[R] Newbie question about the use of lm and anova

Henric Nilsson henric.nilsson at statisticon.se
Wed Oct 27 15:30:12 CEST 2004


At 12:54 2004-10-26 -0700, Sandie Peters wrote:

>[...]
>Several questions:
>1.  Why do we get a different ANOVA answer when we switch the order of
>the explanatory variables , e.g. ComponentA ~ Parent + Plot vs
>ComponentA ~ Plot + Parent?
>2.  Why are the Sum Sq and F ratios calculated by this ANOVA method
>different than those that are calculated by SAS JMP?

It's in the FAQ:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-does-the-output-from-anova_0028_0029-depend-on-the-order-of-factors-in-the-model_003f

Also, see the `anova.lm' help page for a nice example.

If you want test based on so called Type II and III sums of squares, but 
don't want to compute them yourself (by use of `anova' and `drop1' as the 
FAQ suggests), John Fox's excellent `car' package has got an `Anova' function.

HTH,
Henric




More information about the R-help mailing list