Skip to contents

Calculate the R2, also known as the coefficient of determination, value for different model objects. Depending on the model, R2, pseudo-R2, or marginal / adjusted R2 values are returned.


r2(model, ...)

# Default S3 method
r2(model, ci = NULL, verbose = TRUE, ...)

# S3 method for class 'merMod'
r2(model, ci = NULL, tolerance = 1e-05, ...)



A statistical model.


Arguments passed down to the related r2-methods.


Confidence interval level, as scalar. If NULL (default), no confidence intervals for R2 are calculated.


Logical. Should details about R2 and CI methods be given (TRUE) or not (FALSE)?


Tolerance for singularity check of random effects, to decide whether to compute random effect variances for the conditional r-squared or not. Indicates up to which value the convergence result is accepted. When r2_nakagawa() returns a warning, stating that random effect variances can't be computed (and thus, the conditional r-squared is NA), decrease the tolerance-level. See also check_singularity().


Returns a list containing values related to the most appropriate R2 for the given model (or NULL if no R2 could be extracted). See the list below:


If there is no r2()-method defined for the given model class, r2() tries to return a "generic" r-quared value, calculated as following: 1-sum((y-y_hat)^2)/sum((y-y_bar)^2))


# Pseudo r-quared for GLM
model <- glm(vs ~ wt + mpg, data = mtcars, family = "binomial")
#> # R2 for Logistic Regression
#>   Tjur's R2: 0.478

# r-squared including confidence intervals
model <- lm(mpg ~ wt + hp, data = mtcars)
r2(model, ci = 0.95)
#>        R2: 0.827 [0.654, 0.906]
#>   adj. R2: 0.815 [0.632, 0.899]

model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris)
#> # R2 for Mixed Models
#>   Conditional R2: 0.969
#>      Marginal R2: 0.658