Skip to content
Prev 18846 / 20628 Next

Variance of the fixed effects lme4

Hi Simon,

The usual way is to calculate the variance of the fitted values on the link scale, using only the fixed effects. 
E.g. for lme4 fits, appendix S6 of https://doi.org/10.1098/rsif.2017.0213 gives:

# Calculation of the variance in fitted values
VarF <-var(as.vector(model.matrix(parmodGLMERf) %*% fixef(parmodGLMERf)))

Which is essentially the same as the method used in the code for the original Nakagawa & Schielzeth R2_GLMM paper cited in the website you mentioned: https://doi.org/10.1111/j.2041-210x.2012.00261.x

I think this will be the same as:
VarF <-var(fitted(parmodGLMERf))

But as a general method this might be less safe because I can never remember if all the fitted() methods give the link scale fitted values by default, and whether they ever include random effects.

Best wishes,
Paul