timtimbruno
timtimbruno

Reputation: 61

Changing control group for Dunnett glht in multcomp

I was wondering if anyone knows how to change between treatment groups for the control treatment for the Dunnett test in multcomp? A control treatment is selected by the first treatment alphabetically/numerically. I have several sets of data that I'd prefer not to go through editing if I can simply do it with code, plus I have two controls I'd like to compare my experimental treatments to.

For example, my "data"

TrtName Block   Trt X3dpi   X6dpi   X12dpi
Neg_ctrl    1   1   1   4   8
Neg_ctrl    1   1   1   3   8
Neg_ctrl    1   1   2   4   9
Neg_ctrl    2   1   1   3   9
Neg_ctrl    2   1   1   4   8
Neg_ctrl    2   1   1   5   9
TC_ctrl 1   2   2   5   9
TC_ctrl 1   2   2   5   9
TC_ctrl 1   2   1   4   9
TC_ctrl 2   2   1   3   7
TC_ctrl 2   2   2   4   9
TC_ctrl 2   2   2   3   8
D_112   1   3   0   1   5
D_112   1   3   0   1   4
D_112   1   3   1   2   5
D_112   2   3   0   2   5
D_112   2   3   1   1   3
D_112   2   3   1   2   4
D_332   1   4   0   1   5
D_332   1   4   0   2   5
D_332   1   4   1   2   4
D_332   2   4   0   2   5
D_332   2   4   1   3   6
D_332   2   4   2   4   7
J_045   1   5   2   5   9
J_045   1   5   2   5   8
J_045   1   5   1   4   8
J_045   2   5   2   5   9
J_045   2   5   1   5   8
J_045   2   5   1   3   8
J_185   1   6   2   5   8
J_185   1   6   1   4   
J_185   1   6   2   4   8
J_185   2   6   0   3   9
J_185   2   6   2   5   9
J_185   2   6   2   4   9
J_185   2   6   1   3   8

Code I'm using:

FHBficFit3dpi <- aov(X3dpi~ TrtName, FHBficData)
set.seed(115)
FHBficDunnett3dpi <- glht(model = FHBficFit3dpi, linfct=mcp(TrtName="Dunnett"))
summary(FHBficDunnett3dpi)

Results: Simultaneous Tests for General Linear Hypotheses

Multiple Comparisons of Means: Dunnett Contrasts


Fit: aov(formula = X3dpi ~ TrtName, data = FHBficData)

Linear Hypotheses:
                  Estimate Std. Error t value Pr(>|t|)  
D_332 - D_112 == 0      0.1667     0.3624   0.460   0.9873  
J_045 - D_112 == 0      1.0000     0.3624   2.759   0.0390 *
J_185 - D_112 == 0      0.9286     0.3492   2.659   0.0489 *
Neg_ctrl - D_112 == 0   0.6667     0.3624   1.840   0.2534  
TC_ctrl - D_112 == 0    1.1667     0.3624   3.219   0.0128 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Adjusted p values reported -- single-step method)

I realize changing the model to "X3dpi ~ Trt" would result in the correct comparison, but I'd like to compare each of the treatments to the TC_ctrl group as well.

Upvotes: 2

Views: 3881

Answers (1)

Try this: change the order of the factors and put the group you want first:

FHBficData$TrtName<-factor(FHBficData$TrtName,levels=c("TC_ctrl","D_332","J_045","J_185","Neg_ctrl","D_112"),ordered=TRUE)
FHBficFit3dpi <- aov(X3dpi~ TrtName, FHBficData)
set.seed(115)
FHBficDunnett3dpi <- glht(model = FHBficFit3dpi, linfct=mcp(TrtName="Dunnett"))
summary(FHBficDunnett3dpi)

You'll get this:

     Simultaneous Tests for General Linear Hypotheses

Multiple Comparisons of Means: Dunnett Contrasts


Fit: aov(formula = X3dpi ~ TrtName, data = FHBficData)

Linear Hypotheses:
                        Estimate Std. Error t value Pr(>|t|)  
D_332 - TC_ctrl == 0     -1.0000     0.3624  -2.759   0.0391 *
J_045 - TC_ctrl == 0     -0.1667     0.3624  -0.460   0.9873  
J_185 - TC_ctrl == 0     -0.2381     0.3492  -0.682   0.9361  
Neg_ctrl - TC_ctrl == 0  -0.5000     0.3624  -1.380   0.5114  
D_112 - TC_ctrl == 0     -1.1667     0.3624  -3.219   0.0128 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Adjusted p values reported -- single-step method)

Upvotes: 4

Related Questions