1

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

Community
  • 1
  • 1
user1189728
  • 157
  • 1
  • 4
  • 8
  • I think you *may* be able to do this by using the modular approach described in `?modular`: in particular, you would need to hack the `reTrms$Lambdat` component returned from the `lFormula` step, and probably the `reTrms$theta` component. But I will have to stare at the [associated CV question](http://stats.stackexchange.com/questions/114742/multiple-correlated-random-non-nested-intercepts-in-r) some more: I don't quite get how you can have length-3 RE vectors (as implied by the var-cov matrix you present) if the grouping variables are **not nested** ... – Ben Bolker Sep 09 '14 at 23:02
  • in fact, I'm not even sure I see how it works with nested grouping variables ... – Ben Bolker Sep 09 '14 at 23:03
  • Thanks Ben! I will try out this hack approach. If you don't mind, could you elaborate on your concern about the length-3 RE vectors? The structure is similar to the one in this paper [link](http://ideas.repec.org/a/tpr/restat/v95y2013i4p1096-1116.html), except that I wish to relax the assumption that the REs are uncorrelated. I have not yet checked MLwin or HLM, but will check and see if they can handle this structure. Thanks for the suggestions (on CV). – user1189728 Sep 30 '14 at 16:36

0 Answers0