I have been reading about calculating $R^2$ values in mixed models and after reading the R-sig FAQ, other posts on this forum (I would link a few but I don't have enough reputation) and several other references I understand that using $R^2$ values in the context of mixed models is complicated.
However, I have recently came across these two papers below. While these methods do look promising (to me) I am not a statistician, and as such I was wondering if anyone else would have any insight about the methods they propose and how they would compare to other methods that have been proposed.
Nakagawa, Shinichi, and Holger Schielzeth. "A general and simple method for obtaining R2 from generalized linear mixed‐effects models." Methods in Ecology and Evolution 4.2 (2013): 133-142.
Johnson, Paul CD. "Extension of Nakagawa & Schielzeth's R2GLMM to random slopes models." Methods in Ecology and Evolution (2014).
The is method can also be implemented using the r.squaredGLMM function in the MuMIn package which gives the following description of the method.
For mixed-effects models, $R^2$ can be categorized into two types. Marginal $R^2$ represents the variance explained by fixed factors, and is defined as: $$R_{GLMM}(m)^2 = \frac{σ_f^2}{σ_f^2 + \sum(σ_l^2) + σ_e^2 + σ_d^2}$$ Conditional $R^2$ is interpreted as variance explained by both fixed and random factors (i.e. the entire model), and is calculated according to the equation: $$R_{GLMM}(c)^2= \frac{(σ_f^2 + \sum(σ_l^2))}{(σ_f^2 + \sum(σ_l^2) + σ_e^2 + σ_d^2}$$ where $σ_f^2$ is the variance of the fixed effect components, and $\sum(σ_l^2)$ is the sum of all variance components (group, individual, etc.), $σ_l^2$ is the variance due to additive dispersion and $σ_d^2$ is the distribution-specific variance.
In my analysis I am looking at longitudinal data and I am primarily interested in variance explained by the fixed effects in the model
library(MuMIn)
library(lme4)
fm1 <- lmer(zglobcog ~ age_c + gender_R2 + ibphdtdep + iyeareducc + apoegeno + age_c*apoegeno + (age_c | pathid), data = dat, REML = FALSE, control = lmerControl(optimizer = "Nelder_Mead"))
# Jarret Byrnes (correlation between the fitted and the observed values)
r2.corr.mer <- function(m) {
lmfit <- lm(model.response(model.frame(m)) ~ fitted(m))
summary(lmfit)$r.squared
}
r2.corr.mer(fm1)
[1] 0.8857005
# Xu 2003
1-var(residuals(fm1))/(var(model.response(model.frame(fm1))))
[1] 0.8783479
# Nakagawa & Schielzeth's (2013)
r.squaredGLMM(fm1)
R2m R2c
0.1778225 0.8099395