How to do the Dunnett test in R?

4
Assuming that I performed the ANOVA test on my data and gave significantly different, I would like to perform the Dunnett test precisely to compare my treatments with the control group. Should I use some specific package or in the default R's already have?

    
asked by anonymous 24.06.2018 / 16:28

1 answer

7

To do the Dunnet test, you can use the glht function of the multcomp package.

As there is no data in the question I will use the base iris .

Immediately before running the test, you must initialize the random number generator because it seems that multivariate t calculations call the random number generator. With set.seed() or results are reproducible.

library(multcomp)

data(iris)

fit <- aov(Sepal.Length ~ Species, data = iris)

set.seed(204)    # Torna os resultados reprodutíveis
summary(glht(fit, linfct = mcp(Species = "Dunnett")))
#
#Simultaneous Tests for General Linear Hypotheses
#
#Multiple Comparisons of Means: Dunnett Contrasts
#
#
#Fit: aov(formula = Sepal.Length ~ Species, data = iris)
#
#Linear Hypotheses:
#                         Estimate Std. Error t value Pr(>|t|)    
#versicolor - setosa == 0    0.930      0.103   9.033   <1e-10 ***
#virginica - setosa == 0     1.582      0.103  15.366   <1e-10 ***
#---
#Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#(Adjusted p values reported -- single-step method)

Note.

The idea of calling set.seed comes from the answers to a question in Cross Validated, Why does the Dunnett test give different values each time you run in English.

    
24.06.2018 / 17:02