Learn R Programming

performance (version 0.4.5)

r2_nakagawa: Nakagawa's R2 for mixed models

Description

Compute the marginal and conditional r-squared value for mixed effects models with complex random effects structures.

Usage

r2_nakagawa(model)

Arguments

model

A mixed effects model.

Value

A list with the conditional and marginal R2 values.

Details

Marginal and conditional r-squared values for mixed models are calculated based on Nakagawa et al. 2017. For more details on the computation of the variances, see get_variance.

The marginal r-squared considers only the variance of the fixed effects, while the conditional r-squared takes both the fixed and random effects into account. The random effect variances are actually the mean random effect variances, thus the r-squared value is also appropriate for mixed models with random slopes or nested random effects (see Johnson 2014).

References

  • Johnson, P. C. D. (2014). Extension of Nakagawa & Schielzeth<U+2019>s R2 GLMM to random slopes models. Methods in Ecology and Evolution, 5(9), 944<U+2013>946. 10.1111/2041-210X.12225

  • Nakagawa, S., & Schielzeth, H. (2013). A general and simple method for obtaining R2 from generalized linear mixed-effects models. Methods in Ecology and Evolution, 4(2), 133<U+2013>142. 10.1111/j.2041-210x.2012.00261.x

  • Nakagawa, S., Johnson, P. C. D., & Schielzeth, H. (2017). The coefficient of determination R2 and intra-class correlation coefficient from generalized linear mixed-effects models revisited and expanded. Journal of The Royal Society Interface, 14(134), 20170213. 10.1098/rsif.2017.0213

Examples

Run this code
# NOT RUN {
if (require("lme4")) {
  model <- lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris)
  r2_nakagawa(model)
}
# }

Run the code above in your browser using DataLab