Multiple comparisons: which error are you controlling?
多重比较
Derive family-wise control and compute Holm, BH and BY decisions without hiding the hypothesis family.
multiple-testingTwenty chances to find something surprising
Suppose a team compares twenty model variants with one baseline. Even if every null hypothesis is true, twenty independent tests that each reject with probability 0.05 have probability 1−0.95²⁰, about 64%, of producing at least one rejection. The calculation assumes independent tests with exactly that size; shared test data usually make model comparisons dependent. It is a warning about repeated opportunities, not a formula to apply to every benchmark.
Before inspecting results, define the family: which datasets, outcomes, subgroups and model variants support the same scientific claim? Reporting only the smallest p-value conceals the number of opportunities. Read p-values and statistical power first.
Choose the error you want to control
Let R count all rejected hypotheses and V count rejected hypotheses whose nulls are actually true. These counts depend on the data; V is normally unknown in a real study. Two different criteria are:
Family-wise error control limits the chance of any false rejection. False discovery rate control limits an expectation over repeated studies, not the false fraction in every particular list. If all nulls are true, V=R, so these criteria coincide. If many genuine signals exist, FDR permits a different tradeoff. Neither criterion measures effect size.
Bonferroni and Holm: protect the whole family
Assume each true-null p-value is valid: Pr(pᵢ≤u)≤u for thresholds u in [0,1]. Bonferroni rejects pᵢ≤α/m. The union bound gives, without independence:
Katsevich’s lecture gives this argument and contrasts FWER with FDR. Holm sorts p-values ascending and compares the first with α/m, the next with α/(m−1), and so on, stopping at the first failure. To see why dependence is still allowed, suppose the first true null in this ordering is rejected and m₀ nulls are true. At that rank the denominator is at least m₀, so some true-null p-value must be at most α/m₀. Applying the union bound to those m₀ values bounds this event by α. This proof needs valid component tests, even when some other nulls are false.
BH: the last passing rank matters
For target FDR q, the Benjamini–Hochberg rule sorts the same values, finds the largest passing rank and rejects the entire prefix:
A failure at an early rank does not stop BH: a later rank may pass its larger threshold. Under independent valid p-values BH controls FDR at q; extensions cover specified positive dependence conditions, not arbitrary correlation. Benjamini–Yekutieli replaces q by q/Hₘ, where Hₘ=1+1/2+…+1/m, to allow arbitrary dependence. R’s reference documents these methods and their original papers. We use these established algorithms, not new features of the development manual viewed on the check date.
Keep original hypothesis labels attached
This complete Python 3.12 program accepts 1–1000 rational p-values and returns adjusted values in the original order. Compare each output with your chosen level. Bonferroni multiplies by m. Holm takes forward cumulative maxima of the decreasing-multiplier products; BH/BY take reverse cumulative minima of rank-adjusted products. These monotone envelopes encode their respective rejection rules, including ties.
from fractions import Fraction as F
def adjust(values, method):
p = list(values)
if not 1 <= len(p) <= 1000:
raise ValueError('one to 1000 p-values required')
if any(type(x) not in (int, F) or not 0 <= x <= 1 for x in p):
raise ValueError('rational p-values in [0,1] required')
if method not in ('bonferroni', 'holm', 'bh', 'by'):
raise ValueError('unknown method')
p = list(map(F, p)); m = len(p)
order = sorted(range(m), key=p.__getitem__)
result = [F(0)] * m
if method == 'bonferroni':
return [min(F(1), m*x) for x in p]
if method == 'holm':
bound = F(0)
for rank, index in enumerate(order):
bound = max(bound, (m-rank)*p[index])
result[index] = min(F(1), bound)
else:
scale = sum((F(1,j) for j in range(1,m+1)), F(0)) if method == 'by' else F(1)
bound = F(1)
for rank in range(m-1, -1, -1):
index = order[rank]
bound = min(bound, scale*m*p[index]/(rank+1))
result[index] = bound
return result
if __name__ == '__main__':
p = [F(1,1000), F(12,1000), F(18,1000), F(4,100), F(20,100)]
for method in ('bonferroni', 'holm', 'bh', 'by'):
adjusted = adjust(p, method)
print(method, [str(x) for x in adjusted],
'rejected:', [i+1 for i,x in enumerate(adjusted) if x <= F(1,20)])
print('independent all-null unadjusted error:', f'{float(1-F(19,20)**20):.6f}')
Output:
bonferroni ['1/200', '3/50', '9/100', '1/5', '1'] rejected: [1]
holm ['1/200', '6/125', '27/500', '2/25', '1/5'] rejected: [1, 2]
bh ['1/200', '3/100', '3/100', '1/20', '1/5'] rejected: [1, 2, 3, 4]
by ['137/12000', '137/2000', '137/2000', '137/1200', '137/300'] rejected: [1]
independent all-null unadjusted error: 0.641514
In the five-test example, Bonferroni rejects hypothesis 1; Holm rejects 1 and 2; BH rejects 1–4; BY rejects only 1. These are decisions for this input, not evidence that any rejected hypothesis is false. The true states are deliberately not supplied.
Sorting costs O(m log m) comparisons; the scans and additional storage are O(m), excluding rational-number bit costs. The implementation uses no R runtime and is not a port of its source. Empty input, booleans and floating-point p-values are rejected so threshold arithmetic remains exact; practical software needs an explicit missing-value policy.
Adjustment cannot repair a hidden experiment
Including only favorable outcomes understates the family size. Repeatedly inspecting data, adapting hypotheses or choosing the test after seeing results can also invalidate the individual p-values; multiplying them afterward does not automatically restore validity. For confirmatory work, specify the family and analysis in advance. For exploratory work, disclose the search and reserve independent data for confirmation.
There is a cost in power, so “use the strictest correction everywhere” is not a design strategy. Decide whether one false claim would be unacceptable or whether a discovery list will undergo further validation. Report effect estimates, uncertainty and the chosen error criterion alongside adjusted values. BH outputs are not posterior probabilities that individual hypotheses are null.
Check the family and the stopping rule
- Why is 20×0.05 not the exact independent all-null probability of at least one rejection?
Answer 1: It adds overlapping events. The exact value is 1−0.95²⁰; the union bound gives an upper bound of 1 here.
- With p=(0.03,0.04), m=2 and q=0.05, what does BH reject?
Answer 2: Both. Rank 1 fails 0.025 but rank 2 passes 0.05; BH uses the last passing rank.
- If FDR is controlled at 5%, must every reported list contain at most 5% false discoveries?
Answer 3: No. The guarantee concerns the expected fraction across repetitions under its assumptions.
- For p=(0.01,0.03,0.04), compute Holm adjusted values.
Answer 4: The raw rank products are (0.03,0.06,0.04); cumulative maxima give (0.03,0.06,0.06).
Separate the theorem from the software label
Holm’s 1979 method and Benjamini–Hochberg’s 1995 paper address different error criteria; Benjamini–Yekutieli’s 2001 work examines dependence. Their bibliographic records are linked in the R reference. This chapter verifies the Bonferroni/Holm arguments and computes decisions; it does not reproduce the full BH dependence proof.
As a project, simulate experiments with known true and false nulls. Record V and R on every repetition, then estimate FWER and FDR separately. Include Monte Carlo uncertainty, dependent cases and a fixed alternative for power. Never estimate FDR from a single observed list whose true states are unknown.
Make a prediction, then check
BH has an early failure followed by a passing later rank. Where does rejection stop?
Learning objectives
- Distinguish FWER from FDR and state valid-test assumptions.
- Compute adjusted values while preserving hypothesis labels.
Prerequisites & connections
Explore related knowledge →References
- STAT 9610 — Multiple testing
Eugene Katsevich - R stats — Adjust P-values for Multiple Comparisons
R Core Team
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-06 · Codex single-agent authored technical review: primary-source locations, explicit assumptions, exact/literal and numerical checks, and bilingual review; not independent human or second-agent review.
- Single-agent authored technical review: cited primary-source locations, explicit assumptions, original derivations and examples, bilingual equations and four matching exercises. Not independent human or second-agent review.
- Four focused CPython3.12.4 tests passed: literal reference cases, mathematical invariants or full finite-design calibration, invalid inputs and bilingual structure. Rational arithmetic is separated from floating logarithms. R/SciPy documentation was read without claiming those runtimes were executed.
- Promoted the full prose, equations, code and exercises. Tests read formal MDX only; removed temporary fallbacks/draft skips and updated review assertion to checked. Algorithm and independent references are unchanged; final record binds both locale hashes.
Source locations checked:
- STAT 9610 — Multiple testing · Sections30.1–30.2: union bound, largest passing BH rank, independent valid p-values and dependence qualifications.
- R stats — Adjust P-values for Multiple Comparisons · Details and References: Holm1979, BH1995, BY2001; harmonic correction and adjusted values. Development manual read, no R execution claimed.
Related topics