rsq.v: Variance-Function-Based R-Squared

View source: R/rsq.R

rsq.vR Documentation

Variance-Function-Based R-Squared

Description

Calculate the variance-function-based R-squared for generalized linear (mixed) models.

Usage

rsq.v(fitObj,adj=FALSE)

Arguments

fitObj

an object of class "lm", "glm", "lme", or "glmerMod", usually, a result of a call to lm, glm, glm.nb, glmer, or glmer.nb.

adj

logical; if TRUE, calculate the adjusted R^2.

Details

The R^2 relies on the variance function, and is well-defined for quasi models. It reduces to the classical R^2 when the variance function is constant or linear. For (generalized) linear mixed models, there are three types of R^2 calculated on the basis of observed response values, estimates of fixed effects, and variance components, i.e., model-based R_M^2 (proportion of variation explained by the model in total, including both fixed-effects and random-efffects factors), fixed-effects R_F^2 (proportion of variation explained by the fixed-effects factors), and random-effects R_R^2 (proportion of variation explained by the random-effects factors).

Value

The R^2 or adjusted R^2. For (generalized) linear mixed models,

R_M^2

proportion of variation explained by the model in total, including both fixed-effects and random-efffects factors.

R_F^2

proportion of variation explained by the fixed-effects factors.

R_R^2

proportion of variation explained by the random-effects factors.

Author(s)

Dabao Zhang, Department of Statistics, Purdue University

References

Zhang, D. (2017). A coefficient of determination for generalized linear models. The American Statistician, 71(4): 310-316.

Zhang, D. (2020). Coefficients of determination for mixed-effects models. arXiv:2007.08675.

See Also

vresidual, rsq, rsq.glmm, rsq.partial, pcor.

Examples

data(hcrabs)
attach(hcrabs)
y <- ifelse(num.satellites>0,1,0)
bnfit <- glm(y~color+spine+width+weight,family=binomial)
rsq.v(bnfit)
rsq.v(bnfit,adj=TRUE)

quasibn <- glm(y~color+spine+width+weight,family=quasibinomial)
rsq.v(quasibn)
rsq.v(quasibn,adj=TRUE)

# Generalized linear mixed models
require(lme4)
data(cbpp)
glmm1 <- glmer(cbind(incidence,size-incidence)~period+(1|herd),data=cbpp,family=binomial)
rsq.v(glmm1)

rsq documentation built on Oct. 22, 2023, 5:07 p.m.

Related to rsq.v in rsq...