[R-sig-ME] correlation of random factors in mixed models

Luis Cayuela Delgado luis.cayuela at urjc.es
Mon Oct 6 18:32:28 CEST 2014


Dear list,


I have three related questions about how to interpret the output of a mixed model. First, I am interested in understanding what is the meaning of the correlation for random factors. For example:


library(lme4)

mod0 <- lmer(Reaction ~ Days + (Days|Subject), data = sleepstudy)

summary(mod0)


This gives a correlation for random effects of 0.07. From other posts in the list I understood that this was the correlation between the random intercepts and the random slopes, so it should be calculated as:


ran0 <- ranef(mod0)

ran0

cor(ran0$Subject[,1], ran0$Subject[,2])



But this gives a correlation of 0.26. So how is the correlation for random effects estimated?


Second, in case this correlation was high, what implications this might have? I have learned that the model could be refitted removing the correlation between random intercept and slope by specifying the model as follows:


mod1 <- lmer(Reaction ~ Days + (1|Subject) + (0 + Days|Subject), data = sleepstudy)

summary(mod1)


When it is advisable to do this? If correlation of random effects was such a major issue, shouldn't we always fit the model as 'mod1'?


And then a final question, I have seen that when specifying the model as 'mod1', the correlation of fixed effects change. I don't get this, since correlation of fixed effects -as far as I understood- is calculated from the estimated parameters of independent linear models for each of the levels of the random factor. So for the above-mentioned example:


a <- lmList(Reaction ~ Days | Subject, sleepstudy)

cor(coef(a)[,1], coef(a)[,2])


This results in a correlation coefficient of -0.138, which matches the correlation for fixed effects in 'mod0'. So where does the correlation for fixed effects in 'mod1' (r = -0.184) come from?


Sorry for such a long post and hope that the questions are interesting for some other list useRs.


I am working with R 3.1.0. under Ubuntu Saucy 13.10, with package 'nlme' version 3.1.117 and package 'lme4' version 1.1.-7.


Thanks in advance,


Luis Cayuela

Universidad Rey Juan Carlos

Spain


	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list