user3724295
user3724295

Reputation: 213

How to make multiple comparison with a control in R using Dunnett procedure?

I have the following data from an experiment

> spears
   treatment length
1    Control   94.7
2    Control   96.1
3    Control   86.5
4    Control   98.5
5    Control   94.9
6        IAA   89.9
7        IAA   94.0
8        IAA   99.1
9        IAA   92.8
10       IAA   99.4
11       ABA   96.8
12       ABA   87.8
13       ABA   89.1
14       ABA   91.1
15       ABA   89.4
16       GA3   99.1
17       GA3   95.3
18       GA3   94.6
19       GA3   93.1
20       GA3   95.7
21      CPPU  104.4
22      CPPU   98.9
23      CPPU   98.9
24      CPPU  106.5
25      CPPU  104.8

An I want to compare all the treatments against the "Control" treatment using the following code

mod0 <-aov( length ~ treatment, data = spears)
summary(mod0)

library(multcomp)
spears_dun <- glht(mod0,linfct = mcp(treatment = "Dunnett"), alternative = "greater")
summary(spears_dun)

However it is taking the first treatment in alphabetical order (ABA) as control instead of the "Control" treatment.

The results are as follow

Simultaneous Tests for General Linear Hypotheses

Multiple Comparisons of Means: Dunnett Contrasts


Fit: aov(formula = length ~ treatment, data = spears)

Linear Hypotheses:
               Estimate Std. Error t value Pr(>t)    
Control - ABA <= 0    3.300      2.325   1.419 0.2240    
CPPU - ABA <= 0      11.860      2.325   5.101 <0.001 ***
GA3 - ABA <= 0        4.720      2.325   2.030 0.0833 .  
IAA - ABA <= 0        4.200      2.325   1.806 0.1230    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Adjusted p values reported -- single-step method)

How can I make the comparison against "Control"?

Thanks.

Upvotes: 1

Views: 1879

Answers (2)

Chuck P
Chuck P

Reputation: 3923

You can force the treatment contrast level when you make it a factor into any order you like the first will be the base.

spears$treatment <- factor(spears$treatment, 
                          levels = c("Control", "ABA", "CPPU", "GA3", "IAA"))

contrasts(spears$treatment)
#>         ABA CPPU GA3 IAA
#> Control   0    0   0   0
#> ABA       1    0   0   0
#> CPPU      0    1   0   0
#> GA3       0    0   1   0
#> IAA       0    0   0   1

mod0 <-aov( length ~ treatment, data = spears)

library(multcomp)

spears_dun <- glht(mod0,linfct = mcp(treatment = "Dunnett"), alternative = "greater")

summary(spears_dun)
#> 
#>   Simultaneous Tests for General Linear Hypotheses
#> 
#> Multiple Comparisons of Means: Dunnett Contrasts
#> 
#> 
#> Fit: aov(formula = length ~ treatment, data = spears)
#> 
#> Linear Hypotheses:
#>                     Estimate Std. Error t value  Pr(>t)   
#> ABA - Control <= 0    -3.300      2.325  -1.419 0.99232   
#> CPPU - Control <= 0    8.560      2.325   3.682 0.00272 **
#> GA3 - Control <= 0     1.420      2.325   0.611 0.55407   
#> IAA - Control <= 0     0.900      2.325   0.387 0.65279   
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> (Adjusted p values reported -- single-step method)

Upvotes: 1

St&#233;phane Laurent
St&#233;phane Laurent

Reputation: 84599

The treatment column must be a factor and you have to set its reference level to "Control", with the relevel function:

library(multcomp)

dat <- data.frame(
  treatment = c("Control", "Control", "ABA", "ABA", "X", "X"),
  length = c(1, 2, 3, 4, 5, 6),
  stringsAsFactors = TRUE
)
dat$treatment <- relevel(dat$treatment, ref = "Control")

amod <- aov(length ~ treatment, data = dat)
glht(amod, linfct = mcp(treatment = "Dunnett"))

Upvotes: 1

Related Questions