I have a sample dataframe that looks like this:
| DV | IV1 | IV2 | ID |
|---|---|---|---|
| 6 | x | a | 1 |
| 3 | x | a | 2 |
| 4 | x | a | 3 |
| 9 | x | b | 1 |
| 2 | x | b | 2 |
| 4 | x | b | 3 |
| 8 | y | a | 1 |
| 4 | y | a | 2 |
| 3 | y | a | 3 |
| 2 | y | b | 1 |
| 1 | y | b | 2 |
| 5 | y | b | 3 |
| 9 | z | a | 1 |
| 7 | z | a | 2 |
| 8 | z | a | 3 |
| 9 | z | b | 1 |
| 4 | z | b | 2 |
| 3 | z | b | 3 |
I tried to run a repeated measures factorial ANOVA using this code:
model <- aov(DV ~ IV1*IV2 + Error(ID/IV1*IV2), data=my_data)
While the code works, the output is wrong. I suspect it is because R does not recognise there are 3 participants in my data(my degrees of freedom for ID is always 1). Consequently, in the case of this sample data, my error df is 6 instead of 4.
May I know what did I do wrong?