multilevel_r2 | R Documentation |
Calculates the multilevel R squared for two-level models.
multilevel_r2(model1, model2, n = table(model1$groups))
model1 |
The first model. |
model2 |
The second model. |
n |
Optional vector of group sizes for level 2. |
A list with the following components:
r2_l1 |
The R squared value for level 1. |
r2_l2 |
The R squared value for level 2. |
r2_l1_2 |
The combined R squared value for levels 1 and 2. |
r2_l2_2 |
The adjusted R squared value for levels 1 and 2 (with optional group sizes). |
n |
The harmonic mean of the group sizes (if provided). |
Snijders, T. A. B., & Bosker, R. J. (1994). Modeled Variance in Two-Level Models. Sociological Methods & Research, 22(3), 342-363.
data(sleepstudy, package = "lme4")
model1 <- nlme::lme(Reaction ~ 1, data = sleepstudy, random =~ 1|Subject)
model2 <- nlme::lme(Reaction ~ Days, data = sleepstudy, random =~ 1|Subject)
multilevel_r2(model1, model2, table(sleepstudy$Subject))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.