rsq.kl | R Documentation |
The Kullback-Leibler-divergence-based R^2 for generalized linear models.
rsq.kl(fitObj,adj=FALSE)
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. |
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).
The R^2 or adjusted R^2.
Dabao Zhang, Department of Statistics, Purdue University
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.
rsq, rsq.partial, pcor
.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.