Instructions

Please make sure your final output file is a pdf document. You can submit handwritten solutions for non-programming exercises or type them using R Markdown, LaTeX or any other word processor. All programming exercises MUST be done in R, typed up clearly and with all code attached. Submissions should be made on gradescope: go to Assignments \(\rightarrow\) Homework 7.

Questions

  1. Continuation of the swimming data from class. Recall the problem from class on swimming times. Download the data here: http://www2.stat.duke.edu/~pdh10/FCBS/Exercises/swim.dat. Alternatively, you can create the data by manually typing in the data from class slides (here: https://sta-602l-s20.github.io/Course-Website/slides/lec-slides/17-linear-regression.html#70.) into R.

    The file contains data on the amount of time in seconds it takes each of 4 high school swimmers to swim 50 yards. There are 6 times for each student, taken every two weeks. That is, each swimmer has six measurements at \(W = 2, 4, 6, 8, 10, 12\) weeks. Each row corresponds to a swimmer and a higher column index indicates a later date. I did not write it explicitly on the slides but the model for each swimmer is \[T_{i} = \beta_0 + \beta_1 (W_i - \bar{W}) + \epsilon_i,\] where \(T_i\) represents the swimming times and \(\epsilon_i \sim \mathcal{N}(0,\sigma^2)\).
    • Part (a): Using the g-prior with g = n = 6, generate samples/realizations from the prior predictive distribution for a single swimmer over the 12 weeks \((W = 2, 4, 6, 8, 10, 12)\) and create a density plot of the predictive draws (one for each \(W\)). Are the values plausible?
    • Part (b): Using the data, and the g-prior with g = n = 6 for each swimmer, give the posterior distributions of \(\beta_0\), \(\beta_1\) and \(\sigma^2\) for each swimmer.
    • Part (c): For each swimmer \(j\), plot their posterior predictive distributions for a future time \(T^\star\) two weeks after the last recorded observation (overlay the 4 densities in a single plot).
    • Part (d): The coach of the team has to recommend which of the swimmers to compete in a swim meet in two weeks time. Using draws from the predictive distributions, compute \(P(Y_j^\star = \text{max}(Y_1^\star,Y_2^\star,Y_3^\star,Y_4^\star))\) for each swimmer \(j\), and based on this make a recommendation to the coach.
  2. Hoff 9.2.

    You must write your own sampler for part (a). For part (b), you donโ€™t need to write your own Gibbs sampler. Just follow our approach from class and use the packages. Be sure to compare your results to the results from part (a). You can find the data file azdiabetes.dat mentioned in the question here: http://www2.stat.duke.edu/~pdh10/FCBS/Exercises/.

Grading

20 points.