# DF in repeated measures anova

I am doing a 2x2 repeated measures in R, within-subjects. I organized the data in long, so I have the same subject in 4 columns, having a score for each level of the 2 factors. I followed a very helpful tutorial: https://datascienceplus.com/two-way-anova-with-repeated-measures/
The issue is the degrees of freedom, I have 20 subjects with 4 observations each, but the df returns 72, as if it is counting each row as a new participant. Also, the analysis is not considering the 2 factors for the df. How do I fix it?

I am unsure how your data are structured. It sounds to me like you are not meeting the condition stated in the tutorial:

"So we see that we have one row per observation per participant."

Can you please show how your data are arranged and the command you use to generate the anova?

2 Likes

Thank you so much. You're absolutely right, I don't have a row per observation per participant. Each participant has several rows. My data is as follows:

sub condition experiment Q1
1 ci A -2
2 ci A 2
3 ci A 2
...
1 cc A -3
2 cc A -3
3 cc A -3
...
1 ci B 0.5
2 ci B 3
3 ci B 3
...
1 ci B 0.5
2 ci B 3
3 ci B 3

And I used this command:

my_data.mean <- aggregate(my_data\$Q1, by = list(my_data\$subject, my_data\$condition, my_data\$experiment), FUN = 'mean')
colnames(my_data.mean) <- c('subject', 'condition', 'experiment', 'Q1')
my_data.mean <- my_data.mean[order(my_data.mean\$subject), ]