I have a dataset with a 2x2x2 design: Group (CTL vs. SC) x Session (Sess 1 vs. Sess 2) x Treatment (Treat vs. Placebo). The dependent variable is Response Time. I also have a variable Age. I would like to do an ANCOVA using Age as a covariate. To visualize data:
input <- mydata[,c("Group","Treatment","Session","ResponseTime","Age")]
print(head(input))
Group Treatment Session ResponseTime Age
<chr> <chr> <chr> <dbl> <dbl>
1 CTL Placebo Sess1 0.0126 53
2 CTL Placebo Sess1 0.0480 30
3 CTL Placebo Sess1 0.0318 58
4 CTL Placebo Sess1 0.747 28
5 CTL Placebo Sess2 0.150 28
6 CTL Placebo Sess2 0.0149 41
...
Using example from this, I did the following:
options(contrasts = c("contr.treatment", "contr.poly"))
model.1 = lm (Value ~ Group*Session*Treatment + Age + Group:Session:Treatment,
data = mydata)
library(car)
Anova(model.1, type="II")
I'm unclear whether I placed Group where it belongs as it is a between- not within-subject variable. I think Age is used correctly as a covariate here but could someone take a quick look at let me know whether this is correct?