Can anyone tell me under what conditions the beta estimates differ between lm and lmer with a random intercept? I came across a situation where the fixed effect differed considerably. I thought the std errors should change but the fixed effects should remain unchanged. The difference does not seem to be due to having different cluster sizes or having a large number of clusters with a single observation.
I cannot supply the data but have concocted a simplified example below. In this case the correlation within clusters should be negligible.
library(lme4)
x=c(rep(0,10),rep(1,10))
y=rnorm(length(x),mean=3100,sd=400)-200*x
m=c(1,2,3,4,4,6,7,8,8,10,11,12,13,14,15,16,17,18,20,20)
summary(lm(y~x))
summary(lmer(y~x+(1|m)))
Best Answer
The results of a linear model and a linear mixed-model can differ if the design is unbalanced, i.e., the number of observations per cell is different.
First, consider a balanced design:
The regression coefficients do not differ between both models.
Now, consider an unbalanced design: (The number of observations per subject differs.)
The result of the simple linear model is the same as in the first example, but the result of
lmer
changed.