Data Analysis

  1. The datafile “prostate.Rdata” is available on Canvas. You can load it into R using the load function.
    This dataset consists of several clinical measurements for patients with prostate cancer.
    (a) Consider the lpsa variable, a commonly used proxy for prostate cancer severity. Use a Bayesian
    approach to construct a 95% confidence/credible interval for the mean and variance of the lpsa
    level (include plots of the posterior as well). Use conjugate priors and choose the hyperparameters
    to be ”weak”, in the sense that they don’t appear to have much of an effect on the posterior.
    (b) Redo your analysis, but now set up a Metropolis-Hastings algorithm to sample from the posterior.
    Sample 100,000 pairs (µ, σ2
    ) from the posterior. Note, you may still use the fact that the prior is
    conjugate. You are free to decide how to make proposals, but the easiest would be to use uniforms
    as we did in class (however, now you have two variables).
    (c) Now repeat the previous part, but instead of sampling manually, use the metrop function in the
    MCMC package to do the sampling for you. Use the R help file to guide you, but the primary
    thing you need to give it is the log of the posterior density function (first argument), starting
    values (second argument), and the samples size (third argument).

Sample Solution