[R] possible bug in aov?

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Mar 2 22:26:32 CET 2004


Two errors of yours are apparent in your example:

1) df is a function, and sample.df is not used in your code.  I presume 
you actually used data=sample.df.

2) factor2 does not vary within subject so your model makes no sense.

It is the second that leads, correctly, to an error message (if an arcane 
one).

On Tue, 2 Mar 2004, Arditi, Aries wrote:

> Hi, I'm interested in doing a repeated measures anova using aov.  The procedure is nicely described in section 6.7.1, pp. 24-27 of Baron and Li's "Notes on the use of R for psychology experiments and
> questionnaires," and I've reproduced their example exactly.
> 
> My own problem is almost identical to theirs:
> 
> rawdat<-c(1.6530074e+001, 1.2124254e+001, 1.0040371e+001, 1.5317610e+001, 1.2332377e+001,
> 1.0102947e+001, 1.7087520e+001, 1.1692890e+001, 1.1809286e+001, 1.4748297e+001, 1.0717683e+001,
> 8.7908203e+000, 1.3140706e+001, 9.7947745e+000, 8.3588329e+000, 1.5623756e+001, 9.6382132e+000,
> 8.7209537e+000, 1.5321620e+001, 1.1347325e+001,  8.5177789e+000,  1.3271254e+001,  9.7376040e+000,
> 8.7803153e+000  , 1.3155236e+001, 1.0157526e+001, 8.4003486e+000, 1.3083896e+001, 9.6644615e+000,
> 8.1586026e+000, 1.2167609e+001 , 9.1319943e+000, 7.4251013e+000, 1.3284386e+001, 9.1596335e+000,
> 7.9175876e+000,  1.1876537e+002,  7.8831935e+001,  6.2203784e+001,  1.0729023e+002,  7.3790904e+001, 5.8588328e+001,  1.1890329e+002,  6.6345430e+001,  5.3117505e+001,  3.7261647e+002, 2.4538572e+002,  2.2372152e+002,  3.2602801e+002,  2.3267124e+002,  2.0944016e+002,  2.9755054e+002,  2.3970708e+002,  2.2379642e+002)

Where did those e+001 etc come from?  Not from R, AFAIK.

> sample.df <- data.frame(dep.variable=rawdat,
> subject=factor(rep(paste("subj",1:6, sep=""),each=9)),
> factor1=factor(rep(rep(c("fac1level1","fac1level2","fac1level3"),each=6),3)),
> factor2=factor(rep(c("fac2level1","fac2level2","fac2level3"),each=18))
> )
> sample.aov <- aov(dep.variable ~ factor1 * factor2 + Error(subject/(factor1+factor2)), data=df)
> 
> But the aov function returns an error:
> 
> Error in "names<-.default"(`*tmp*`, value = nmstrata) :
>         names attribute must be the same length as the vector
> 
> I am using R1.8.1.
> 
> Any help or insight on a workaround would be appreciated.

-- 
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