1
$\begingroup$

When I run my output from the lmer function for random effects, I get something like this:

form_lmer1 <- "y  ~   1 + Var1 + (1+Var1 | group)"
fm3        <- lmer(as.formula(form_lmer1), df, REML=FALSE, verbose=TRUE)
ranef(fm3)
# $group
#      (Intercept)                    Var1
# 500  0.044211088           -0.0127878291
# 501 -0.047100911            0.0779782538
# 502  0.038150455           -0.0073571972
# 504  0.040368393           -0.0089280108
# 505  0.062128815           -0.0308154532
# 506  0.004291613            0.0265210988

Are these just the differences of the fixed effects / coefficients?

fixef(fm3)
#  (Intercept)                    Var1 
#  0.970103582             0.001630575

So if I wanted to calculate the new coefficients by group, I would just add/subtract from the fixed effect?

$\endgroup$

1 Answer 1

2
$\begingroup$

You have the gist of it. With a mixed model you are estimating a population distribution, which is assumed to be normal.

Consider a simple model with only an intercept (and a random effect for the intercept). The 'fixed effect' for the intercept is the mean of the population, and the variance of the reported random effect is the population variance. The fitting algorithm can further compute 'BLUP's for each group as a function of that group's data and the estimated model parameters. (For more information, it may help to read my answer here: Why do the estimated values from a Best Linear Unbiased Predictor (BLUP) differ from a Best Linear Unbiased Estimator (BLUE)?)

If you add a slope to the model and fit random effects for that, you are assuming there is a population distribution of group slopes. The fixed effects are the population distribution means, and the random effect variances are the variances of those distributions.

The regression line determined by the fixed effects for the intercept and slope is just the population mean, but that doesn't necessarily reflect the line that an specific individual group varies around. To get the best guess for that line, you would add the fixed effect for the intercept with the BLUP for the intercept for that group, and compute the slope likewise.

In the outputted lmer object, you should be able to use coef(object), and get the summed fixed and random effects, or you can get the individually (as you do here), and sum them yourself.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.