# Tukey's test

Tukey’s test is good choice for post-hoc comparisons. Specifically,
Tukey’s Honestly Significant Difference (HSD) test is implemented using
`TukeyHSD()`

. The input should be the output from `aov()`

. In our
example, this is our variable `out`

.

Tukey multiple comparisons of means

95 factor levels have been ordered

Fit: aov(formula = DIVERSTY ~ ZNGROUP, data = d)

$ZNGROUP

diff lwr upr p adj

3-4 0.44000000 -0.15739837 1.0373984 0.2095597

1-4 0.51972222 -0.09606192 1.1355064 0.1218677

2-4 0.75472222 0.13893808 1.3705064 0.0116543

1-3 0.07972222 -0.53606192 0.6955064 0.9847376

2-3 0.31472222 -0.30106192 0.9305064 0.5153456

2-1 0.23500000 -0.39863665 0.8686367 0.7457444

The additional argument `ordered = T`

just ensures the the differences
are positive. (Compare this result to `TukeyHSD(out)`

).

In all cases, we see that the data indicate that the difference really lies between groups 2 and 4. To adequately interpret and summarize this information, we have to follow the rules for interpreting post-hoc tests. We found:

$\mu _{4} = \mu _{3} = \mu _{1}$ and $\mu _{3} = \mu _{1} = \mu _{2}$.

We could also summarize this result on the boxplot using letters. Here,
I will have to expand the y-axis limits using the `ylim`

argument to
give room for the letters. I will also use
`tapply(d$DIVERSTY, d$ZNGROUP, max)`

to extract the maximum diversity
values in each group. These (plus a little extra space) become the
y-coordinates for the new letters.

+ ylab = "Diatom Diversity", names = c("B", "L", "M", "H"))

> text(1:4, tapply(d\$DIVERSTY, d\$ZNGROUP, max) + 0.15, c("ab", "a",

+ "ab", "b"))