[R-sig-ME] Variance of the fixed effects lme4

Paul Johnson p@u|@john@on @end|ng |rom g|@@gow@@c@uk
Mon Oct 26 11:11:10 CET 2020


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


> On 26 Oct 2020, at 07:42, Simon Harmel <sim.harmel using gmail.com> wrote:
> 
> Hello All,
> 
> The below website talks about the use of "the variance of the fixed
> effects" in the computation of R-squared from a mixed model.
> 
> But what is "the variance of the fixed effects"? Is it the sum of
> the diagonal elements obtained from:   vcov(fitted_model)?
> 
> The website:
> https://www.theanalysisfactor.com/r-squared-for-mixed-effects-models/
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



More information about the R-sig-mixed-models mailing list