I am trying to conduct a repeated measures ANOVA on the following data:
id pre-treatment post-treatment
1 212 208
2 192 189
3 167 168
4 151 151
5 135 128
6 105 118
7 88 88
8 67 71
9 55 50
10 27 30
An online repeated measures anova calculator tells me that the p-value of the above repeated measures anova is: 0.914259
. I agree that this is correct.
But when I try this in R, I use the following syntax:
model <- aov( post-treatment ~ pre-treatment + Error(id), data = df.anova )
print(summary(model))
And I get the following output:
Error: id
Df Sum Sq Mean Sq
pre 1 1448 1448
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
pre 1 702527 702527 26248 <2e-16 ***
Residuals 217 5808 27
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
But p < 2e-16
is a lot different from p = 0.914259
What gives? I'm sure something is wrong with my syntax about how I'm running the ANOVA with the aov
function. There are many tutorials online about how to do repeated measures ANOVA in R. But most of them either
- spend 15 pages explaining ANOVA and repeated-measures ANOVA like I've never heard of ANOVA
or they
- have a 7 or 8 page example using the
mtcars
dataset that leave me unable to see the forest for the trees.
Can anyone advise me on how to do repeated measures ANOVA in R?