Exercise

Two group model

Suppose you want to compare my reaction times with those of my son Steven.

A data frame dd is available in your workspace containing two variables Time and Person, which has all of the reaction time measurements for me and my son.

We are interested in the regression model

$$ Time = \beta_0 + \beta_1 * Person $$

The errors are normal with mean 0 and standard deviation \(S\). This model is fit using lm():

lm(Time ~ Person, data = dd)

Now you can simulate from the posterior distribution of (beta0, beta1, S) using the non-informative prior on the regression parameters beta0, beta1 and the sampling standard deviation S!

Instructions

100 XP
  • Perform a regression fit of Time using Person as the only covariate.
  • Simulate 1000 draws from the joint posterior distribution using the sim() function and save the result as sim_fit.
  • Using coef() and sigma.hat(), extract the simulated values of (beta0, beta1) and S from sim_fit.
  • Use plot() to construct a scatterplot of beta0 and beta1, which are stored in the beta_sim vector you made.