[R] help: unbalanced repeated measures

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sun Nov 30 11:23:42 CET 2008


Sumitrajit Dhar wrote:
> Hi folks,
> 
> I am trying to figure out how run a repeated measures ANOVA on the  
> following data set.
> 
>     subject trial frequency dplvl
> 1  FSI052A     A         1    NA
> 2  FSI052B     B         1    NA
> 3  FSI053A     A         1    NA
..
> 
> 
> Both "frequency" and "trial" are factorized.
> 
>  > is.factor(trial)
> [1] TRUE
>  > is.factor(frequency)
> [1] TRUE
>  > levels(frequency)
> [1] "1" "2" "3" "4" "6"
> 
> I know that I should be using 'lme' rather than aov, but....
> 
>  > summary(aov(dplvl~trial*frequency+Error(subject/ 
> (trial*frequency)),data=tenB))
> 
> Error: subject
>                  Df Sum Sq Mean Sq F value Pr(>F)
> trial            1   7.15    7.15  0.2566 0.6203
> frequency        1  40.84   40.84  1.4657 0.2461
> trial:frequency  1   0.03    0.03  0.0013 0.9723
> Residuals       14 390.11   27.86
> 
> Error: subject:frequency
>                  Df  Sum Sq Mean Sq F value   Pr(>F)
> frequency        1 183.893 183.893  11.925 0.003271 **
> trial:frequency  1  16.393  16.393   1.063 0.317866
> Residuals       16 246.738  15.421
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> 
> Error: Within
>            Df Sum Sq Mean Sq F value Pr(>F)
> Residuals 35 269.13    7.69
> 
> What I do not understand is why I am getting df=1 for frequency when  
> there are 5 levels of that factor.

Is tenB$frequency also a factor? The prototypical error would be to have 
modified only a copy of it.

By the way, with that amount of NA in the response, you are not going to 
undertand aov output in any case...

(and what happened with the subject:trial stratum???)

-- 
    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list