[R] R-squared in Logistic Regression
Johan Stenberg
jstenberg at ice.mpg.de
Tue Mar 29 10:56:06 CEST 2005
Dear all,
How do I make R show the R-squared (deviance explained by the model) in
a logistic regression?
Below is how I write my syntax. Basically I want to investigate
density-dependence in parasitism of larvae. Note that in the end I
perform a F-test because the dispersion factor (residual deviance /
residual df) is significantly higher than 1. But how do I make R show
the "R-squared"?
Best wishes
Johan
> 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