Algorithmcore
Hochberg procedure
Also called Hochberg step-up procedure.
A step-up form of Holm: find the largest k with p_(k) <= alpha / (m - k + 1) and reject H_(1) to H_(k). It controls the FWER when the Simes inequality holds, as under independence or MTP2.
- Time
- Θ(m log m) worst · best
- Space
- Θ(m) extra
- Where
- m = the number of hypotheses
- Model
- Real RAM
- Properties
- deterministicnot exactofflineiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Yosef Hochberg, R. John Simes, 1988
The Hochberg procedure uses the same thresholds as Holm's method, for the -th smallest p-value, but it reads the sorted list from the other end. It starts at the largest p-value and moves down until it finds a ; it then rejects . Each hypothesis that Holm rejects, Hochberg rejects too. The price is an assumption: the family-wise error rate is at most when the Simes inequality holds for the true nulls, which is the case under independence and under positive dependence of the MTP2 kind. Under negative dependence it can exceed . The adjusted p-value of is .
In plain words
Holm's method checks the strongest result first and stops at the first weak one. Hochberg's method checks the weakest result first. If even the weakest result passes the ordinary level, every result is accepted as real. If not, it drops that result and checks the next weakest against a level twice as strict, and so on. The first result that passes takes all the stronger results with it. This finds every effect that Holm finds, and sometimes more, but it is safe only when the tests do not pull against each other. With independent tests, or tests that tend to move together, the chance of any false alarm stays below the chosen level.
The problem
Input. P-values and a level . is the set of true nulls, , and are the sorted p-values.
Output. The rejected set with , or the empty set when there is no such ; and the adjusted p-values .
Error rate controlled. Strong control of the family-wise error rate, for every , under the condition below.
Dependence. The control holds whenever the null p-values satisfy the Simes inequality,
where is the -th smallest null p-value. This holds with equality for independent uniform null p-values (Simes 1986, proved on this page), for MTP2 p-values (Sarkar 1998), and for several positively dependent families, among them one-sided tests on equicorrelated normal statistics with nonnegative correlation (Sarkar and Chang 1997). The last two are cited, not proved. It fails for some negatively dependent laws. The control is exact in finite samples, as an inequality, under these conditions.
The algorithm
HOCHBERG(p₁, …, p_m, α) ▷ p-values in [0, 1], level α- 1
sort the indices so that p_(1) ≤ … ≤ p_(m) - 2
k ← m; while k ≥ 1 and (m − k + 1) · p_(k) > α do - 3
k ← k − 1 - 4
reject H_(1), …, H_(k) ▷ none when k = 0 - 5
run ← 1; for j ← m down to 1 do ▷ adjusted p-values - 6
run ← min(run, (m − j + 1) · p_(j)) - 7
p̃_(j) ← run - 8
return (rejected set, p̃)
Lines L2 and L3 move down from the largest p-value. The first that passes is the largest one, and every smaller rank is rejected with it, whatever its own comparison gives.
Example
Where Hochberg gains. For and at , Hochberg first checks , which holds, so it rejects both. Holm first checks , which fails, so it rejects neither.
Four p-values. at .
| threshold | Hochberg adjusted | Holm adjusted | |||
|---|---|---|---|---|---|
| 1 | 0.01 | 0.0125 | 0.04 | 0.04 | 0.04 |
| 2 | 0.02 | 0.016667 | 0.06 | 0.045 | 0.06 |
| 3 | 0.03 | 0.025 | 0.06 | 0.045 | 0.06 |
| 4 | 0.045 | 0.05 | 0.045 | 0.045 | 0.06 |
Line L2 checks first: holds, so Hochberg rejects all four. Holm passes , fails at and rejects one. The two columns of adjusted p-values come from the same products: Hochberg takes running minima from the bottom of the table, Holm running maxima from the top.
Fifteen p-values. On the 15 p-values of Benjamini and Hochberg (1995), line L2 checks , , and so on down to , and stops at . So and Hochberg rejects the same 3 as Holm. The adjusted p-values are 0.0015, 0.0056, 0.0247, 0.114, 0.2211, 0.2682, 0.2682, 0.2752, 0.3213, and 1 for the last six. They are at most Holm's, which are 0.278 instead of 0.2682 for the sixth and seventh and instead of 0.2752 for the eighth.
Correctness
Two facts give the control. The first is combinatorial: every hypothesis that Hochberg rejects is also rejected by the closed testing procedure that tests each intersection with the Simes test, "reject when for some ". With , at least elements of any that holds a rejected hypothesis have rank at most , so their p-values are at most , and gives the Simes condition. Taking , a false rejection implies that the Simes test rejects . The second fact is probabilistic: the Simes test of has level under the dependence conditions above. For independent uniform p-values this is an equality, proved by induction on the number of p-values, conditioning on the largest. The correctness proof gives both parts in full, and an exact two-hypothesis law with uniform marginals under which the family-wise error rate is . The tests check the inclusion against brute-force closed Simes testing over all subsets for , the equality by exact counting on a grid and by simulation, and the counterexample in exact arithmetic.
Proof: Hochberg's step-up procedure lies inside closed Simes testing, so it controls the family-wise error rate whenever the Simes inequality holdsfull
We prove that HOCHBERG computes the step-up rule and its adjusted p-values (Lemma 1), that it rejects every hypothesis Holm rejects (Theorem 1), that every hypothesis it rejects is rejected by closed testing with Simes local tests (Theorem 2), that the Simes test has size exactly for independent uniform p-values (Theorem 3), and hence that HOCHBERG controls the family-wise error rate strongly under independence (Corollary 4). The Simes inequality under MTP2 dependence (Sarkar 1998) and under other positive dependence (Sarkar and Chang 1997) is cited, not proved; Corollary 4 extends to those cases word for word. Finally we give a law under which the guarantee fails (Theorem 5). The tests check Theorems 1 and 2 against brute force, Theorem 3 by exact counting and simulation, and Theorem 5 in exact arithmetic.
Setting. P-values , sorted as by line L1; is the index of rank . is the set of true nulls, . For a nonempty set with , is the -th smallest of . The Simes test of rejects when for some . Fix .
Lemma 1 (what the lines compute). Lines L2 and L3 end with , or if there is no such , and line L4 rejects ranks . Lines L5 to L7 give , and rank is rejected if and only if .
Proof. The loop starts at and decreases while the test fails, so it stops at the largest that passes, or at 0. The running minimum starts at 1 and takes in the products from rank down, which is the formula. Rank is rejected if and only if , that is, if and only if some has ; since , this is .
Theorem 1 (Hochberg contains Holm). If Holm rejects , so does HOCHBERG.
Proof. Holm rejects the ranks , where every has . In particular rank passes, so in Lemma 1, and HOCHBERG rejects ranks .
Theorem 2 (Hochberg lies inside closed Simes testing). Suppose HOCHBERG rejects hypotheses, and let be any set that contains a rejected hypothesis. Then the Simes test rejects .
Proof. Let , so that by Lemma 1, and let . At most indices have rank above , so at least elements of have rank at most . Also at least one does, the rejected hypothesis in . Let . Then at least elements of have p-values at most , so . It remains to show , that is, .
- If , then and .
- If , then and , since and .
In both cases , so the Simes test rejects .
So with : if HOCHBERG rejects any true null, then contains a rejected hypothesis, and the Simes test of the null p-values rejects . Hence
Theorem 2 also says that every Hochberg rejection is a rejection of the closed procedure with Simes local tests, which is Hommel's procedure; the closed testing principle gives the same bound (1). Only the Simes test of the one set matters.
Theorem 3 (Simes 1986). Let be independent and uniform on , and . Then .
Proof. By induction on . For the event is , of probability . Let and assume the claim for and every level in . Let , which has density on . Given , the other values are independent and uniform on ; after division by they are independent and uniform on , with order statistics .
- If , the event holds with .
- If , the condition at fails, and for it reads , that is, with . Since , , so by the induction hypothesis the conditional probability is .
So
Corollary 4 (strong control under independence). If the null p-values are independent and uniform, HOCHBERG has for every , whatever the false null p-values are and however they depend on the null ones.
Proof. Bound (1) involves only the null p-values, and Theorem 3 with shows that its right side equals .
If the null p-values are only valid, , and independent, then each is stochastically larger than a uniform, the Simes event is a decreasing event in the p-values, and its probability is at most the uniform value . The tests confirm that on grids of discrete uniform p-values the probability is at most , with equality for when both thresholds are grid points. Under MTP2 dependence the right side of (1) is at most by Sarkar (1998), and for the positively dependent families of Sarkar and Chang (1997) as well; with those cited results Corollary 4 holds for them.
Theorem 5 (failure under negative dependence). Let and . There is a joint law of with uniform marginals under which HOCHBERG has , while Holm has .
Proof. Split into , and , of lengths , and . Let the pair fall in with probability , in with probability , in with probability and in with probability , uniformly inside each block. The mass of in is , in is , and in is , each spread uniformly, so is uniform; the same holds for . HOCHBERG rejects something when or . The first event is , and the second is ; they are disjoint, so the error rate is . Holm rejects something only when , which has probability .
The tests build this law on the grid with and confirm both numbers exactly.
Termination and cost. The sort terminates, and the two loops run at most times each with constant work per step.
Complexity
On a real RAM, the sort at line L1 takes comparisons, and lines L2 to L7 take . So the time is , or on sorted input. The extra space is . Closed Simes testing over all intersections is exponential; the usual algorithm for Hommel's procedure reduces it to time, and Hochberg is a fast and slightly conservative shortcut of it.
Numerical stability. As for Holm, compare products with , so that the rejections agree with the adjusted p-values in floating point, and compute small p-values from the upper tail directly.
Properties
- Strong FWER control under the Simes condition. Proved for independent p-values; cited for MTP2 and positively dependent normal statistics.
- More powerful than Holm. The rejected set always contains Holm's, and is at most Holm's adjusted p-value.
- Less powerful than Hommel. Every Hochberg rejection is a rejection of closed Simes testing, which can reject more.
- Step-up. One p-value that passes its threshold carries all smaller p-values with it, even those above their own thresholds.
- Not valid under arbitrary dependence. For two hypotheses there is a law with uniform marginals and family-wise error rate .
- Monotone. Lowering any p-value never removes a rejection.
Variants and improvements
- Hommel's procedure. Closed testing with Simes local tests, from Hommel (1988). It rejects at least as much as Hochberg under the same conditions. See the closed testing principle.
- The Simes global test. Reject the global null when for some . It is the local test inside Hochberg's and Hommel's methods, and its rule is the one of the Benjamini-Hochberg procedure, which uses it for each to control a different error rate.
- Rom's procedure. Rom (1990) replaced Hochberg's thresholds with slightly larger ones computed so that the error rate is exactly under independence.
- Under arbitrary dependence. Use Holm's method, or the Hommel-type correction of the Simes test by the factor , the same factor as in the Benjamini-Yekutieli procedure.
When to use it
Use Hochberg instead of Holm when the test statistics are independent or positively dependent, for example one-sided tests of several treatments against a shared control, which are positively correlated. The gain is largest when most of the p-values are moderately small, so that the largest one already passes. When the dependence is unknown or can be negative, as for two-sided tests on correlated statistics with no further structure, use Holm. When raw data are available, the Westfall-Young procedure often gains more than either.
Pitfalls
- Two-sided tests. Positive dependence of the statistics does not always carry over to two-sided p-values, which are functions of absolute values. Check that the Simes inequality is known to hold for the family at hand before using Hochberg.
- Reading the rule as Holm's. Hochberg's comparison runs from the largest p-value down, and the first success rejects all smaller ones. Stopping at the first failure from the bottom gives Holm's method.
- Adjusted p-values with the wrong running extreme. Hochberg uses running minima from the largest p-value; Holm uses running maxima from the smallest. Mixing them gives adjusted p-values that do not match either rule.
- Claiming the gain without the condition. If a reviewer cannot check that the Simes inequality holds, report Holm.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/hochberg-procedure/. The authors are listed in prov/T4RCRV.jsonl.
"""Hochberg's step-up procedure for m hypotheses.
Sort the p-values, p_(1) <= ... <= p_(m). Find the largest k with
p_(k) <= alpha / (m - k + 1) and reject H_(1), ..., H_(k). The adjusted p-value of
H_(k) is min over j >= k of min(1, (m - j + 1) p_(j)). The family-wise error rate is
at most alpha when the Simes inequality holds for the true nulls, for example under
independence or MTP2 dependence; it can exceed alpha under negative dependence.
The code works with floats or with fractions.Fraction.
"""
from collections.abc import Sequence
def hochberg(p: Sequence, alpha) -> tuple[list[bool], list]:
"""Return (reject, adjusted) in the original order of p."""
m = len(p)
if m == 0:
return [], []
if any(not 0 <= v <= 1 for v in p):
raise ValueError("p-values must lie in [0, 1]")
if not 0 <= alpha <= 1:
raise ValueError("alpha must lie in [0, 1]")
order = sorted(range(m), key=lambda i: p[i]) # @line L1
k = m # number of rejections; ranks are 1-based here
while k >= 1 and (m - k + 1) * p[order[k - 1]] > alpha: # @line L2
k -= 1 # @line L3
reject = [False] * m
for r in range(k): # @line L4
reject[order[r]] = True
adjusted = [0] * m
running = 1
for r in range(m - 1, -1, -1): # @line L5
running = min(running, (m - r) * p[order[r]]) # @line L6
adjusted[order[r]] = running # @line L7
return reject, adjusted # @line L8
test_hochberg_procedure.py 160 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/hochberg-procedure/. The authors are listed in prov/T4RCRV.jsonl.
import itertools
import math
import random
import statistics
from fractions import Fraction
import pytest
from hochberg_procedure import hochberg
BH95 = [0.0001, 0.0004, 0.0019, 0.0095, 0.0201, 0.0278, 0.0298, 0.0344, 0.0459, 0.3240, 0.4262, 0.5719, 0.6528, 0.7590, 1.000]
def holm_reference(p: list, alpha) -> list[bool]:
"""Holm's step-down rule, written out directly, as the reference for the power comparison."""
m = len(p)
order = sorted(range(m), key=lambda i: p[i])
reject = [False] * m
for k, i in enumerate(order):
if (m - k) * p[i] > alpha:
break
reject[i] = True
return reject
def simes_rejects(values: list, alpha) -> bool:
"""The Simes test of an intersection: reject when p_(j) <= j alpha / n for some j."""
n = len(values)
return any(v * n <= (j + 1) * alpha for j, v in enumerate(sorted(values)))
def closed_simes(p: list, alpha) -> list[bool]:
"""Brute force: closed testing with Simes local tests (Hommel's procedure), over all 2^m - 1 subsets."""
m = len(p)
subsets = [s for size in range(1, m + 1) for s in itertools.combinations(range(m), size)]
local = {s: simes_rejects([p[j] for j in s], alpha) for s in subsets}
return [all(local[s] for s in subsets if i in s) for i in range(m)]
def test_hochberg_beats_holm_by_hand() -> None:
reject, adjusted = hochberg([0.04, 0.045], 0.05)
# Step-up: p_(2) = 0.045 <= 0.05 / 1, so both are rejected. Holm stops at 0.04 > 0.05 / 2.
assert reject == [True, True]
assert holm_reference([0.04, 0.045], 0.05) == [False, False]
assert adjusted == pytest.approx([0.045, 0.045])
def test_worked_example_by_hand() -> None:
reject, adjusted = hochberg(BH95, 0.05)
# From the top: 1.000 > 0.05, 0.7590 > 0.025, ..., 0.0095 > 0.05/12; then 0.0019 <= 0.05/13.
assert [i for i, r in enumerate(reject) if r] == [0, 1, 2]
assert adjusted[:4] == pytest.approx([0.0015, 0.0056, 0.0247, 0.114])
assert adjusted[-1] == 1
def test_exact_fractions() -> None:
p = [Fraction(1, 10), Fraction(1, 50), Fraction(3, 100), Fraction(1, 30)]
reject, adjusted = hochberg(p, Fraction(1, 10))
# Sorted: 1/50, 3/100, 1/30, 1/10 against 1/40, 1/30, 1/20, 1/10. The largest passes, so all are rejected.
assert reject == [True, True, True, True]
# Products (m - k + 1) p_(k): 2/25, 9/100, 1/15, 1/10; the running minimum from the top gives these.
assert adjusted == [Fraction(1, 10), Fraction(1, 15), Fraction(1, 15), Fraction(1, 15)]
def test_superset_of_holm_and_subset_of_closed_simes() -> None:
rng = random.Random(1988)
for _ in range(400):
m = rng.randint(1, 7)
p = [Fraction(rng.randint(0, 100), 100) ** 2 for _ in range(m)]
alpha = Fraction(rng.randint(1, 20), 100)
reject, _ = hochberg(p, alpha)
holm = holm_reference(p, alpha)
hommel = closed_simes(p, alpha)
assert all(r or not h for r, h in zip(reject, holm)) # Holm's rejections are kept
assert all(h or not r for r, h in zip(reject, hommel)) # every Hochberg rejection is a closed Simes rejection
def test_at_least_as_powerful_as_holm_on_many_float_vectors() -> None:
rng = random.Random(3)
for _ in range(5000):
m = rng.randint(1, 30)
p = [rng.random() ** 4 for _ in range(m)]
reject = hochberg(p, 0.05)[0]
assert sum(reject) >= sum(holm_reference(p, 0.05))
assert all(r or not h for r, h in zip(reject, holm_reference(p, 0.05)))
def test_adjusted_p_values_match_rejections() -> None:
rng = random.Random(4)
for _ in range(300):
m = rng.randint(1, 10)
p = [Fraction(rng.randint(0, 200), 200) for _ in range(m)]
_, adjusted = hochberg(p, Fraction(1, 20))
for alpha in [Fraction(k, 100) for k in range(0, 100, 3)]:
assert hochberg(p, alpha)[0] == [a <= alpha for a in adjusted]
def test_invalid_input() -> None:
assert hochberg([], 0.05) == ([], [])
with pytest.raises(ValueError):
hochberg([0.5, 2], 0.05)
def test_exact_fwer_under_independence_on_grids() -> None:
"""Global null, independent p-values uniform on {1/N, ..., 1}, every threshold on the grid; all N^m cases."""
for m, n_grid, alpha in [(2, 10, Fraction(2, 5)), (3, 20, Fraction(3, 10))]:
grid = [Fraction(k, n_grid) for k in range(1, n_grid + 1)]
hits = sum(any(hochberg(list(p), alpha)[0]) for p in itertools.product(grid, repeat=m))
fwer = Fraction(hits, n_grid**m)
assert fwer <= alpha
if m == 2:
# P(max <= 2/5) + P(min <= 1/5 < 2/5 < max) = 16/100 + 24/100: the Simes bound is attained.
assert fwer == alpha
def test_monte_carlo_simes_equality_under_independence() -> None:
rng = random.Random(1986)
m, alpha, reps = 5, 0.1, 30000
hits = sum(any(hochberg([rng.random() for _ in range(m)], alpha)[0]) for _ in range(reps))
# Simes (1986): exactly alpha for continuous independent p-values. Four standard errors are 0.0069.
assert abs(hits / reps - alpha) < 0.0069
def test_monte_carlo_positive_dependence() -> None:
"""One-sided tests on equicorrelated normals with rho = 0.5 (an MTP2 case), m_0 = 6 of m = 8."""
rng = random.Random(1998)
nd = statistics.NormalDist()
m, m0, alpha, reps, errors = 8, 6, 0.05, 15000, 0
for _ in range(reps):
shared = rng.gauss(0, 1)
z = [math.sqrt(0.5) * shared + math.sqrt(0.5) * rng.gauss(0, 1) + (3.5 if i >= m0 else 0.0) for i in range(m)]
errors += any(hochberg([1 - nd.cdf(v) for v in z], alpha)[0][:m0])
assert errors / reps <= alpha + 0.0054 # three standard errors
def test_negative_dependence_breaks_the_guarantee_exactly() -> None:
"""A joint law of two uniform p-values on {1/40, ..., 1} under which Hochberg has FWER 3 alpha / 2.
With alpha = 1/10: B = {1/40, 2/40} (at most alpha/2), A = {3/40, 4/40} (in (alpha/2, alpha]) and C the other 36 points.
The pair falls in A x A with probability 1/20, in B x C with 1/20, in C x B with 1/20 and in C x C with 17/20,
uniformly inside each block. Both marginals are uniform on the grid.
"""
alpha = Fraction(1, 10)
grid = [Fraction(k, 40) for k in range(1, 41)]
b_set, a_set, c_set = grid[:2], grid[2:4], grid[4:]
law: dict[tuple, Fraction] = {}
for block, mass in [((a_set, a_set), Fraction(1, 20)), ((b_set, c_set), Fraction(1, 20)), ((c_set, b_set), Fraction(1, 20)), ((c_set, c_set), Fraction(17, 20))]:
cells = list(itertools.product(*block))
for cell in cells:
law[cell] = law.get(cell, 0) + mass / len(cells)
for coord in (0, 1):
for g in grid:
assert sum(w for cell, w in law.items() if cell[coord] == g) == Fraction(1, 40)
fwer_hochberg = sum(w for cell, w in law.items() if any(hochberg(list(cell), alpha)[0]))
fwer_holm = sum(w for cell, w in law.items() if any(holm_reference(list(cell), alpha)))
assert fwer_hochberg == Fraction(3, 2) * alpha
assert fwer_holm == alpha
History
Simes (1986) proposed a global test that rejects the intersection of all nulls when for some , and proved that its size is exactly for independent tests. He also suggested using it to reject single hypotheses, without a proof of control. Hochberg (1988) gave the step-up rule with Holm's thresholds and proved strong control through closed testing with Simes local tests, and in the same year Hommel published the full closed Simes procedure. Whether the Simes inequality holds under positive dependence was open for some years. Sarkar and Chang (1997) proved it for a class of positively dependent statistics, and Sarkar (1998) proved it for MTP2 p-values, the "Simes conjecture".
References
- Yosef Hochberg, A sharper Bonferroni procedure for multiple tests of significance, Biometrika 75(4) (1988), pages 800 to 802, the step-up procedure with thresholds alpha / (m - k + 1), and its family-wise error control through closed testing with Simes tests
- R. J. Simes, An improved Bonferroni procedure for multiple tests of significance, Biometrika 73(3) (1986), pages 751 to 754, the global test that rejects when p_(j) <= j alpha / n for some j, of size exactly alpha for independent continuous p-values
- G. Hommel, A stagewise rejective multiple test procedure based on a modified Bonferroni test, Biometrika 75(2) (1988), pages 383 to 386, closed testing with Simes local tests, which rejects at least as much as Hochberg
- Sanat K. Sarkar and Chung-Kuei Chang, The Simes method for multiple hypothesis testing with positively dependent test statistics, Journal of the American Statistical Association 92(440) (1997), pages 1601 to 1608, the Simes inequality for positively dependent statistics, including equicorrelated normal and t statistics
- Sanat K. Sarkar, Some probability inequalities for ordered MTP2 random variables, a proof of the Simes conjecture, The Annals of Statistics 26(2) (1998), pages 494 to 504, the Simes inequality for p-values that are multivariate totally positive of order 2
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag T4RCRV Edit this page History Report an error Markdown