rsq.kl: KL-Divergence-Based R-Squared

View source: R/rsq.R

rsq.klR Documentation

KL-Divergence-Based R-Squared

Description

The Kullback-Leibler-divergence-based R^2 for generalized linear models.

Usage

rsq.kl(fitObj,adj=FALSE)

Arguments

fitObj

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

adj

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

Details

This version of R^2 was proposed by Cameron and Windmeijer (1997). It is extended to quasi models (Zhang, 2017) based on the quasi-likelihood function (McCullagh, 1983).

Value

The R^2 or adjusted R^2.

Author(s)

Dabao Zhang, Department of Statistics, Purdue University

References

Cameron, A. C. and Windmeijer, A. G. (1997) An R-squared measure of goodness of fit for some common nonlinear regression models. Journal of Econometrics, 77: 329-342.

McCullagh, P. (1983) Quasi-likelihood functions. Annals of Statistics, 11: 59-67.

See Also

rsq, 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.kl(bnfit)
rsq.kl(bnfit,adj=TRUE)

psfit <- glm(num.satellites~color+spine+width+weight,family=poisson)
rsq.kl(psfit)
rsq.kl(psfit,adj=TRUE)

# Effectiveness of Bycycle Safety Helmets in Thompson et al. (1989)
y <- matrix(c(17,218,233,758),2,2)
x <- factor(c("yes","no"))
tbn <- glm(y~x,family=binomial)
rsq.kl(tbn)
rsq.kl(tbn,adj=TRUE)

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

Related to rsq.kl in rsq...