[R] deviance in GLM vs. summary.glm

array chip arrayprofile at yahoo.com
Wed May 31 06:53:25 CEST 2017


Hi, I am running a logistic regression on a simple dataset (attached) using glm:
> dat<-read.table("dat.txt",sep='\t',header=T)
If I use summary() on a logistic model:
> summary(glm(y~x1*x2,dat,family='binomial'))
Coefficients:            Estimate Std. Error z value Pr(>|z|)(Intercept)    19.57    5377.01   0.004    0.997x1            -18.59    5377.01  -0.003    0.997x2B           -19.57    5377.01  -0.004    0.997x1:x2B         38.15    7604.24   0.005    0.996
As you can see, the interaction term is very insignificant (p = 0.996)!
But if I use a anova() to compare a full vs reduced model to evaluate the interaction term:
> anova(glm(y~x1+x2,dat,family='binomial'), glm(y~x1*x2,dat,family='binomial'))Analysis of Deviance Table
Model 1: y ~ x1 + x2Model 2: y ~ x1 * x2  Resid. Df Resid. Dev Df Deviance1        22     27.067            2        21     21.209  1   5.8579
This follows a chi-square distribution with 1 df, so the corresponding p value is:
> 1-pchisq(5.8679,1)[1] 0.01541944
So I get very different p value on the interaction term, can someone share what's going wrong here?
Thanks!
Yi

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dat.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20170531/7d302080/attachment.txt>


More information about the R-help mailing list