[R] Understanding Anova (car) output

Ista Zahn izahn at psych.rochester.edu
Mon Mar 2 00:21:40 CET 2009


Dear professor Fox and R helpers,
I have a quick question about the Anova function in the car package.
When using the default "type II" SS I get results that I don't
understand (see below).

library(car)
Data <- data.frame(y=rnorm(10), x1=factor(c(rep("a",4), rep("b",6))),
x2 = factor(c(rep("j", 2), rep("k", 3), rep("j", 2), rep("k", 3))))
Data$c1 <- recode(Data$x1, '"a"=-1;"b"=1', as.factor.result=FALSE)
Data$c2 <- recode(Data$x2, '"j"=-1;"k"=1', as.factor.result=FALSE)
Data$c3 <- Data$c1*Data$c2

options(contrasts=c("contr.Sum", "contr.poly"))

m1 <- lm(y ~ x1*x2, data=Data)
m2 <- lm(y ~ c1 + c2 + c3, data=Data)

Anova(m1)#Why is this
Anova(m2)#Different from this?

I would greatly appreciate it if someone can help me understand why
the results differ.

Thanks,
Ista




More information about the R-help mailing list