Post-Hoc Tests

tags: #statistics/inferential/anova/post_hoc

What is Tukey HSD?

The Tukey's Honestly Significant Difference (HSD) test is a post-hoc test that can be used following a significant ANOVA result to determine which specific groups are significantly different from each other.

The test is based on a pairwise comparison of group means, and it calculates a critical value for the difference between the means that must be exceeded to conclude that the difference is statistically significant.

Tukey HSD has the properties of being both: conservative and robust

We can conduct a post-hoc Tukey HSD whenever there is a significant F statistic.

What makes Tukey different from T-tests?

Import libraries

import pandas as pd
import numpy as np
from scipy.stats import f_oneway
from statsmodels.stats.multicomp import pairwise_tukeyhsd

Run Tukey

# perform Tukey's test
tukey = pairwise_tukeyhsd(endog=df['CONTINUOUS DV'],
                          groups=df['CATEGORICAL IDV'],
                          alpha=0.05)

#display results
print(tukey)

 Multiple Comparison of Means - Tukey HSD, FWER=0.05 
=====================================================
group1 group2 meandiff p-adj   lower    upper  reject
-----------------------------------------------------
     a      b      8.4 0.0158   1.4272 15.3728   True
     a      c      1.3 0.8864  -5.6728  8.2728  False
     b      c     -7.1 0.0453 -14.0728 -0.1272   True
-----------------------------------------------------



  1. A conservative approach is generally preferred in situations where false positives (Type I errors) are considered to be more problematic than false negatives (Type II errors) ↩︎

  2. https://medium.com/mlearning-ai/two-way-anova-post-hoc-analysis-what-is-the-difference-between-tukeyhsd-and-t-test-121ce557797f ↩︎

Powered by Forestry.md