[R] test for factor effect with nested glm

Marie-Agnes Coutellec marie-agnes.coutellec at rennes.inra.fr
Thu Dec 20 16:52:19 CET 2007


Dear all,

I use a nested design with lm and glm, with factor2 nested within 
factor1. In order to test for the significance of both factors, I use 
anova tables on the obtained models such as follows:

/> mod1<-lm(A~factor1/factor2)
 > amod1<-anova(mod1, test="F")
Analysis of Variance Table
Response: A
                   Df Sum Sq Mean Sq F value    Pr(>F)   
factor1            15  85.99    5.73  3.1332 8.702e-05 ***
factor1:factor2    42 131.75    3.14  1.7145  0.005654 **
Residuals         308 563.52    1.83                      /

and recalculate the Fvalue for factor1 as follows:

/> ffactor1<-(85.99/15)/(131.75/42)
 > fpop
[1] 1.827491
 > 1-pf(ffactor1,15,42)
[1] 0.06285258/

My question is: am I allowed to do the same with an Analysis of Deviance 
table, calculated on a glm model, as done hereafter:

/> mod2<-glm(M~factor1/factor2, family=Gamma(link=identity))
 > amod2<-anova(mod2,test="F")
 > amod2
Analysis of Deviance Table
Model: Gamma, link: identity
Response: M
Terms added sequentially (first to last)

                 Df Deviance Resid. Df Resid. Dev      F    Pr(>F)   
NULL                               365    164.486                    
factor1          15   18.699       350    145.787 3.4365 1.997e-05 ***
factor1:factor2  42   38.973       308    106.814 2.5579 2.319e-06 ***
---

 > ffactor1<-(18.699/15)/(38.973/42)
[1] 1.343422
 > 1-pf(ffactor1,15,42)/
[1] 0.2206373


Thanks in advance for your answer, and sorry if my question doesn't fit 
with the R-help list.

Agnès Coutellec

-- 

Marie-Agnès Coutellec
UMR INRA-Agrocampus 985 EQHC
Equipe Ecotoxicologie et Qualité des Milieux Aquatiques
65 rue de Saint-Brieuc - CS 84215
35042 Rennes cedex - FRANCE

tél.: +33(0)2 23 48 52 48
fax:  +33(0)2 23 48 54 40



More information about the R-help mailing list