# Why are the beta values provided in lmer() different than simple group means of observations?

In a 2-level mixed-effect model, the equation for level-1 is

$$Y_{ij} = \beta_{0j} + r_{ij}$$

where $\beta_{0j}$ is the mean outcome for the $j$-th group.

I ran the following model: model.1 = lmer(score ~ (1|group), REML = T, data = data)

However, in the output from lmer(), I see that the beta values are slightly different than the means I compute by hand in Excel.

For example, my dataset has 3 groups of 20 observations each. The 3 means of the observations that I calculate by hand in Excel are:

9.118, 7.004, and 4.837.

However, by using the script: model.1@resp$mu, I learn that lmer() computed those same means as: 9.040, 7.003, and 4.916. It appears that lmer() is doing some sort of weighting to compute the beta values (the group means). Can you help me understand how lmer() is computing these group means? Ultimately, I'd like to be able to do the computation myself in Excel and arrive at the same beta values as lmer() provides. ## 1 Answer Mixed effects do not simply compute group means - if it did so you didn't have to use such model but could just compute the means. First, notice that the model you described and your model specification in lme4 differ. In lme4 score ~ (1|group) translates to $$Y_{ij} = \beta_{00} + b_{0j} + r_{ij}$$ where$\beta_{00}$is an (fixed) intercept and$b_{0j}$is a random intercept term. If you like to write the model you described in lme4, you should rather define it as score ~ 0 + (1|group) where 0 (or -1) translates to "no intercept" as in standard R formulas (check the Bates et al. paper on lme4). However notice that you should rather not drop the intercept from your model. And now, answering your question, consider that your model is $$Y_{ij} = b_{0j} + r_{ij}$$ while means the groups would be something like: $$Y_{ij} = \overline{Y}_{j}$$ so the difference is that in mixed model you include information on both individual ($r_{ij}$) and group level ($b_{0j}$), while with computing means you are only interested in group level results. Mixed models were discovered to include both levels of variation in your model and not just group level variation (here you can find an example why you should not confuse individual and group level data). If you include a higher level intercept terms (e.g. here$\beta_{00}\$) then your model gets even more complicated then "group means".

For learning more I recommend you the following books:

• Snijders, T.A.B. and Bosker, R.J. (2012). Multilevel Analysis: An Introduction to Basic and Advanced Multilevel Modeling. London: Sage Publishers.
• Hox, J. (2010). Multilevel Analysis: Techniques and Applications. New York: Routledge.
• Gelman, A. and Hill, J. (2006). Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge: Cambridge University Press.
• Pinheiro, J.C. and Bates, D.M. (2000). Mixed-Effects Models in S and S-PLUS. New York: Springer.
• Thanks Tim. I realize the equation I provided was only for the first level of my lmer() model. And I understand that the full mixed model accounts for residuals among the observations within groups (r-ij) AND among the groups (u-0j). However, don't the residuals among the observations within the groups reflect the deviance of each observation from the mean of all observations within the group? My original question concerns how those group means are computed in R. For example, the mean of the scores in one of my groups is 9.118, but lmer() is using a value of 9.040. How is 9.040 computed? Jan 22, 2015 at 17:02
• Those are not group means - think of them rather as "unbiased group means". So they won't be the same as raw group means however in many cases they would provide you better estimate of group effects then group means. For details about implementation check the Bates et al. (developers of lme4) paper or Pinhero and Bates book (developers of nlme), there you'll find more details.
– Tim
Jan 22, 2015 at 17:06
• Okay, your correction of my mis-impression of the beta's as group means is helpful. I'll refer to the Bates et al. article for further details about it. Thank you. Jan 22, 2015 at 17:17
• For more intuitions check also: en.wikipedia.org/wiki/Stein%27s_example
– Tim
Jan 22, 2015 at 17:19
• In Bates et al., I found that table 7 on page 20 was helpful. It provides equations for how "mu" and "wtres" are computed in lmer() and links to further details within the article for each. Linear predictor "mu": μY|U=u (Equation 13). Weighted residuals "wtres": W1/2(yobs − μ) Jan 22, 2015 at 17:36