[R] Tukey.aov with split-plot designs

Prof Brian D Ripley ripley at stats.ox.ac.uk
Sat Jul 8 19:23:46 CEST 2000


On Wed, 5 Jul 2000, Peter B. Mandeville wrote:

> I am using R 1.1 with Redhat 6.2 and RW 1.001 with Win98 (the upkey doesn't
> work on my IBM either as has been previously reported by others).

Yes, and the fix was posted long ago (I've been on two trips since).

> 
> The function aov doesn't return either the residuals or the residual
> degrees of freedom for split-plot designs. 
> 
> If you use the following code from Baron and Li's "Notes on the use of R
> for psycology experiments and questionnaires"
> 
> data <- c(30,14,24,38,26,28,18,20,34,28,16,10,18,20,14,34,22,30,44,30)
> Stv.df <-
> data.frame(rt=data,subj=factor(rep(paste("subj",1:5,sep=""),4)),drug=factor(
> rep(paste("drug",1:4,sep=""),c(5,5,5,5))))
> res0 <- aov(rt~drug,data=Stv.df)
> res1 <- aov(rt~drug+subj,data=Stv.df)
> res2 <- aov(rt~drug+Error(subj/drug),data=Stv.df)
> 
> res0$resid works
> resid(res0) works
> res0$df.residual works
> 
> res1$resid works
> resid(res1) works
> res1$df.residual work
> 
> res2$resid doesn't work and reports NULL
> resid(res2) doesn't work and reports NULL
> res2$df.residual doesn't work and reports NULL
> 
> Is this an undocumented feature or an error?

By design.  What are the residuals for a multistratum design?  In your
example

> res2

Call:
aov(formula = rt ~ drug + Error(subj/drug), data = Stv.df)

Grand Mean: 24.9 

Stratum 1: subj

Terms:
                Residuals
Sum of Squares      680.8
Deg. of Freedom         4

Residual standard error: 13.04607 

Stratum 2: subj:drug

Terms:
                 drug Residuals
Sum of Squares  698.2     112.8
Deg. of Freedom     3        12

Residual standard error: 3.065942 
Estimated effects may be unbalanced

and which of the two sets of residuals did you expect to get?  You can get
either by applying resid to the appropriate stratum, by using the function
proj().  See V&R3 p.198 for an example.


> It sure plays havoc with Dr. Bates' contribution of Tukey.aov which works
> with res0 and res1 but doesn't work with res2 and reports 
> 
> Error in qtukey(p, nranges, nmeans, df, lower.tail, log.p) :
>         Non-numeric argument to mathematical function

Again, what do you actually want here?  Surely you want to treat each
stratum separately, and you can do that via proj().

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list