[R] type III Sum Sq in ANOVA table - Howto?

John Fox jfox at mcmaster.ca
Fri Mar 7 03:38:58 CET 2003


Dear Thomas et al.,

At 05:33 PM 3/6/2003 -0800, Thomas Lumley wrote:
>On Fri, 7 Mar 2003, Josef Frank wrote:
>
> > Hello,
> >
> > as far as I see, R reports type I sums of squares. I'd like to get R to
> > print out type III sums of squares.
> >
> > e.g. I have the following model:
> > vardep~factor1*factor2
> >
> > to get the type III sum of squares for factor1 I've tried
> > anova(lm(vardep~factor2+factor1:factor2),lm(vardep~factor1*factor2))
> > but that didn't yield the desired result.
> >
> > Could anyone give me a hint how to proceed?
> >
>
>Unfortunately the arguments about whether Type III sums of squares are
>part of the axis of evil have drowned out a real issue.
>
>I would have expected the command to work, and in fact wrote a FAQ answer
>saying this was the way to do it.  However, if factor1 is indeed a factor
>its main effect is helpfully stuck back in the model by terms.formula.
>
>I think this is a bug, since it doesn't happen if factor1 isn't a factor,
>and leaving aside any question about Type III SS it seems to make it
>impossible to fit the model
>    lm(vardep~factor2+factor1:factor2)
>While this model isn't terribly often useful, it is sometimes.

The description of model formulas in Ch. 2 of Statistical Models in S 
explains why ~factor2+factor1:factor2 is treated as it is.

Assuming that one really wants to test a "Type-III" hypothesis, the Anova 
function in the car package will do it (and "Type-II" tests as well).

Regards,
  John

-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------



More information about the R-help mailing list