Tukey HSD (honestly significant difference) is the standard follow-up when a one-way ANOVA says that some group means differ but not which ones. It compares every pair of groups at once and widens each interval just enough that the chance of any false alarm across the whole family stays at the chosen level, usually 5%.
The procedure, from overall test to a list of differing pairs:
Why not just run many t-tests? With $k$ groups there are $m=k(k-1)/2$ pairs. Each unadjusted test has a 5% false-positive rate, so the chance of at least one false alarm grows quickly. If the tests behaved independently, three comparisons would give about $1-0.95^3\approx0.143$ (14.3%), and the 15 pairs among six groups would give about $1-0.95^{15}\approx0.537$. Tukey replaces that growth with a single family-wise error rate.
The formula. For groups $i$ and $j$ with sizes $n_i,n_j$, the ANOVA error mean square $MS_W$ on $\nu=N-k$ degrees of freedom gives the Tukey-Kramer simultaneous interval, which also handles unequal group sizes:
Here $q_{1-\alpha,k,\nu}$ is the upper critical value of the studentized range distribution, the distribution of the largest minus the smallest of $k$ means divided by the standard error. For equal group size $n$ the half-width is the single number $\mathrm{HSD}=q\sqrt{MS_W/n}$; any pair of means farther apart than HSD is declared different.
Worked example. The three etch-recipe groups from the ANOVA entries have sizes $3,4,5$, means $13,\,16.5,\,21$, $MS_W=17/9\approx1.889$, and $\nu=9$. The $95\%$ studentized-range value is $q_{0.95,3,9}\approx3.948$.
| Pair | Difference | Tukey half-width | 95% interval | Adjusted p |
|---|---|---|---|---|
| B minus A | $3.5$ | $2.931$ | $[0.57,\,6.43]$ | $0.0215$ |
| C minus A | $8.0$ | $2.802$ | $[5.20,\,10.80]$ | $0.0001$ |
| C minus B | $4.5$ | $2.574$ | $[1.93,\,7.07]$ | $0.0022$ |
Every interval excludes $0$, so all three recipes differ from each other while the family-wise error stays at 5%. The intervals match both scipy and statsmodels. The picture compares them with the narrower unadjusted $t$ intervals, which would look more precise but overstate the evidence:
Practical rules.
- Adjusted p-values: report the Tukey-adjusted p-value or simultaneous interval, not the raw t-test p-value for each pair.
- Assumptions: independent observations, roughly normal residuals, and similar variances across groups. If variances differ clearly, use the Games-Howell procedure instead.
- Unequal sizes: the Tukey-Kramer form above is the right one; do not average the group sizes by hand.
- Alternatives: Bonferroni is simpler but, when every pair is compared, is often more conservative. Here its B minus A half-width would be about $3.08$ against Tukey's $2.93$. Dunnett's test is better when every group is compared only to a control.
- Meaning: a difference being reliably non-zero does not mean it is large enough to matter; read the interval in process units.
Read Tukey HSD as an ANOVA follow-up that answers "which pairs differ?" with one shared error budget: wider intervals than separate t-tests, in exchange for a false-alarm rate you can actually state.