Hi, I was wondering why anova() and drop1() give different tail probabilities for F tests. I guess overdispersion is calculated differently in the following example, but why? Thanks for any advice, Tom For example: > x<-c(2,3,4,5,6) > y<-c(0,1,0,0,1) > b1<-glm(y~x,binomial) > b2<-glm(y~1,binomial) > drop1(b1,test="F") Single term deletions Model: y ~ x Df Deviance AIC F value Pr(F) <none> 6.3024 10.3024 x 1 6.7301 8.7301 0.2036 0.6824 Warning message: F test assumes quasibinomial family in: drop1.glm(b1, test = "F") > anova(b2,b1,test="F") Analysis of Deviance Table Model 1: y ~ 1 Model 2: y ~ x Resid. Df Resid. Dev Df Deviance F Pr(>F) 1 4 6.7301 2 3 6.3024 1 0.4277 0.4277 0.5131 >
On Thu, 20 Oct 2005, Tom Van Dooren wrote:> Hi, > I was wondering why anova() and drop1() give different tail > probabilities for F tests. > I guess overdispersion is calculated differently in the following > example, but why?Because of the warning. You are using both inappropriately. drop1.glm guesses you meant quasibinomial and tells you. anova.glm guesses you mean the Chisq test (F with infinite denominator df) and does not tell you.> Thanks for any advice, > Tom > > For example: > > > x<-c(2,3,4,5,6) > > y<-c(0,1,0,0,1) > > b1<-glm(y~x,binomial) > > b2<-glm(y~1,binomial) > > drop1(b1,test="F") > Single term deletions > > Model: > y ~ x > Df Deviance AIC F value Pr(F) > <none> 6.3024 10.3024 > x 1 6.7301 8.7301 0.2036 0.6824 > Warning message: > F test assumes quasibinomial family in: drop1.glm(b1, test = "F") > > anova(b2,b1,test="F") > Analysis of Deviance Table > > Model 1: y ~ 1 > Model 2: y ~ x > Resid. Df Resid. Dev Df Deviance F Pr(>F) > 1 4 6.7301 > 2 3 6.3024 1 0.4277 0.4277 0.5131 > > > > ______________________________________________ > R-help at 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 >-- 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
Hi Brian, well I wanted a test based on quasibinomial... Does it work like this then?: x<-gl(3,2) y<-c(0,1,0,0,1,1) # quasibinomial models # ######################## qb1<-glm(y~x,quasibinomial) qb2<-glm(y~1,quasibinomial) qbdev<-(qb2$dev-qb1$dev) qbdev # deviance I qbdev/(qb2$df.res-qb1$df.res)/(qb1$dev /qb1$df.res) # deviance ratio II qbdev/summary(qb1)$disp # scaled deviance III qbdev/(qb2$df.res-qb1$df.res)/summary(qb1)$disp # scaled deviance IV anova(qb2,qb1,test="Chisq") # Chisq test based on I drop1(qb1,test="F") # F test, based on II drop1(qb1,test="Chisq") # Chisq test, based on III anova(qb2,qb1,test="F") # F test, based on IV # binomial models # ################### b1<-glm(y~x,binomial) b2<-glm(y~1,binomial) bdev<-(b2$dev-b1$dev) bdev # deviance I bdev/(b2$df.res-b1$df.res)/(b1$dev /b1$df.res) # deviance ratio II drop1(b1,test="Chisq") # Chisq test, based on I anova(b2,b1,test="Chisq") # Chisq test based on I anova(b2,b1,test="F") # Chisq test, based on I drop1(b1,test="F") # F test, based on II Cheers, Tom PS: thanks Tord ;)
Yes, in essence although it is much easier to describe in words. anova uses the Chisquared-based estimate of dispersion unless it is known. drop1 uses the deviance-based estimate of dispersion unless it is known. If the F tests are going to be approximately valid the dispersion estimators should be pretty similar, and when they are not the first _may_ be closer to chi-square-distributed. However, as I recall it, when I learnt analysis of deviance using GLIM3, the drop1 approach was used. On Thu, 20 Oct 2005, Tom Van Dooren wrote:> Hi Brian, > well I wanted a test based on quasibinomial... > Does it work like this then?: > > x<-gl(3,2) > y<-c(0,1,0,0,1,1) > > # quasibinomial models # > ######################## > > qb1<-glm(y~x,quasibinomial) > qb2<-glm(y~1,quasibinomial) > > qbdev<-(qb2$dev-qb1$dev) > > qbdev # deviance I > > qbdev/(qb2$df.res-qb1$df.res)/(qb1$dev /qb1$df.res) # deviance ratio II > > qbdev/summary(qb1)$disp # scaled deviance III > > qbdev/(qb2$df.res-qb1$df.res)/summary(qb1)$disp # scaled deviance IV > > > anova(qb2,qb1,test="Chisq") # Chisq test based on I > drop1(qb1,test="F") # F test, based on II > drop1(qb1,test="Chisq") # Chisq test, based on III > anova(qb2,qb1,test="F") # F test, based on IV > > # binomial models # > ################### > > b1<-glm(y~x,binomial) > b2<-glm(y~1,binomial) > > bdev<-(b2$dev-b1$dev) > > bdev # deviance I > > bdev/(b2$df.res-b1$df.res)/(b1$dev /b1$df.res) # deviance ratio II > > > drop1(b1,test="Chisq") # Chisq test, based on I > anova(b2,b1,test="Chisq") # Chisq test based on I > anova(b2,b1,test="F") # Chisq test, based on I > drop1(b1,test="F") # F test, based on II > > > Cheers, Tom > > PS: thanks Tord ;) > >-- 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