I am running mixed effects regression in R, utilizing glmer, and am hoping someone can help clarify the difference between using coef and ranef on the results. Specifically, I have fixed effects $f_1,f_2,f_3$ and random effects $r_1,r_2,r_3.$ When I run coef I get certain coefficent values for each of the fixed and random effects. Additionally when I use the ranef function I get coefficients for my random effects. These two coefficients are not equal for each respective random effect $r_1,r_2,r_3.$ Why are these coefficients different and what information each coefficient tells us?

  • $\begingroup$ coef returns coefficients and ranef returns modes of random effects - what i not clear in it for you? $\endgroup$ – Tim Oct 20 '15 at 19:36
  • $\begingroup$ @Tim Why doesn't coef = ranef. Shouldn't the coefficient = mode of random effect = mean of random effect? $\endgroup$ – OuijiBoard Oct 20 '15 at 19:41
  • $\begingroup$ @Tim Then what information is being given to me when coef() returns a coefficient of a random effect? $\endgroup$ – OuijiBoard Oct 20 '15 at 19:47

From lme4 documentation you can learn that

coef: Computes the sum of the random and fixed effects coefficients for each explanatory variable for each level of each grouping factor

and ranef is

A generic function to extract the conditional modes of the random effects from a fitted model object. For linear mixed models the conditional modes of the random effects are also the conditional means.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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