[R] Nested anovas in R not doing what they ought to...

Michael Rennie mike.rennie at ene.gov.on.ca
Thu Jul 11 17:07:34 CEST 2002


Hi, there

I first sent this e-mail a couple months ago, to no avail.Since I am not a member on your mailing list, so could you please cc: a response to me? I'll be sure to check the list today for replies.

I am currently attempting to perform an ANOVA with both nested and normal factors.  My problem is that R is treating my nested factors the exact same way as it would interaction terms.  

My output for the nested model is as follows:

> nested <- anova(lm(ltotinv ~ habitat + fish/lake + habitat:fish + habitat:(la\
ke %in% fish)))
> nested
Analysis of Variance Table
 
Response: ltotinv
                  Df  Sum Sq Mean Sq F value    Pr(>F)
habitat            1 17.0829 17.0829 50.0917 3.083e-09 ***
fish               1  0.9131  0.9131  2.6774  0.107600
habitat:fish       1 13.0100 13.0100 38.1488 8.877e-08 ***
fish:lake          1  1.0256  1.0256  3.0072  0.088599 .
habitat:fish:lake  1  2.7641  2.7641  8.1051  0.006229 **
Residuals         54 18.4158  0.3410
---lysis of Variance Table
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

With just interactions, not nested:

> test <- anova(lm(ltotinv ~ habitat + fish + lake:fish + habitat:fish + fish:h\
abitat:lake))
> test
Analysis of Variance Table
 
Response: ltotinv
                  Df  Sum Sq Mean Sq F value    Pr(>F)
habitat            1 17.0829 17.0829 50.0917 3.083e-09 ***
fish               1  0.9131  0.9131  2.6774  0.107600
habitat:fish       1 13.0100 13.0100 38.1488 8.877e-08 ***
fish:lake          1  1.0256  1.0256  3.0072  0.088599 .
habitat:fish:lake  1  2.7641  2.7641  8.1051  0.006229 **
Residuals         54 18.4158  0.3410
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
>


We get the same answer.  The reason I figured this out is because I did this analysis first in SAS, and then tried to reproduce it in R.  It must be something to do with my syntax, I imagine, but I can't see what it is.

Any help anyone has would be greatly appreciated.


Sincerely, 

Mike Rennie
M.Sc. Candidate, University of Toronto at Mississauga 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list