Wuming Gong
2005-Jun-24 08:04 UTC
[R] How to find the significant differences among interactions in logit model?
Hi, I have a question about interpret the results from logistic regression model. I used a dataset from the book Categorical Data Analysis (2nd Edition) by Alan Agresti.> summary(crabs)color spine width satell weight psat 2:12 1: 37 Min. :21.0 Min. : 0.000 Min. :1200 Mode :logical 3:95 2: 15 1st Qu.:24.9 1st Qu.: 0.000 1st Qu.:2000 FALSE:62 4:44 3:121 Median :26.1 Median : 2.000 Median :2350 TRUE :111 5:22 Mean :26.3 Mean : 2.919 Mean :2437 3rd Qu.:27.7 3rd Qu.: 5.000 3rd Qu.:2850 Max. :33.5 Max. :15.000 Max. :5200> crabs.glm <- glm(psat ~ color*width, family=binomial(), data=crabs) > summary(crabs.glm)Call: glm(formula = psat ~ color * width, family = binomial(), data = crabs) Deviance Residuals: Min 1Q Median 3Q Max -2.0546 -0.9129 0.5285 0.8140 1.9657 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -1.75261 11.46409 -0.153 0.878 color3 -8.28735 12.00363 -0.690 0.490 color4 -19.76545 13.34251 -1.481 0.139 color5 -4.10122 13.27532 -0.309 0.757 width 0.10600 0.42656 0.248 0.804 color3:width 0.31287 0.44794 0.698 0.485 color4:width 0.75237 0.50435 1.492 0.136 color5:width 0.09443 0.50042 0.189 0.850 (Dispersion parameter for binomial family taken to be 1) Null deviance: 225.76 on 172 degrees of freedom Residual deviance: 183.08 on 165 degrees of freedom AIC: 199.08 Number of Fisher Scoring iterations: 5 Note the predictors are mixture of continuous data and categorical data. Here, I wonder whether there is *significant difference* among the four interactions of color and width (say, to get a p-value). In a two-way ANOVA, we may do a F-test. But is there an "equivalent" method for logit model? Thanks, Wuming
Prof Brian Ripley
2005-Jun-24 08:22 UTC
[R] How to find the significant differences among interactions in logit model?
Use an analysis of deviance test for the term color:width. Probably most clearly by (untested) crabs.glm2 <- update(crabs.glm, . ~ . - color:width) anova(crabs.glm2, crabs.glm, test="Chisq") This is covered with several examples in MASS. On Fri, 24 Jun 2005, Wuming Gong wrote:> I have a question about interpret the results from logistic regression > model.Not really: this is about comparing two such models.> I used a dataset from the book Categorical Data Analysis (2nd > Edition) by Alan Agresti. > >> summary(crabs) > color spine width satell weight psat > 2:12 1: 37 Min. :21.0 Min. : 0.000 Min. :1200 Mode :logical > 3:95 2: 15 1st Qu.:24.9 1st Qu.: 0.000 1st Qu.:2000 FALSE:62 > 4:44 3:121 Median :26.1 Median : 2.000 Median :2350 TRUE :111 > 5:22 Mean :26.3 Mean : 2.919 Mean :2437 > 3rd Qu.:27.7 3rd Qu.: 5.000 3rd Qu.:2850 > Max. :33.5 Max. :15.000 Max. :5200 > >> crabs.glm <- glm(psat ~ color*width, family=binomial(), data=crabs) >> summary(crabs.glm) > > Call: > glm(formula = psat ~ color * width, family = binomial(), data = crabs) > > Deviance Residuals: > Min 1Q Median 3Q Max > -2.0546 -0.9129 0.5285 0.8140 1.9657 > > Coefficients: > Estimate Std. Error z value Pr(>|z|) > (Intercept) -1.75261 11.46409 -0.153 0.878 > color3 -8.28735 12.00363 -0.690 0.490 > color4 -19.76545 13.34251 -1.481 0.139 > color5 -4.10122 13.27532 -0.309 0.757 > width 0.10600 0.42656 0.248 0.804 > color3:width 0.31287 0.44794 0.698 0.485 > color4:width 0.75237 0.50435 1.492 0.136 > color5:width 0.09443 0.50042 0.189 0.850 > > (Dispersion parameter for binomial family taken to be 1) > > Null deviance: 225.76 on 172 degrees of freedom > Residual deviance: 183.08 on 165 degrees of freedom > AIC: 199.08 > > Number of Fisher Scoring iterations: 5 > > Note the predictors are mixture of continuous data and categorical > data. Here, I wonder whether there is *significant difference* among > the four interactions of color and width (say, to get a p-value). In a > two-way ANOVA, we may do a F-test. But is there an "equivalent" method > for logit model?-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595