R2Dev: Compute R^2 for a GLM based on deviance residuals

View source: R/GLM_functions.R

R2DevR Documentation

Compute R^2 for a GLM based on deviance residuals

Description

Computes an R^2 measure for a generalized linear model (GLM) that is based on deviance residuals, as discussed in Fox (1997, p. 481) and Cameron and Windmeijer (1997).

Usage

R2Dev(x, digits = NULL)

Arguments

x

A model fit via glm().

digits

An integer specifying the number of decimal places to used when rounding the result. Defaults to NULL, which does not round the result.

Details

=============================================================================

This R^2 measure has a number of desirable properties and is also called R^2_KL (Cameron & Windmeijer, 1997). It is suitable for use with logistic regression and Poisson regression models.

Value

A numeric value for the R^2.

References

Cameron, A. C., & Windmeijer, F. A. G. (1997). An R-squared measure of goodness of fit for some common nonlinear regression models. Journal of Econometrics, 77(2), 329-342. doi:10.1016/S0304-4076(96)01818-0

Fox, J. (1997). Applied regression analysis, linear models, and related methods. Thousand Oaks, CA: Sage Publications.

Examples

m1 <- glm(formula = vs ~ wt + disp, family = binomial, data = mtcars)
R2Dev(m1)
R2Dev(m1, digits = 2)


sjpierce/piercer documentation built on Dec. 30, 2024, 3:28 p.m.