I'm new to hierarchical models and am learning to use the lme4 package. My understanding is that the fixed effects generated from the lmer() function are suppose to match the coefficients from lm(). However, I can't seem to get the two sets of coefficients to match. Below is an example using the "mpg" data set from ggplot2. If anyone could help me identify the problem with my code or the source of the issue, I'd greatly appreciate it. Thank you!
lm.mpg = lm(hwy ~ displ + year, data = mpg) summary(lm.mpg) lm.mpg$coefficients hlm.mpg = lmer(hwy ~ displ + year + (1 | class), data = mpg, control=lmerControl(optCtrl=list(maxfun=100000))) fixef(hlm.mpg)