The code is like the following:
> d <- data.frame(a=c(1,1,1,1,2,2,2,2), b=c(1,1,2,2,1,1,2,2),v=1:8)
> anova(lm(v~a*b, data=d))
Analysis of Variance Table
Response: v
Df Sum Sq Mean Sq F value Pr(>F)
a 1 32 32.0 64 0.001324 **
b 1 8 8.0 16 0.016130 *
a:b 1 0 0.0 0 1.000000
Residuals 4 2 0.5
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> anova(lm(v~a, data=d))
Analysis of Variance Table
Response: v
Df Sum Sq Mean Sq F value Pr(>F)
a 1 32 32.000 19.2 0.004659 **
Residuals 6 10 1.667
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
My question is why "a" has different value of F and Pr between lm(v~ab) and lm(v~a)? As far as I think anova(v~ab) will test avona(v~a), anova(v~b) and anova for a and b together.