0
votes

I'm wondering if i can use the function "TukeyHSD" to perform the all pairwise comparisons of a "aov()" model with one factor (e.g., GROUP) and one continuous covariate (e.g., AGE). I did for example:

library(multcomp)
data('litter', package = 'multcomp')
litter.aov <- aov(weight ~ gesttime + dose, data = litter)
TukeyHSD(litter.aov, which = 'dose')

and i get a warning message like this: Warning message: In replications(paste("~", xx), data = mf): non-factor ignored: gesttime

Is this process above correct? What's the meaning of the warning message? And does "TukeyHSD" apply to badly unbalanced designs?

In addition, is there any difference between the processes above and below?

litter.mc <- glht(litter.aov, linfct = mcp(dose = 'Tukey'))
summary(litter.mc)

Best, Sue

1
See the ?TukeyHSD help page description: "...differences between the means of the levels of a factor with the specified family-wise probability of coverage."Roman Luštrik

1 Answers

0
votes

There's no difference. TukeyHSD() is just a bit more eager to tell you about potential problems. Notice that it's a warning message, not an error, meaning that the results might not be what you expect, but they'll still be returned so you can judge for yourself.

As for what it means, it means what it says: non-factor variables are ignored. Remember that you are comparing the differences between groups, and grouping is done using factors, so factors are all TukeyHSD() care about. In your case you explicitly tell the function to only care about dose, which is factor, so the warning might be seen as overly cautious.

One way of avoiding the warning would be to convert gesttime into a factor, and as it consist of only four levels it makes some sense to do so.

data('litter', package = 'multcomp')
litter$gesttime <- as.factor(litter$gesttime)
litter.aov <- aov(weight ~ gesttime + dose, data = litter)

TukeyHSD(litter.aov, which = 'dose')