# Dunnett's test

Finally, instead of comparing all possible combinations, you might
instead want to just compare each group to a reference. In this case,
you might want to use the "Background" group as a reference. Dunnett’s
test will do this, and can be implemented in the `multcomp`

library. The
main function in `multcomp`

for doing post hoc tests is `glht`

(which
stands for ’general linear hypothesis tests’). At this point, the syntax
may seem a little strange, but the `multcomp`

library is extremely
powerful. We will only scratch the surface by using it to conduct the
Dunnett’s test. (Also, be aware that when you install `multcomp`

, there
are a large number of other libraries it depends on.)

> test.out = glht(out, linfct = mcp(ZNGROUP = "Dunnett"))

> summary(test.out)

Simultaneous Tests for General Linear Hypotheses

Multiple Comparisons of Means: Dunnett Contrasts

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

Linear Hypotheses:

Estimate Std. Error t value Pr( > |t|)

2 - 1 == 0 0.23500 0.23303 1.008 0.6195

3 - 1 == 0 -0.07972 0.22647 -0.352 0.9701

4 - 1 == 0 -0.51972 0.22647 -2.295 0.0725 .

---

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Adjusted p values reported -- single-step method)

Notice that the first group (whatever that happens to be) is considered the reference group. Be careful to make sure this is what you want!

**Key Point to Remember:** The steps to analyzing the data using ANOVA
were:

plot the response as a function of the grouping variable,

fit the linear model using

`lm()`

,consider the assumptions (e.g., by examining the residuals of the linear model),

interpret the ANOVA results, which were obtained using

`anova()`

,consider post-hoc comparisons.