Message-ID: <0997001E-E284-4746-85E2-731935E3F8E4@glasgow.ac.uk>
Date: 2020-10-26T10:11:10Z
From: Paul Johnson
Subject: Variance of the fixed effects lme4
In-Reply-To: <CACgv6yUkovnb64oZKRM319EK2BsXVncYTJS7JUHGWSp9Tgaz8Q@mail.gmail.com>
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 at 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 at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models