I am trying to estimate a longitudinal model in R in which there are several random intercepts that are correlated with each other, and the data are non-nested. For example, consider a simple longitudinal model in which student test scores are regressed on three random intercepts, one random school effect, one random teacher effect, and one random teacher-school match effect. The data are non-nested because teachers frequently switch schools in the longitudinal data. I am primarily interested in the random effects parameters themselves, and so I want to specify all three random effects and allow them to be correlated with each other. There are no random slopes, only random intercepts.
I tried:
model1 <- lmer(test_score ~ FEs + (1|schoolid) + (1|teacherid) + (1|matchid), data)
but this appears to force the random effects to be uncorrelated with each other. Is there a way, using lmer
or any other R package to estimate a similar model in which the random intercepts are allowed to be correlated with each other (using non-nested data)?
More specifically, the above model forces the covariance matrix to be diagonal. What I would like to estimate instead is a random effects model with an unrestricted covariance matrix like this link