Theo Pepler

Home | Research | Teaching | Software | Links | HOWTO's

HOWTO: CALCULATE TYPE I, II AND III SUMS OF SQUARES FOR ANOVA IN R

When performing an analysis of variance (ANOVA) for a fitted model, there are different ways to calculate the sums of squares (SS) for the model effects. A good readable explanation of the different types of SS, generally called I, II and III, can be found here.

I would argue to always use type II SS when doing an ANOVA. If you have a model with no interactions, fitted on data from a balanced design, the different types of SS will all lead to the same result. However, if there are interactions fitted in your model, and/or you have an unbalanced design, the SS (and resulting ANOVA tables) will differ. One should start by interpreting any interactions in the model, and only interpret the main effects if there are no significant interactions (between the main effects being interpreted). If the interaction(s) are not significant, type II SS give more powerful tests of the main effects.

To perform ANOVA with type II SS in R:

  1. Load the car library

    require(car)

  2. To perform ANOVA for a fitted model (called myModel, for example)

    Anova(myModel, type = 'II')