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 imposes the covariance structure: $$ Cov \left[ \begin{array} \\ \theta_{s} \\ \theta_{t} \\ \theta_{m} \\ \end{array} \right] = \left[ \begin{array} \\ \sigma^{2}_{\theta_{s}}I_{s} & 0 & 0 \\ 0& \sigma^{2}_{\theta_{t}}I_{t} & 0\\ 0&0&\sigma^{2}_{\theta_{m}}I_{m}\\ \end{array} \right] $$
What I would like to estimate instead is a random effects model with the following covariance structure:
$$ Cov \left[ \begin{array} \\ \theta_{s} \\ \theta_{t} \\ \theta_{m} \\ \end{array} \right] = \left[ \begin{array} \\ \sigma^{2}_{\theta_{s}}I_{s} & \sigma^{2}_{\theta_{st}}C_{st} & \sigma^{2}_{\theta_{sm}}C_{sm} \\ \sigma^{2}_{\theta_{ts}}C_{ts} & \sigma^{2}_{\theta_{t}}I_{t} & \sigma^{2}_{\theta_{tm}}C_{tm}\\ \sigma^{2}_{\theta_{ms}}C_{ms} &\sigma^{2}_{\theta_{mt}}C_{mt} &\sigma^{2}_{\theta_{m}}I_{m}\\ \end{array} \right] $$ where $C_{st}$, for example, is a matrix of zeros and ones, with $C(i,j)=1$ where there is an observation of the pair $(school=i, teacher=j)$ in the data, and 0 if no such pair is observed.