Compare every pair of group means with Tukey HSD, interpret simultaneous intervals, and distinguish family-wise error control from unadjusted tests and FDR.
Tukey HSD test
The Tukey HSD test—Tukey's honestly significant difference test—compares every pair of population means while controlling the chance of at least one false rejection across that family. For a quant comparing mean execution costs across several venues, it answers which gaps are statistically detectable after accounting for the whole set of pairwise comparisons.
An omnibus analysis of variance asks whether all means are equal. It does not identify the pairs responsible for a difference. Tukey HSD is commonly used for that follow-up question; its adjustment is designed specifically for all pairwise mean comparisons. NIST explains the simultaneous confidence guarantee.
One threshold for a balanced design
Suppose there are k≥2 fixed groups, each containing n≥2 observations. The classical model assumes observations are independent within and across groups, each group's errors are normally distributed, and all groups share a common positive, finite error variance. Their population means may differ.
Let yˉi be group i's sample mean. Estimate the common variance using the pooled within-group mean square:
MSE=ν∑i=1k∑r=1n(yir−yˉi)2,ν=k(n−1).
Write q1−α;k,ν for the lower-tail 1−α quantile of the studentised range distribution. The honestly significant difference is
HSD=q1−α;k,νnMSE.
Reject the pairwise null hypothesisμi=μj when ∣yˉi−yˉj∣>HSD. Equivalently, check whether zero falls outside the interval
(yˉi−yˉj)±HSD.
These are simultaneous confidence intervals: under the balanced normal model, the entire collection covers its true pairwise differences with probability 1−α over repeated samples. The studentised range calibrates the largest standardised spread, so the threshold accounts for inspecting every pair. The denominator here is MSE/n; inserting the ordinary two-mean standard error 2MSE/n would add an erroneous factor of 2. Abdi and Williams give both balanced and unequal-size formulas.
Three venues, only one detected gap
Consider a stipulated teaching example of execution cost in basis points (bp), where a larger value means a higher cost. Venues A, B and C have five observations each and sample means of 10, 12 and 15 bp. Stipulate pooled MSE=4bp2 and the model assumptions above.
There are 15−3=12 residual degrees of freedom. At family level α=0.05,
Stipulated three-venue example: B minus A is 2 bp with interval minus 1.375 to 5.375; C minus B is 3 bp with interval minus 0.375 to 6.375; C minus A is 5 bp with interval 1.625 to 8.375. Only C minus A excludes zero.
Original fixed-input illustration. All three intervals use the same 3.3746 bp margin and jointly target 95% coverage under the stated model.
Only A versus C clears the threshold. The other two nonrejections do not establish equality, and they do not imply that A and C must have equal means. A statistically detected cost gap also does not determine which venue is preferable after fees, fill quality and operational constraints.
These summary inputs support the arithmetic, not evidence that a real dataset satisfies the assumptions. No raw observations or sampling design are supplied. In an actual venue study, shared market shocks, repeated parent orders and changing volatility can undermine independence or a common variance; checking a formula cannot resolve those design issues.
What the adjustment protects
The family-wise error rate is the probability of one or more false rejections within the defined family. Tukey's procedure controls it at no more than α under its model. This differs from the false discovery rate, which concerns the expected proportion of false rejections among all rejections, with that proportion defined as zero when nothing is rejected.
Running each pair's t-test at an unadjusted 5% level does not generally provide a 5% family guarantee. Nor does Tukey's adjustment for three declared venues automatically cover an earlier search over many venue definitions, time windows or performance measures. Define the comparison family and analysis before using the result as evidence.
Unequal group sizes need Tukey–Kramer
With unequal ni, the common-variance extension uses a pair-specific margin:
q1−α;k,N−k2MSE(ni1+nj1),N=i=1∑kni.
This is the Tukey–Kramer method; substituting one convenient sample size into the balanced formula is incorrect. The expression reduces to HSD when both sizes equal n. Unequal sample sizes do not remove the common-variance assumption. Unequal-variance alternatives such as Games–Howell use different uncertainty calculations; SciPy's documentation distinguishes these procedures and states their assumptions.
For a full derivation of the pooled variance and the global test, read One-Way Analysis of Variance (public preview; full lesson requires membership).