r2_cor: Pseudo R-squared: Squared correlation between predicted and...

View source: R/r2_cor.R

r2_corR Documentation

Pseudo R-squared: Squared correlation between predicted and observed values

Description

The r2_cor function estimates a pseudo R-squared by correlating predicted \hat{Y} values and observed Y values. This pseudo R-squared is similar to the R^2 used in OLS regression. It indicates amount of variation in the outcome that is explained by the model (Peugh, 2010; Singer & Willett, 2003, p. 36).

Usage

r2_cor(x, verbose = FALSE)

Arguments

x

A model produced using the lme4::lmer() function. This is an object of class merMod and subclass lmerMod.

verbose

If true, prints an explanatory message, "The squared correlation between predicted and observed values is...". If false (default), returns a value.

Value

If verbose == TRUE, a console message. If verbose == FALSE (default), a numeric value.

References

\insertRef

peugh2010mlmhelpr

\insertRef

singer2003mlmhelpr

Examples


fit <- lme4::lmer(mathach ~ 1 + ses + catholic + (1|id),
data=hsb, REML=TRUE)

# returns a numeric value
r2_cor(fit)

# returns a console message with the r2 value
r2_cor(fit, verbose = TRUE)

lrocconi/mlmhelpr documentation built on Dec. 9, 2024, 10:58 p.m.