7 Post-hoc

7.1 TukeyHSD (Tukey’s Honestly-Significant Difference) post-hoc test in R

There are at least two ways to perform a Tukey’s HSD post-hoc in R. One is by using the TukeyHSD function of the pre-installed R package stats. The second is the glht function with "Tukey" option bundled along with the multcomp package.

7.2 Using TukeyHSD of stats package

TukeyHSD(one_aov)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Sales ~ Type, data = .)
## 
## $Type
##                   diff        lwr        upr     p adj
## Pink-Colorless    2.24 -0.5880714  5.0680714 0.1479369
## Orange-Colorless -0.88 -3.7080714  1.9480714 0.8099459
## Green-Colorless   4.14  1.3119286  6.9680714 0.0034923
## Orange-Pink      -3.12 -5.9480714 -0.2919286 0.0281177
## Green-Pink        1.90 -0.9280714  4.7280714 0.2580535
## Green-Orange      5.02  2.1919286  7.8480714 0.0005837

Discussion of Results. Picking up from the significant ANOVA result in our soft drink data, the Tukey’s HSD post-hoc analysis result above shows the following significant comparisons at \(0.05\):

cat("Avg. Sales Comparison\t P-value (adjusted)\n---------------------------------------------\nGreen > Colorless\t 0.0034923\nGreen > Orange\t\t 0.0005837\nOrange > Pink\t\t 0.0281177\n---------------------------------------------\n")
## Avg. Sales Comparison     P-value (adjusted)
## ---------------------------------------------
## Green > Colorless     0.0034923
## Green > Orange        0.0005837
## Orange > Pink         0.0281177
## ---------------------------------------------

7.3 Using the multicomp package with “Tukey” option

summary(glht(one_aov, linfct = mcp(Type = "Tukey")))
## 
##   Simultaneous Tests for General Linear Hypotheses
## 
## Multiple Comparisons of Means: Tukey Contrasts
## 
## 
## Fit: aov(formula = Sales ~ Type, data = .)
## 
## Linear Hypotheses:
##                         Estimate Std. Error t value Pr(>|t|)    
## Pink - Colorless == 0     2.2400     0.9885   2.266  0.14815    
## Orange - Colorless == 0  -0.8800     0.9885  -0.890  0.80991    
## Green - Colorless == 0    4.1400     0.9885   4.188  0.00339 ** 
## Orange - Pink == 0       -3.1200     0.9885  -3.156  0.02817 *  
## Green - Pink == 0         1.9000     0.9885   1.922  0.25800    
## Green - Orange == 0       5.0200     0.9885   5.078  < 0.001 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- single-step method)