Shouldn't the beta estimates always be the same using lm and lmer? 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)))

 A: 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:
df <- data.frame(x = rep(0:1, each = 10), y = 1:20, m = rep(1:10, each = 2))

lm(y ~ x, df)
# Coefficients:
# (Intercept)            x  
#         5.5         10.0  

library(lme4)
lmer(y ~ x + (1 | m), df)
# Fixed effects:
#             Estimate Std. Error t value
# (Intercept)    5.500      1.414   3.889
# x             10.000      2.000   5.000

The regression coefficients do not differ between both models.
Now, consider an unbalanced design:
  (The number of observations per subject differs.)
df2 <- data.frame(x = rep(0:1, each = 10), y = 1:20, m = rep.int(1:10, times = rep(c(1, 3), times = 5)))

lm(y ~ x, df2)
# Coefficients:
# (Intercept)            x  
#         5.5         10.0  

library(lme4)
lmer(y ~ x + (1 | m), df2)
# Fixed effects:
#             Estimate Std. Error t value
# (Intercept)    8.752      1.643   5.325
# x              2.699      1.164   2.318

The result of the simple linear model is the same as in the first example, but the result of lmer changed.
