Create a set of confidence intervals on the differences between the means of the levels of a factor with the specified family-wise probability of coverage. The intervals are based on the Studentized range statistic, Tukey's ‘Honest Significant Difference’ method.
TukeyHSD(x, which, ordered = FALSE, conf.level = 0.95, ...)
A fitted model object, usually an
A character vector listing terms in the fitted model for which the intervals should be calculated. Defaults to all the terms.
A logical value indicating if the levels of the factor
should be ordered according to increasing average in the sample
before taking differences. If
A numeric value between zero and one giving the family-wise confidence level to use.
Optional additional arguments. None are used at present.
This is a generic function: the description here applies to the method
for fits of class
When comparing the means for the levels of a factor in an analysis of variance, a simple comparison using t-tests will inflate the probability of declaring a significant difference when it is not in fact present. This because the intervals are calculated with a given coverage probability for each interval but the interpretation of the coverage is usually with respect to the entire family of intervals.
John Tukey introduced intervals based on the range of the sample means rather than the individual differences. The intervals returned by this function are based on this Studentized range statistics.
The intervals constructed in this way would only apply exactly to balanced designs where there are the same number of observations made at each level of the factor. This function incorporates an adjustment for sample size that produces sensible intervals for mildly unbalanced designs.
which specifies non-factor terms these will be dropped with
a warning: if no terms are left this is an error.
A list of class
with one component for each term requested in
Each component is a matrix with columns
diff giving the
difference in the observed means,
lwr giving the lower
end point of the interval,
upr giving the upper end point
p adj giving the p-value after adjustment for the multiple
plot methods for class
plot method does not accept
main arguments and creates its own
values for each plot.
Miller, R. G. (1981) Simultaneous Statistical Inference. Springer.
Yandell, B. S. (1997) Practical Data Analysis for Designed Experiments. Chapman & Hall.
glht in package multcomp.
require(graphics) summary(fm1 <- aov(breaks ~ wool + tension, data = warpbreaks)) TukeyHSD(fm1, "tension", ordered = TRUE) plot(TukeyHSD(fm1, "tension"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.