before my actual ANCOVA I would like to test whether there is a significant interaction between the IV and the CV as this is one assumption for ANCOVA. I found 3 different ways in R to perform an ANCOVA. However, the result for one solution differs from the other two and I do not understand why. Here is my working code snippet:
library(lattice)
data <- data.frame(group = c(rep("CTRL", 10), rep("P", 10)),
response = c(10,11,14,16,17,17,19,20,21,22, 10,11,11,11,12,13,14,14,15,16),
age = c(40,41,45,43,50,51,55,57,60,62, 30,32,34,35,40,41,42,44,43,46))
xyplot(response ~ age, data=data, groups=group, type=c("p","r"))
# 1. ANCOVA
anova(lm(response ~ group + age + group : age, data = data))
# 2. ANCOVA
summary(aov(response ~ group + age + group : age, data = data))
# 3. ANCOVA
summary(lm(response ~ group + age + group : age, data = data))
I don't understand why the two p-values for group and age are identical for ANCOVA 1. and 2. but different for 3. even though the interaction p-value (group : age) is the same for all three. Doing the same thing in SPSS results in exactly the same p-values as ANCOVA 3.
Now, as you can imagine, I am pretty unsure what's right and what's wrong or what's actually the difference between them? Can anyone help?