I’m very new to hierarchical/multilevel analysis, so please excuse me, if my question is basic.
I’m wondering why I get different results if I analyze my data with lme (of nlme) or lmer (of lme4) even though (to my knowledge) I’m using the same design-formula:
I have a repeated measures design with Condition being the repeated-measures factor. Gender is a between-subjects factor and additionally I’m interested in the interaction between Condition and Gender.
I’m analyzing the data of several studies, therefore I included Study as a random-effect factor.
I have to account for the repeated measures structure as well (right?) and therefore I include Person as a random effect, too. Because Person is nested in Study, I include the random effects term:
+ (1|Study/Person)
for lmer and random
= ~ 1|Study/Person
for lme. (I took care that Person is a truly unique number/factor).
However, in the output for lme only the random effects for Study are printed:
Random effects:
Formula: ~1 | Study
Whereas in the output for lmer the random effects for Study and the interaction between Person and Study are printed
Random effects:
Groups Name Variance Std.Dev.
Person:Study (Intercept) 5.261 2.294
Study (Intercept) 2.242 1.497
Residual 66.342 8.145
Number of obs: 784, groups: Person:Study, 392; Study, 7
What is correct? Should I use lme or lmer?
For reference the complete formulas:
nlme::lme(Outcome ~ Condition + Gender + Condition:Gender,
data = nestedData, random = ~ 1|Study/Person,
method="ML", na.action=na.exclude)
lme4::lmer(Outcome ~ Condition + Gender + Condition:Gender +
(1|Study/Person), data = nestedData, REML = FALSE)
(1|Study) + (1|Person)instead of(1|Study/Person). See also https://stackoverflow.com/questions/33586363/mixed-modelling-different-results-between-lme-and-lmer-functions and https://stats.stackexchange.com/questions/228800/crossed-vs-nested-random-effects-how-do-they-differ-and-how-are-they-specified – dariober Feb 28 '22 at 10:23