How to Perform Dunnett’s Test in R

Spread the love

Dunnett’s test is commonly used in the context of a one-way Analysis of Variance (ANOVA) to compare all treatments against a single control. It is particularly useful in experiments where the primary interest lies in comparing various treatments with a control group rather than comparing every possible pair of groups. This test is known for being relatively powerful while maintaining control over the Type I error rate.

In this article, we’ll discuss how to prepare your data, perform Dunnett’s test, interpret the results, and delve into a real-world case study to illustrate these steps.

Table of Contents

  1. Prerequisites
  2. Data Preparation
  3. Understanding One-way ANOVA
  4. Performing Dunnett’s Test
  5. Interpretation of Results
  6. Advantages and Disadvantages
  7. Conclusion

1. Prerequisites

Software Requirements

  • R (version 3.6.0 or later)
  • RStudio (optional, but recommended)


  • multcomp

You can install the multcomp package from CRAN by running the following command:


Basic Knowledge of One-way ANOVA

A fundamental understanding of one-way ANOVA is beneficial as Dunnett’s test is typically carried out following a significant ANOVA result.

2. Data Preparation

Input Data

Ensure your data is well-structured, usually in a .csv file or a data frame. The data should consist of at least two variables – one categorical (the group identifier) and one continuous (the dependent variable).

Import Data into R

To read a .csv file:

simple_data <- read.csv("your_file_path.csv")

Or, create a data frame:

# Create a simplified dataset
simple_data <- data.frame(Group = factor(rep(c("Control", "Treatment1", "Treatment2"), each = 5)),
                          Score = c(runif(5, 80, 90), runif(5, 90, 100), runif(5, 70, 80)))

3. Understanding One-way ANOVA

Before performing Dunnett’s test, it is recommended to perform a one-way ANOVA to check for any overall differences between the groups.

# Run a One-way ANOVA
simple_anova_result <- aov(Score ~ Group, data = simple_data)

4. Performing Dunnett’s Test

Load the Package


Create the Dunnett Contrasts

Here, you specify which groups are treatments and which one is the control.

simple_dunnettContrasts <- glht(simple_anova_result, linfct = mcp(Group = "Dunnett"))

Execute the Test

To execute the Dunnett’s test:


5. Interpretation of Results

Dunnett’s test produces a summary that includes the estimated differences between each treatment and the control, along with the corresponding p-values. If the p-value is less than your chosen significance level (often 0.05), you can reject the null hypothesis and conclude that the group in question significantly differs from the control group.

6. Advantages and Disadvantages


  • Specific in comparing each group against a single control.
  • Controls the familywise error rate effectively.


  • Cannot be used for pairwise comparisons between multiple treatment groups.
  • Assumes homogeneity of variances across groups.

7. Conclusion

Dunnett’s test is a specialized tool, ideal for experiments where the primary objective is to compare multiple treatment groups against a single control group. It is both powerful and fairly easy to implement in R, given the appropriate circumstances.By following the steps outlined in this comprehensive guide, you should be well-equipped to perform and interpret Dunnett’s Test in R, thereby gaining actionable insights from your experiments.

Posted in RTagged

Leave a Reply