[R] Trouble with aovlist and Tukey test

Jonathan Dushoff dushoff at eno.princeton.edu
Tue Nov 15 00:08:16 CET 2005


I am having what I think is a strange problem with applying TukeyHSD to
an aov fit with error strata.

TukeyHSD is supposed to take "A fitted model object, usually an 'aov'
fit."  aov (with error strata) is supposed to generate an object of type
aovlist, which is a list of objects of type aov.  But I can't seem to
feed components of my aovlist to TukeyHSD.  I guess I wouldn't expect to
be able to use the error strata, but I did expect to be able to use the
final stratum.

I have posted a complete example, which I hope explains why I am
confused, below.  Any help will be appreciated.

Jonathan Dushoff

----------------------------------------------------------------------


> morley$Expt = factor(morley$Expt)
> morley$Run = factor(morley$Run)
>
> mod =  aov(Speed~Expt+Run, data=morley)
> class(mod)
[1] "aov" "lm"
>
> TukeyHSD(mod)$Expt
      diff        lwr        upr
2-1 -53.0 -117.91627  11.916268
3-1 -64.0 -128.91627   0.916268
4-1 -88.5 -153.41627 -23.583732
5-1 -77.5 -142.41627 -12.583732
3-2 -11.0  -75.91627  53.916268
4-2 -35.5 -100.41627  29.416268
5-2 -24.5  -89.41627  40.416268
4-3 -24.5  -89.41627  40.416268
5-3 -13.5  -78.41627  51.416268
5-4  11.0  -53.91627  75.916268
>
> errmod =  aov(Speed~Expt+Error(Run), data=morley)
> names(errmod)
[1] "(Intercept)" "Run"         "Within"
> basemod = errmod$W
>
> class(basemod)
[1] "aov" "lm"
> TukeyHSD(basemod)
Error in sort(unique.default(x), na.last = TRUE) :
    'x' must be atomic




More information about the R-help mailing list