[Rd] anova.glm (PR#7624)

yuedong at pstat.ucsb.edu yuedong at pstat.ucsb.edu
Wed Feb 2 04:31:48 CET 2005


There may be a bug in the anova.glm function.

deathstar[32] R

R : Copyright 2004, The R Foundation for Statistical Computing
Version 2.0.1  (2004-11-15), ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for a HTML browser interface to help.
Type 'q()' to quit R.

> counts <- c(18,17,15,20,10,20,25,13,12)
> outcome <- gl(3,1,9)
> treatment <- gl(3,3)
> glm.D93 <- glm(counts ~ outcome + treatment, family=poisson())
> anova(glm.D93,test="Chisq")
Analysis of Deviance Table

Model: poisson, link: log

Response: counts

Terms added sequentially (first to last)


           Df Deviance Resid. Df Resid. Dev P(>|Chi|)
NULL                          8    10.5814
outcome    2   5.4523         6     5.1291    0.0655
treatment  2   0.0000         4     5.1291    1.0000

> anova(glm.D93,test="F")
Analysis of Deviance Table

Model: poisson, link: log

Response: counts

Terms added sequentially (first to last)


           Df Deviance Resid. Df Resid. Dev      F  Pr(>F)
NULL                          8    10.5814
outcome    2   5.4523         6     5.1291 2.7262 0.06547 .
treatment  2   0.0000         4     5.1291 0.0000 1.00000
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1



----------------------------------------------------------------------
The F test should use the estimated dispersion parameter, so should be 
different from the Chisq test. The following is what I got from Splus:

deathstar[31] Splus
S-PLUS : Copyright (c) 1988, 2000 MathSoft, Inc.
S : Copyright Lucent Technologies, Inc.
Version 6.0 Release 1 for Linux 2.2.12 : 2000
Working data will be in /data/home/faculty/yuedong/MySwork
> counts <- c(18,17,15,20,10,20,25,13,12)
> outcome <- factor(rep(1:3,3))
> treatment <- factor(rep(1:3,c(3,3,3)))
> glm.D93 <- glm(counts ~ outcome + treatment, family=poisson())
> anova(glm.D93, test="Chisq")
Analysis of Deviance Table

Poisson model

Response: counts

Terms added sequentially (first to last)
           Df  Deviance Resid. Df Resid. Dev   Pr(Chi)
      NULL                      8   10.58145
   outcome  2  5.452305         6    5.12914 0.0654707
treatment  2  0.000000         4    5.12914 1.0000000
> anova(glm.D93, test="F")
Analysis of Deviance Table

Poisson model

Response: counts

Terms added sequentially (first to last)
           Df  Deviance Resid. Df Resid. Dev  F Value     Pr(F)
      NULL                      8   10.58145
   outcome  2  5.452305         6    5.12914 2.108359 0.2369863
treatment  2  0.000000         4    5.12914 0.000000 1.0000000


--------------------------------------------------------------------
Yuedong Wang                                  Phone:  (805) 893-4870
Dept of Statistics & Applied Probability        Fax:  (805) 893-2334
Univ of California                            yuedong at pstat.ucsb.edu
Santa Barbara, CA 93106    http://www.pstat.ucsb.edu/faculty/yuedong



More information about the R-devel mailing list