[R] Dispersion factor in GLM
Johan Stenberg
jstenberg at ice.mpg.de
Tue Mar 15 20:26:15 CET 2005
Dear all,
I have two questions concerning GLM (logistic regression) with
family=binomial.
1. A measure of the departure from the binomial assumption is given by
the
dispersion factor (= residual deviance / residual df). The data is
over-dispersed when the dispersion factor is significantly higher than 1
(Crawley, page 518). Is there any way to test if the dispersion factor
is significantly higher than 1? The residual deviance should be
chi2-distributed which should allow to test for the significance of the
departure...
See below to see how my syntax looks like.
2. How do you calculate the proportion of deviance explained by the
model (the equivalent of r2 in a standard regression) in R?
Kind regards
Johan Stenberg
> y<-cbind(para,unpara)
> model<-glm(y~log(larvae),binomial)
> summary(model)
Call:
glm(formula = y ~ log(larvae), family = binomial)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.0633 -1.6218 -0.1871 0.7907 2.7670
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.0025 0.7049 1.422 0.15499
log(larvae) -1.0640 0.3870 -2.749 0.00597 **
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 35.981 on 12 degrees of freedom
Residual deviance: 27.298 on 11 degrees of freedom
AIC: 40.949
Number of Fisher Scoring iterations: 4
> anova(model,test="F")
Analysis of Deviance Table
Model: binomial, link: logit
Response: y
Terms added sequentially (first to last)
Df Deviance Resid. Df Resid. Dev F Pr(>F)
NULL 12 35.981
log(larvae) 1 8.683 11 27.298 8.6828 0.003212 **
More information about the R-help
mailing list