Hi, I’m moving a project from RStanARM to Stan just to build by knowledge of Stan modeling. I’m struggling with representing nested random effects in a Stan script. In RStanARM, the model is
formula = close ~ (1|year_id\dsp_id) - 1...
That is, it’s a lme4 syntax representation of
formula = close ~ (1|year_id) + (1|year_id:dsp_id) - 1...
I’m trying to figure out how to represent this in native Stan code. I’ve been able to run the model for two random effects:
vector[N_obs] p = dsp[dsp_id] + year[year_id]
But I need help with how to write out the interaction. Please note that this is an interaction of two categorical random variables. Data and Stan model attached. I don’t think I need to change anything besides the function above, but please correct me if I’m wrong. Thanks.