Type III Sums of Squares and ANOVA Parametrization

Statistics
R
A discussion on the implications of using Type III sums of squares in ANOVA and the importance of choosing the correct parametrization.
Author

Marina Varfolomeeva

Published

January 5, 2019

Choosing between different parametrizations in Analysis of Variance (ANOVA) often feels like a rather confusing task.

Types of Sums of Squares

Suppose we have a model Y ~ A + B + AB featuring two discrete factors and their interaction. “Types” of sums of squares (SS) are simply different sequences for testing the significance of factors within this model. The most commonly used are Types I, II, and III. Regardless of the type chosen, the significance of the interaction is always tested the same way - relative to a model containing both factors but no interaction, i.e., \(SS(AB | A, B)\). However, the significance of the main factors can be tested in different order.

  • SS Type I: Significance is tested sequentially—in the order factors are entered into the model. First, \(SS(A)\) is calculated, then \(SS(B | A)\), and finally \(SS(AB | A, B)\).
  • SS Type II: Significance is tested by comparing the model against one that includes the other factor but lacks the interaction—specifically \(SS(A | B)\) and \(SS(B | A)\). With this method, the SS does not depend on the order of factors, but it is sensitive to group sizes. It is best used when groups are balanced (equal sizes).
  • SS Type III: Significance is tested by comparing the model against one that includes both the other factor and the interaction: \(SS(A | B, AB)\) and \(SS(B | A, AB)\). Statisticians often criticize this approach because it violates the principle of marginality (an interaction should only be in the model if its constituent main effects are also present). However, because these SS do not depend on group sizes, they are frequently recommended for unbalanced data.

Types of Parametrization

In the classical regression approach, dummy coding (indicator variables) is most common. Here, coefficients represent the deviation of group means from the mean of a baseline level (in R, this is the default: contr.treatment).

In classical ANOVA, effect coding is used. Here, coefficients represent the deviation of group means from the grand mean (in R, this is contr.sum).

How is Parametrization Linked to SS Type?

In the vast majority of cases, both coding schemes will yield identical ANOVA results. However, the moment you decide to use SS Type III (perhaps remembering that it is the default in many other statistical packages), choosing contr.sum becomes critical.

When using contr.treatment, the coefficients do not correspond to the classical definition of “main effects” (the effect of a factor averaged across all levels of other factors). This is explained thoroughly and clearly in this technical report.

Under contr.treatment, coefficients actually represent “simple effects” (the effect of a factor at a specific level of another factor, rather than an average). As shown on page 14 of the linked report, a coefficient representing a simple effect simultaneously captures part of the interaction. This leads to two important consequences:

  1. Collinearity: If an interaction is present, contr.treatment automatically introduces collinearity. Therefore, when checking a full model for collinearity, you should use contr.sum (or use the trick of checking a reduced model without the interaction).
  2. Incorrect SS: Because contr.treatment coefficients partially encode the interaction, using them with SS Type III results in incorrect sums of squares. For example, when calculating \(SS(A | B, AB)\), we evaluate the effect of \(A\) by comparing models A + B + AB and B + AB. By dropping factor \(A\), we aren’t just removing the main effect; we are also removing part of the interaction (in reality, it is even more complex than that).

How to Choose the Right SS Type and Parametrization?

  • If your model has no interaction, you don’t need SS Type III; it serves no purpose here.
  • If you have an interaction and balanced data (or the imbalance is negligible), you can safely use SS Type II. In this case, the choice of parametrization doesn’t change the ANOVA results - just remember how to interpret the coefficients and use a model with no interaction to check for collinearity.
  • If you have an interaction and unbalanced data, you may use SS Type III, but you must use the contr.sum parametrization.