Calculates marginal and conditional R-squared values for Gaussian linear mixed-effects models fitted with lme4::lmer(). Marginal R-squared describes variance explained by fixed effects; conditional R-squared describes variance explained by fixed and random effects. For random-slope models, the random-effect contribution is the mean observation-level random variance.

mixed_model_r2(model)

Arguments

model

A Gaussian lmerMod model fitted with lme4::lmer().

Value

A one-row data frame with columns R2m and R2c.

References

Nakagawa, S. & Schielzeth, H. (2013). A general and simple method for obtaining R-squared from generalized linear mixed-effects models. Methods in Ecology and Evolution, 4, 133-142.

Johnson, P. C. D. (2014). Extension of Nakagawa & Schielzeth's R-squared GLMM to random slopes models. Methods in Ecology and Evolution, 5, 944-946.

Nakagawa, S., Johnson, P. C. D., & Schielzeth, H. (2017). The coefficient of determination R-squared and intra-class correlation coefficient from generalized linear mixed-effects models revisited and expanded. Journal of the Royal Society Interface, 14, 20170213.

Examples

if (FALSE) { # \dontrun{
model <- lme4::lmer(Reaction ~ Days + (Days | Subject), lme4::sleepstudy)
mixed_model_r2(model)
} # }