[R] Within Subject ANOVA question

tsunhin wong thjwong at gmail.com
Tue Jun 2 00:31:40 CEST 2009


Dear R users,

I have copied for following table from an article on "Using confidence
intervals in within-subject designs":

Subject 1sec 2sec 5sec
1 10 13 13 12.00
2 6 8 8 7.33
3 11 14 14 13.00
4 22 23 25 23.33
5 16 18 20 18.00
6 15 17 17 16.33
7 1 1 4 2.00
8 12 15 17 14.67
9 9 12 12 11.00
10 8 9 12 9.67

I rearranged the data this way:
>subject<-factor(c(1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10))
>condition<-factor(c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,5,5,5,5,5,5,5,5,5,5))
>recall<-factor(c(10,6,11,22,16,15,1,12,9,8,13,8,14,23,18,17,1,15,12,9,13,8,14,25,20,17,4,17,12,12))
>example<-cbind(subject,condition,recall)

Using ANOVA (aov), I should have DF for condition = 2, DF of subjects
= 9, Interaction DF = 18
And a term for mean square of interaction. (0.61)

But, I have something like below instead:
>aov.recall <- aov(recall~condition + Error(subject/condition),data=as.data.frame(example))
>summary(aov.recall)

Error: subject
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  1 12.898  12.898

Error: subject:condition
          Df Sum Sq Mean Sq
condition  1 34.505  34.505

Error: Within
          Df Sum Sq Mean Sq F value Pr(>F)
condition  1   3.22    3.22  0.1378 0.7135
Residuals 26 607.54   23.37

The within-subject (repeated measure) anova of R seems to be a bit
subtle for me, please point out the errors that I have made if you
can.
Thank you very much!

- John




More information about the R-help mailing list