R: Discrepancy between R and SPSS in two-way repeated measures designs

From MathWiki

There are 20 distinct individuals, right? expno breaks the 20
individuals into five groups of 4, right? Is this a blocking factor?

If expno is treated as a blocking factor, the following is what you get:

 > xy <- expand.grid(expno=letters[1:5],cond=letters[1:4],
+                                    time=factor(paste(1:2)))
 > xy$subj <- factor(paste(xy$expno, xy$cond, sep=":"))
 > xy$cond <- factor(xy$cond)
 > xy$expno <- factor(xy$expno)
 > xy$y <- rnorm(40)
 > summary(aov(y~cond*time+Error(expno/cond), data=xy))

Error: expno
           Df Sum Sq Mean Sq F value Pr(>F)
Residuals  4   3.59    0.90

Error: expno:cond
           Df Sum Sq Mean Sq F value Pr(>F)
cond       3   1.06    0.35    0.36   0.78
Residuals 12  11.86    0.99

Error: Within
           Df Sum Sq Mean Sq F value Pr(>F)
time       1   2.27    2.27    1.38   0.26
cond:time  3   3.27    1.09    0.67   0.59
Residuals 16  26.19    1.64


If on the other hand this is analyzed as for a complete
randomized design, the following is the output:

 > summary(aov(y~cond*time+Error(subj), data=xy))

Error: subj
           Df Sum Sq Mean Sq F value Pr(>F)
cond       3   1.06    0.35    0.37   0.78
Residuals 16  15.46    0.97

Error: Within
           Df Sum Sq Mean Sq F value Pr(>F)
time       1   2.27    2.27    1.38   0.26
cond:time  3   3.27    1.09    0.67   0.59
Residuals 16  26.19    1.64



On 10 Sep 2005, at 8:00 PM, Larry A Sonna wrote:


>> From: "Larry A Sonna" <larry_sonna@hotmail.com>
>> Date: 10 September 2005 12:10:06 AM
>> To: <r-help@stat.math.ethz.ch>
>> Subject: [R] Discrepancy between R and SPSS in 2-way, repeated  
>> measures ANOVA
>>
>>
>> Dear R community,
>>
>> I am trying to resolve a discrepancy between the way SPSS and R  
>> handle 2-way, repeated measures ANOVA.
>>
>> An experiment was performed in which samples were drawn before and  
>> after treatment of four groups of subjects (control and disease  
>> states 1, 2 and 3).  Each group contained five subjects.  An  
>> experimental measurement was performed on each sample to yield a  
>> "signal".  The before and after treatment signals for each subject  
>> were treated as repeated measures.  We desire to obtain P values  
>> for disease state ("CONDITION"), and the interaction between signal  
>> over time and disease state ("CONDITION*TIME").
>>
>> Using SPSS, the following output was obtained:
>>                      DF        SumSq (Type 3)    Mean Sq    F  
>> value     P=
>>
>> COND              3                 42861            14287        
>> 3.645 0.0355
>>
>> TIME                1                     473                
>> 473       0.175 0.681
>>
>> COND*TIME     3                     975               325        
>> 0.120 0.947
>>
>> Error                16                43219             2701
>>
>>
>>
>> By contrast, using the following R command:
>>
>> summary(aov(SIGNAL~(COND+TIME+COND*TIME)+Error(EXPNO/COND),  
>> Type="III"))
>>
>> the output was as follows:
>>
>>                  Df     Sum Sq     Mean Sq     F value  Pr(>F)
>>
>> COND          3          26516       8839      3.2517     0.03651 *
>>
>> TIME            1            473         473      0.1739     0.67986
>>
>> COND:TIME  3            975         325      0.1195     0.94785
>>
>> Residuals     28        76107      2718
>>
>>
>>
>> I don't understand why the two results are discrepant.  In  
>> particular, I'm not sure why R is yielding 28 DF for the residuals  
>> whereas SPSS only yields 16.  Can anyone help?
>>
>>


John Maindonald             email: john.maindonald@anu.edu.au
phone : +61 2 (6125)3473    fax  : +61 2(6125)5549
Centre for Bioinformation Science, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.

______________________________________________