Session Ready
Exercise

Visualizing the regression priors

In the previous exercise, you simulated 10,000 samples for each parameter (\(a\), \(b\), \(s\)) in the Bayesian regression model of weight \(Y\) by height \(X\): \(Y \sim N(m, s^2)\) with mean \(m = a + bX\). The set of \(a\), \(b\), and \(s\) values in each row of samples represents a prior plausible regression scenario. To explore the scope of these prior scenarios, you will simulate 50 pairs of height and weight values from each of the first 12 sets of prior parameters \(a\), \(b\), and \(s\).

Instructions
100 XP
  • Create a data frame prior_simulation which includes n = 50 replicates of the first 12 sets of prior parameters in samples (600 rows in total!).
  • For each of the 600 prior_simulation rows:
    • Simulate a height value from a \(N(170, 10^2)\) model.
    • Simulate a weight value from \(N(a + b X, s^2)\) where \(X\) is height and \((a,b,s)\) are the prior parameter set.
  • You now have 50 simulated height and weight pairs for each of the 12 parameter sets. Use ggplot() to construct a scatterplot of these 50 pairs for each set of parameter values. Be sure to put weight on the y-axis!