Johan Stenberg wrote:
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

The proportion of deviance explained has been shown to not be such a good measure. You can use the lrm function in the Design package to get various measures including ROC area (C index), Somers' Dxy and Kendall tau rank correlation, Nagelkerke generalization of R-squared for maximum likelihood-based models (related to Maddala and others).


Frank Harrell



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 **

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



--
Frank E Harrell Jr   Professor and Chair           School of Medicine
                     Department of Biostatistics   Vanderbilt University

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to