Task 1: Fixed to random effects

Start with the code for Lesson 3 - Task 6 (dummy coding) and/or the regression code from Stan User’s guide.

Convert the 3 categorical groups into a random intercept model, i.e.:

  1. Remove the categorical variable from the model matrix
  2. Introduce new data elements for the model to represent the number of categories and the category each observation belongs to
  1. Introduce new parameter elements:
  1. Add the categorical predictor to the result of the matrix multiplication for the linear predictor.
  1. Add a prior for the standard deviation and then put a normal(0, ...) prior on the category random intercepts

How does the fit change from the fixed effect

Task 2: Non-centered parametrization

Convert the above model to non-centered parametrization, i.e.:

  1. Put a normal(0, 1) prior on the random intercept vector
  2. Multiply the raw parameters by the standard deviation in transformed parameters