I have a repeated measures from clusters, over several years, and I expect the cluster effect to vary each year. Year is coded as a factor, with '1' as reference level. I have tried the following:
mod1 <- lmer(y ~ x + year + (year|cluster))
and
mod2 <- lmer(y ~ x + year + (1|cluster:year))
My first example specifies the following random effects:
ranef(mod1)
$cluster
(Intercept) year2 year3 year4 year5
AA 0.03721015 0.0573160920 -0.114709171 0.1588302187 0.125329740
AB -0.12958994 -0.0458997003 0.216455596 0.2345170893 0.248950509
AC -5.10692972 -0.1311546328 1.130347798 2.5215580167 5.070106525
AD 0.10087455 -0.2677088515 -0.345583355 -0.2442831982 -0.257074662
....
Second one specifies:
ranef(mod2)
$`cluster:year`
(Intercept)
AA:year2 0.0838186244
AA:year3 -0.1197284361
AA:year4 0.1944488619
AA:year5 0.1562090690
I assumed they would be equivalent, given year is a factor, but I must not understand the random effect specification of lme4
well enough. Can anyone help me understand the difference between the two parameterizations?