[R] repeated measures aov problem

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Dec 17 11:29:13 CET 2003


You have an NA in your data, it says.  That makes the design unbalanced 
(it it is not already unbalanced by having 50 obs with a 2x2 
classification: I can't see the pattern from your extract but guess 25 
subjects don't divide into two equal groups).

That you get the same effects in both strata is the classic symptom of
lack of balance.  I think you need to use lme to analyse these data, and
to be rather careful how you interpet the result.

On Wed, 17 Dec 2003, Nathan Weisz wrote:

> Hi all,
> 
> I have a strange problem and rigth now I can't figure out a 
> solution.
> 
> Trying to calculate an ANOVA with one between subject factor (group) 
> and one within (hemisphere). My dependent variable is source 
> localization (data). My N = 25.
> 
> My data.frame looks like this:
> > ML.dist.stack
>    subj group hemisphere      data
> 1     1   tin       left 0.7460840
> 2     2   tin       left 1.0300600
> 3     3   tin       left 0.8026865
> <<SNIP>>
> 47   22   con      rigth 0.6808010
> 48   23   con      rigth 1.2291490
> 49   24   con      rigth 2.0930595
> 50   25   con      rigth 1.5631695
> 
> > str(ML.dist.stack)
> `data.frame':	50 obs. of  4 variables:
>  $ subj      : Factor w/ 25 levels "1","2","3","4",..: 1 2 3 4 5 6 7 
> 8 9 10 ...
>  $ group     : Factor w/ 2 levels "con","tin": 2 2 2 2 2 2 2 2 2 2 
> ...
>  $ hemisphere: Factor w/ 2 levels "left","rigth": 
> 1 1 1 1 1 1 1 1 1 1 ...
>  $ data      : num  0.746 1.030 0.803 2.197    NA ...
> 
> Typing: summary(aov(data ~group * hemisphere + Error(subj/
> hemisphere), data=ML.dist.stack))
> gives me following result ...
> Error: subj
>                  Df  Sum Sq Mean Sq F value Pr(>F)
> group             1  0.1813  0.1813  0.2012 0.6584
> hemisphere        1  0.1937  0.1937  0.2149 0.6477
> group:hemisphere  1  0.0898  0.0898  0.0996 0.7554
> Residuals        21 18.9277  0.9013               
> 
> Error: subj:hemisphere
>                  Df  Sum Sq Mean Sq F value Pr(>F)
> hemisphere        1  1.0534  1.0534  1.6736 0.2105
> group:hemisphere  1  0.5714  0.5714  0.9077 0.3521
> Residuals        20 12.5893  0.6295               
> ... which looks like the error strata are wrong.
> 
> I kept very close (in my opinion exactly) to Baron's Example 4 of 
> the tutorial (p. 29), which produces correct results. See below:
> > str(Ela.uni)
> `data.frame':	96 obs. of  5 variables:
>  $ effect: num  19 11 20 21 18 17 20 14 16 26 ...
>  $ subj  : Factor w/ 16 levels "s1","s10","s11",..: 
> 1 9 10 11 12 13 14 15 16 2 ...
>  $ gp    : Factor w/ 2 levels "gp1","gp2": 1 1 1 1 1 1 1 1 2 2 ...
>  $ drug  : Factor w/ 2 levels "dr1","dr2": 1 1 1 1 1 1 1 1 1 1 ...
>  $ dose  : Factor w/ 3 levels "do1","do2","do3": 1 1 1 1 1 1 1 1 1 1 
> ...
> > summary(aov(effect ~ gp * drug * dose + Error(subj/(dose+drug)), 
> data=Ela.uni))
> 
> Error: subj
>           Df Sum Sq Mean Sq F value  Pr(>F)  
> gp         1 270.01  270.01  7.0925 0.01855 *
> Residuals 14 532.98   38.07                  
> ---
> Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 
> 
> Error: subj:dose
>           Df Sum Sq Mean Sq F value    Pr(>F)    
> dose       2 758.77  379.39 36.5097 1.580e-08 ***
> gp:dose    2  42.27   21.14  2.0339    0.1497    
> Residuals 28 290.96   10.39                      
> ---
> Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 
> 
> Error: subj:drug
>           Df Sum Sq Mean Sq F value   Pr(>F)   
> drug       1 348.84  348.84  13.001 0.002866 **
> gp:drug    1 326.34  326.34  12.163 0.003624 **
> Residuals 14 375.65   26.83                    
> ---
> Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 
> 
> Error: Within
>              Df  Sum Sq Mean Sq F value Pr(>F)
> drug:dose     2  12.063   6.031  0.6815 0.5140
> gp:drug:dose  2  14.812   7.406  0.8369 0.4436
> Residuals    28 247.792   8.850               
> 
> Can someone give me a hint where I migth be going wrong? However 
> trivial this migth be I somehow got stuck.
> 
> All the best,
> Nathan
> 
> -----------------------------------------
> Nathan Weisz
> Department of Psychology
> University of Konstanz
> P.O. Box D25
> D - 78457 Konstanz
> GERMANY
> 
> Tel: +49 (0)7531 88- 4612
> E-mail: Nathan.Weisz at uni-konstanz.de
> http://www.clinical-psychology.uni-konstanz.de
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 
> 

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list