问题
Setting aside the debate about Type III ANOVA and the Principle of Marginality and all that...
I've set up two models whose sum of squares should be different (and Type III ANOVA would test that difference). Here's the code:
library(car)
library(openintro)
data(hsb2)
hsb2$gender <- factor(hsb2$gender)
contrasts(hsb2$gender) <- "contr.sum"
contrasts(hsb2$ses) <- "contr.sum"
math_gender_int <- lm(math ~ gender + gender:ses, data = hsb2)
math_gender_ses_int <- lm(math ~ gender + ses + gender:ses, data = hsb2)
Now I should be able to see a difference in the sum of squares between these two models. After all, the "full" model has one more term in it:
anova(math_gender_int, math_gender_ses_int)
But the output shows this:
Analysis of Variance Table
Model 1: math ~ gender + gender:ses
Model 2: math ~ gender + ses + gender:ses
Res.Df RSS Df Sum of Sq F Pr(>F)
1 194 15858
2 194 15858 0 -1.819e-12
What's going on here?
来源:https://stackoverflow.com/questions/43146368/checking-type-iii-anova-results