Sub topic 17
Multiple comparisons and common pitfalls
This chapter assumes you can run a two-sample t-test and a one-way ANOVA. It also assumes you know what alpha and a p-value mean. It covers what goes wrong when you run many tests on one data set, how to correct for it, and the other mistakes that most often invalidate Analyze-phase conclusions.
Why many tests inflate false alarms
Each test at alpha = 0.05 has a 5% chance of a false positive when the null hypothesis is true. Run several tests and the chance that at least one is a false positive grows. This chance is the family-wise error rate (FWER). For m independent tests where every null is true:
FWER = 1 − (1 − alpha)^m
| Number of tests (m) | Chance of at least one false positive |
|---|---|
| 1 | 5.0% |
| 3 | 14.3% |
| 10 | 40.1% |
| 20 | 64.2% |
A Six Sigma team often triggers this without noticing. It happens when it screens 20 candidate Xs against one Y. It also happens when it compares every pair of five machines, which is 10 pairs.
Seeing it on pure noise
The script below compares 20 pairs of samples drawn from the same distribution, so every null is true. It then applies the Holm correction.
import numpy as np
from scipy import stats
from statsmodels.stats.multitest import multipletests
rng = np.random.default_rng(1)
n_tests = 20
p_values = []
for _ in range(n_tests):
a = rng.normal(100, 5, 30)
b = rng.normal(100, 5, 30) # same distribution as a
p_values.append(stats.ttest_ind(a, b, equal_var=False).pvalue)
p_values = np.array(p_values)
print("Raw p < 0.05:", int((p_values < 0.05).sum()))
reject, p_adj, _, _ = multipletests(p_values, alpha=0.05, method="holm")
print("Holm rejections:", int(reject.sum()))
print("Smallest adjusted p:", p_adj.min())On average, about one raw p-value in 20 falls below 0.05, even though no real difference exists. The exact count depends on the seed. After correction, a rejection is unlikely, and the smallest adjusted p-value is far above 0.05 in most runs.
Correction methods
Pick the method by what you are comparing.
| Situation | Method | Notes |
|---|---|---|
| All pairs of means after a significant ANOVA | Tukey HSD | Controls FWER for all pairwise comparisons. Standard choice. |
| Each treatment against one control | Dunnett | More powerful than Tukey when only control comparisons matter. |
| Any set of unrelated tests | Bonferroni | Use alpha / m for each test. Simple but conservative. |
| Any set of unrelated tests | Holm | Never less powerful than Bonferroni. Prefer it. |
| Screening many Xs, where some false leads are acceptable | Benjamini-Hochberg | Controls the false discovery rate (FDR), the expected share of false positives among your discoveries. |
Post hoc comparisons after ANOVA
A significant ANOVA says that at least one mean differs. It does not say which. Tukey HSD answers that question:
import numpy as np
from scipy import stats
rng = np.random.default_rng(7)
line_a = rng.normal(100, 5, 25)
line_b = rng.normal(102, 5, 25)
line_c = rng.normal(105, 5, 25)
f_stat, p_anova = stats.f_oneway(line_a, line_b, line_c)
print("ANOVA p =", p_anova)
# Run post hoc comparisons only if the ANOVA is significant
if p_anova < 0.05:
print(stats.tukey_hsd(line_a, line_b, line_c))stats.tukey_hsd needs SciPy 1.8 or later. It prints each pairwise difference with an adjusted p-value and a confidence interval. Report the intervals, because they show how large each difference is. A significant pair whose interval is wide or barely excludes zero deserves caution.
Common pitfalls
Choosing the test after seeing the result
If you try a t-test, then a Mann-Whitney test, then drop a few outliers, and report whichever gives p < 0.05, the real error rate is well above 5%. This practice is called p-hacking. Write down the hypothesis, the test, and the alpha before you look at the outcome. Record the plan in the project charter or the data collection plan.
Slicing the data after the fact
Splitting the data by shift, operator, supplier, and day until one subgroup shows a difference is a multiple-testing problem. Count every slice you looked at as a test. Treat a result found this way as a lead and confirm it with new data.
Ignoring independence
Every test in this tutorial assumes observations are independent. Ten measurements of the same part are not ten independent samples of the process. This error is pseudo-replication, and it makes p-values far too small. Consecutive readings from a drifting process are also correlated. Plot the data in time order before testing.
Reading "not significant" as "no difference"
A large p-value means the data did not give enough evidence against the null. A small sample or noisy measurements can produce it even when a real difference exists. Check the power. Look at the confidence interval for the effect, and ask whether it includes differences that matter to the business.
Misreading the p-value
The p-value is the probability of data at least this extreme if the null were true. It is not the probability that the null is true. It is also not the probability that the result will repeat.
Dropping assumptions checks
Normality and equal-variance checks are part of the test, not extras. Skipping them quietly is a common reason for conclusions that fail in the Improve phase. If the checks fail, use Welch's test or a non-parametric alternative. Do not just report the t-test anyway.
Confusing association with cause
A significant chi-square, correlation, or regression coefficient shows that X and Y move together in the data you collected. It does not show that changing X changes Y. Lurking variables are a common explanation. Confirm a suspected cause in the Improve phase with a designed experiment or a controlled pilot.
Chasing significance without practical value
With a large enough sample, a trivial difference gives p < 0.001. Always state the effect size in process units, such as 0.2 mm or 0.3 percentage points. Compare it with the smallest difference that would change a decision.
A pre-report checklist
- State the hypotheses and alpha before analyzing.
- Count how many tests you ran, including exploratory ones.
- Check independence, normality, and equal variance for each test.
- Apply a correction method that fits the comparison structure.
- Report effect sizes with confidence intervals, not only p-values.
- Mark exploratory findings as needing confirmation.
Exercise
A team compares defect rate against 12 candidate Xs, each with its own two-sample test at alpha = 0.05. Two tests give raw p-values of 0.03 and 0.04, and the rest are above 0.20. What is the chance of at least one false positive if all 12 nulls are true, and how should the team treat the two results?
Show answer
The chance is 1 − 0.95^12, about 46%. Two raw p-values just under 0.05 among 12 tests are what chance alone often produces. The team should apply Holm (or Bonferroni, with a per-test threshold of 0.05 / 12 ≈ 0.0042). Both raw p-values are above that threshold, so neither survives correction. The team should treat the two Xs as leads and confirm them with new data before acting.
Exercise
An ANOVA across five machines gives p = 0.01. A colleague then runs all 10 pairwise t-tests at alpha = 0.05 and reports every significant pair as a real difference. Name the problem and give one better approach.
Show answer
The 10 uncorrected tests inflate the family-wise error rate to about 40%, so some of the "significant" pairs may be false positives. A better approach is Tukey HSD, which controls the error rate across all pairs and gives confidence intervals. Applying Holm to the 10 pairwise p-values also works.