# Two way ANOVA, no difference between tests based on type I vs type II sums of squares

I'm learning about two way ANOVA possibly with interaction. I'm following this tutorial http://www.sthda.com/english/wiki/two-way-anova-test-in-r

This is their code.

my_data <- ToothGrowth
my_data$$dose <- factor(my_data$$dose,
levels = c(0.5, 1, 2),
labels = c("D0.5", "D1", "D2"))

res.aov2 <- aov(len ~ supp + dose, data = my_data)
summary(res.aov2)

res.aov3 <- aov(len ~ supp + dose + supp:dose, data = my_data)
summary(res.aov3)


Their results show there is a significant interaction between the 2 categorical variables using what I understand as Type I ANOVA.

And I have 2 questions:

1. As type I ANOVA is supposed to be sequential, why do I get exactly the same results? That is,

>res.aov3 <- aov(len ~ supp + dose + supp:dose, data = my_data)
> summary(res.aov3)

Df Sum Sq Mean Sq F value   Pr(>F)
supp         1  205.4   205.4  15.572 0.000231 ***
dose         2 2426.4  1213.2  92.000  < 2e-16 ***
supp:dose    2  108.3    54.2   4.107 0.021860 *
Residuals   54  712.1    13.2
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

> res.aov4 <- aov(len ~ dose + supp + supp:dose, data = my_data)
> summary(res.aov4)
Df Sum Sq Mean Sq F value   Pr(>F)
dose         2 2426.4  1213.2  92.000  < 2e-16 ***
supp         1  205.4   205.4  15.572 0.000231 ***
dose:supp    2  108.3    54.2   4.107 0.021860 *
Residuals   54  712.1    13.2
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

2. When I compare the 3 types of ANOVAs, why the results for type I and II are the same?

library(car)
> anova(res.aov3)  # type I
Analysis of Variance Table

Response: len
Df  Sum Sq Mean Sq F value    Pr(>F)
supp       1  205.35  205.35  15.572 0.0002312 ***
dose       2 2426.43 1213.22  92.000 < 2.2e-16 ***
supp:dose  2  108.32   54.16   4.107 0.0218603 *
Residuals 54  712.11   13.19
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

> Anova(res.aov3, type=2)  # type II
Anova Table (Type II tests)

Response: len
Sum Sq Df F value    Pr(>F)
supp       205.35  1  15.572 0.0002312 ***
dose      2426.43  2  92.000 < 2.2e-16 ***
supp:dose  108.32  2   4.107 0.0218603 *
Residuals  712.11 54
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

> Anova(res.aov3, type=3)   # type III
Anova Table (Type III tests)

Response: len
Sum Sq Df F value    Pr(>F)
(Intercept) 1750.33  1 132.730 3.603e-16 ***
supp         137.81  1  10.450  0.002092 **
dose         885.26  2  33.565 3.363e-10 ***
supp:dose    108.32  2   4.107  0.021860 *
Residuals    712.11 54
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

• Welcome to the site, please consider registering your account (you can find information on how to do this in the My Account section of our help center). Dec 21 '18 at 4:22

The type I, II, III (etc.) sums of squares distinction has to do with how the total sums of squares are partitioned. When your variables are not orthogonal, there is no single unique partition, but there are many ways to divvy up the sums of squares between the different variables. (It may help to read my answer here: How to interpret type I, type II, and type III ANOVA and MANOVA?) The issue with applying this to the ToothGrowth dataset is that the variables in that study were orthogonal, so the distinction does not come into play:
with(ToothGrowth, table(dose, supp))