Algorithm Search⌘K

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
Properties
deterministicnot exactofflineiterative
Origin
Yosef Hochberg, R. John Simes, 1988

The Hochberg procedure uses the same thresholds as Holm's method, α/(m−k+1)\alpha/(m - k + 1) for the kk-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 p(k)≤α/(m−k+1)p_{(k)} \le \alpha/(m - k + 1); it then rejects H(1),…,H(k)H_{(1)}, \dots, H_{(k)}. Each hypothesis that Holm rejects, Hochberg rejects too. The price is an assumption: the family-wise error rate is at most α\alpha 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 α\alpha. The adjusted p-value of H(k)H_{(k)} is min⁡j≥kmin⁡(1,(m−j+1)p(j))\min_{j \ge k}\min(1, (m - j + 1)p_{(j)}).

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 p1,…,pmp_1, \dots, p_m and a level α∈(0,1)\alpha \in (0, 1). I0I_0 is the set of true nulls, m0=∣I0∣m_0 = |I_0|, and p(1)≤⋯≤p(m)p_{(1)} \le \dots \le p_{(m)} are the sorted p-values.

Output. The rejected set {H(1),…,H(r)}\{H_{(1)}, \dots, H_{(r)}\} with r=max⁡{k:p(k)≤α/(m−k+1)}r = \max\{k : p_{(k)} \le \alpha/(m - k + 1)\}, or the empty set when there is no such kk; and the adjusted p-values p~(k)=min⁡j≥kmin⁡(1,(m−j+1)p(j))\tilde p_{(k)} = \min_{j \ge k}\min(1, (m - j + 1)p_{(j)}).

Error rate controlled. Strong control of the family-wise error rate, P(V≥1)≤αP(V \ge 1) \le \alpha for every I0I_0, under the condition below.

Dependence. The control holds whenever the null p-values satisfy the Simes inequality,

P(p(j:I0)≤jαm0 for some j)≤α,P\Big(p_{(j:I_0)} \le \frac{j\alpha}{m_0} \text{ for some } j\Big) \le \alpha,

where p(j:I0)p_{(j:I_0)} is the jj-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

  1. HOCHBERG(p₁, …, p_m, α) ▷ p-values in [0, 1], level α
  2. 1sort the indices so that p_(1) ≤ … ≤ p_(m)
  3. 2k ← m; while k ≥ 1 and (m − k + 1) · p_(k) > α do
  4. 3k ← k − 1
  5. 4reject H_(1), …, H_(k) ▷ none when k = 0
  6. 5run ← 1; for j ← m down to 1 do ▷ adjusted p-values
  7. 6run ← min(run, (m − j + 1) · p_(j))
  8. 7p̃_(j) ← run
  9. 8return (rejected set, p̃)

Lines L2 and L3 move down from the largest p-value. The first kk that passes is the largest one, and every smaller rank is rejected with it, whatever its own comparison gives.

Example

Where Hochberg gains. For p=0.04p = 0.04 and 0.0450.045 at α=0.05\alpha = 0.05, Hochberg first checks 0.045≤0.05/10.045 \le 0.05/1, which holds, so it rejects both. Holm first checks 0.04≤0.05/2=0.0250.04 \le 0.05/2 = 0.025, which fails, so it rejects neither.

Four p-values. 0.01,0.02,0.03,0.0450.01, 0.02, 0.03, 0.045 at α=0.05\alpha = 0.05.

kk p(k)p_{(k)} threshold α/(m−k+1)\alpha/(m - k + 1) (m−k+1)p(k)(m - k + 1)p_{(k)} 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 k=4k = 4 first: 0.045≤0.050.045 \le 0.05 holds, so Hochberg rejects all four. Holm passes k=1k = 1, fails at k=2k = 2 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 1.000>0.051.000 > 0.05, 0.7590>0.0250.7590 > 0.025, and so on down to 0.0095>0.05/12=0.0041670.0095 > 0.05/12 = 0.004167, and stops at 0.0019≤0.05/13=0.0038460.0019 \le 0.05/13 = 0.003846. So k=3k = 3 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 HIH_I with the Simes test, "reject when p(j:I)≤jα/∣I∣p_{(j:I)} \le j\alpha/|I| for some jj". With a=m−r+1a = m - r + 1, at least max⁡(1,∣I∣−a+1)\max(1, |I| - a + 1) elements of any II that holds a rejected hypothesis have rank at most rr, so their p-values are at most p(r)≤α/ap_{(r)} \le \alpha/a, and (a−1)(∣I∣−a)≥0(a - 1)(|I| - a) \ge 0 gives the Simes condition. Taking I=I0I = I_0, a false rejection implies that the Simes test rejects HI0H_{I_0}. The second fact is probabilistic: the Simes test of HI0H_{I_0} has level α\alpha 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 3α/23\alpha/2. The tests check the inclusion against brute-force closed Simes testing over all subsets for m≤7m \le 7, 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 α\alpha 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 p1,…,pmp_1, \dots, p_m, sorted as p(1)≤⋯≤p(m)p_{(1)} \le \dots \le p_{(m)} by line L1; (k)(k) is the index of rank kk. I0I_0 is the set of true nulls, m0=∣I0∣m_0 = |I_0|. For a nonempty set II with n=∣I∣n = |I|, p(j:I)p_{(j:I)} is the jj-th smallest of {pi:i∈I}\{p_i : i \in I\}. The Simes test of HIH_I rejects when p(j:I)≤jα/np_{(j:I)} \le j\alpha/n for some j∈{1,…,n}j \in \{1, \dots, n\}. Fix 0<α<10 < \alpha < 1.

Lemma 1 (what the lines compute). Lines L2 and L3 end with k=r=max⁡{k:(m−k+1)p(k)≤α}k = r = \max\{k : (m - k + 1)p_{(k)} \le \alpha\}, or r=0r = 0 if there is no such kk, and line L4 rejects ranks 1,…,r1, \dots, r. Lines L5 to L7 give p~(j)=min⁡l≥jmin⁡(1,(m−l+1)p(l))\tilde p_{(j)} = \min_{l \ge j}\min(1, (m - l + 1)p_{(l)}), and rank jj is rejected if and only if p~(j)≤α\tilde p_{(j)} \le \alpha.

Proof. The loop starts at k=mk = m and decreases kk while the test fails, so it stops at the largest kk that passes, or at 0. The running minimum starts at 1 and takes in the products from rank mm down, which is the formula. Rank jj is rejected if and only if j≤rj \le r, that is, if and only if some l≥jl \ge j has (m−l+1)p(l)≤α(m - l + 1)p_{(l)} \le \alpha; since α<1\alpha < 1, this is p~(j)≤α\tilde p_{(j)} \le \alpha. □\square

Theorem 1 (Hochberg contains Holm). If Holm rejects HiH_i, so does HOCHBERG.

Proof. Holm rejects the ranks 1,…,s1, \dots, s, where every j≤sj \le s has (m−j+1)p(j)≤α(m - j + 1)p_{(j)} \le \alpha. In particular rank ss passes, so r≥sr \ge s in Lemma 1, and HOCHBERG rejects ranks 1,…,r⊇{1,…,s}1, \dots, r \supseteq \{1, \dots, s\}. □\square

Theorem 2 (Hochberg lies inside closed Simes testing). Suppose HOCHBERG rejects r≥1r \ge 1 hypotheses, and let II be any set that contains a rejected hypothesis. Then the Simes test rejects HIH_I.

Proof. Let a=m−r+1a = m - r + 1, so that p(r)≤α/ap_{(r)} \le \alpha/a by Lemma 1, and let n=∣I∣n = |I|. At most m−r=a−1m - r = a - 1 indices have rank above rr, so at least n−a+1n - a + 1 elements of II have rank at most rr. Also at least one does, the rejected hypothesis in II. Let j=max⁡(1,n−a+1)j = \max(1, n - a + 1). Then at least jj elements of II have p-values at most p(r)p_{(r)}, so p(j:I)≤p(r)≤α/ap_{(j:I)} \le p_{(r)} \le \alpha/a. It remains to show α/a≤jα/n\alpha/a \le j\alpha/n, that is, n≤jan \le ja.

  • If n≤an \le a, then j=1j = 1 and n≤a=jan \le a = ja.
  • If n>an > a, then j=n−a+1j = n - a + 1 and ja−n=(n−a+1)a−n=(a−1)(n−a)≥0ja - n = (n - a + 1)a - n = (a - 1)(n - a) \ge 0, since a≥1a \ge 1 and n>an > a.

In both cases p(j:I)≤jα/np_{(j:I)} \le j\alpha/n, so the Simes test rejects HIH_I. □\square

So with I=I0I = I_0: if HOCHBERG rejects any true null, then I0I_0 contains a rejected hypothesis, and the Simes test of the null p-values rejects HI0H_{I_0}. Hence

P(V≥1)≤P(p(j:I0)≤jα/m0 for some j).(1)P(V \ge 1) \le P\big(p_{(j:I_0)} \le j\alpha/m_0 \text{ for some } j\big). \tag{1}

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 I0I_0 matters.

Theorem 3 (Simes 1986). Let U1,…,UnU_1, \dots, U_n be independent and uniform on (0,1)(0, 1), and 0≤α≤10 \le \alpha \le 1. Then P(U(j)≤jα/n for some j)=αP(U_{(j)} \le j\alpha/n \text{ for some } j) = \alpha.

Proof. By induction on nn. For n=1n = 1 the event is U1≤αU_1 \le \alpha, of probability α\alpha. Let n≥2n \ge 2 and assume the claim for n−1n - 1 and every level in [0,1][0, 1]. Let M=U(n)M = U_{(n)}, which has density nun−1nu^{n-1} on (0,1)(0, 1). Given M=uM = u, the other n−1n - 1 values are independent and uniform on (0,u)(0, u); after division by uu they are independent and uniform on (0,1)(0, 1), with order statistics W(1)≤⋯≤W(n−1)W_{(1)} \le \dots \le W_{(n-1)}.

  • If u≤αu \le \alpha, the event holds with j=nj = n.
  • If u>αu > \alpha, the condition at j=nj = n fails, and for j<nj < n it reads uW(j)≤jα/nuW_{(j)} \le j\alpha/n, that is, W(j)≤jα′/(n−1)W_{(j)} \le j\alpha'/(n - 1) with α′=α(n−1)/(nu)\alpha' = \alpha(n - 1)/(nu). Since u>αu > \alpha, α′<1\alpha' < 1, so by the induction hypothesis the conditional probability is α′\alpha'.

So

P=∫0αnun−1 du+∫α1nun−1⋅α(n−1)nu du=αn+α(n−1)∫α1un−2 du=αn+α(1−αn−1)=α.□P = \int_0^\alpha nu^{n-1}\,du + \int_\alpha^1 nu^{n-1}\cdot\frac{\alpha(n - 1)}{nu}\,du = \alpha^n + \alpha(n - 1)\int_\alpha^1 u^{n-2}\,du = \alpha^n + \alpha(1 - \alpha^{n-1}) = \alpha. \qquad \square

Corollary 4 (strong control under independence). If the null p-values are independent and uniform, HOCHBERG has P(V≥1)≤αP(V \ge 1) \le \alpha for every I0I_0, 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 n=m0n = m_0 shows that its right side equals α\alpha. □\square

If the null p-values are only valid, P(pi≤u)≤uP(p_i \le u) \le u, 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 α\alpha. The tests confirm that on grids of discrete uniform p-values the probability is at most α\alpha, with equality for m=2m = 2 when both thresholds are grid points. Under MTP2 dependence the right side of (1) is at most α\alpha 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 m=m0=2m = m_0 = 2 and 0<α≤1/20 < \alpha \le 1/2. There is a joint law of (p1,p2)(p_1, p_2) with uniform marginals under which HOCHBERG has P(V≥1)=3α/2P(V \ge 1) = 3\alpha/2, while Holm has P(V≥1)=αP(V \ge 1) = \alpha.

Proof. Split (0,1](0, 1] into B=(0,α/2]B = (0, \alpha/2], A=(α/2,α]A = (\alpha/2, \alpha] and C=(α,1]C = (\alpha, 1], of lengths α/2\alpha/2, α/2\alpha/2 and 1−α1 - \alpha. Let the pair fall in A×AA \times A with probability α/2\alpha/2, in B×CB \times C with probability α/2\alpha/2, in C×BC \times B with probability α/2\alpha/2 and in C×CC \times C with probability 1−3α/21 - 3\alpha/2, uniformly inside each block. The mass of p1p_1 in BB is α/2\alpha/2, in AA is α/2\alpha/2, and in CC is α/2+1−3α/2=1−α\alpha/2 + 1 - 3\alpha/2 = 1 - \alpha, each spread uniformly, so p1p_1 is uniform; the same holds for p2p_2. HOCHBERG rejects something when max⁡(p1,p2)≤α\max(p_1, p_2) \le \alpha or min⁡(p1,p2)≤α/2\min(p_1, p_2) \le \alpha/2. The first event is A×AA \times A, and the second is B×C∪C×BB \times C \cup C \times B; they are disjoint, so the error rate is 3α/23\alpha/2. Holm rejects something only when min⁡(p1,p2)≤α/2\min(p_1, p_2) \le \alpha/2, which has probability α\alpha. □\square

The tests build this law on the grid {1/40,…,40/40}\{1/40, \dots, 40/40\} with α=1/10\alpha = 1/10 and confirm both numbers exactly.

Termination and cost. The sort terminates, and the two loops run at most mm times each with constant work per step.

Complexity

On a real RAM, the sort at line L1 takes Θ(mlog⁡m)\Theta(m\log m) comparisons, and lines L2 to L7 take Θ(m)\Theta(m). So the time is Θ(mlog⁡m)\Theta(m\log m), or Θ(m)\Theta(m) on sorted input. The extra space is Θ(m)\Theta(m). Closed Simes testing over all 2m−12^m - 1 intersections is exponential; the usual algorithm for Hommel's procedure reduces it to Θ(m2)\Theta(m^2) time, and Hochberg is a fast and slightly conservative shortcut of it.

Numerical stability. As for Holm, compare products (m−k+1)p(k)(m - k + 1)p_{(k)} with α\alpha, 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 p~i\tilde p_i 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 3α/23\alpha/2.
  • 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 p(j)≤jα/mp_{(j)} \le j\alpha/m for some jj. 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 kk 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 α\alpha under independence.
  • Under arbitrary dependence. Use Holm's method, or the Hommel-type correction of the Simes test by the factor ∑i=1m1/i\sum_{i=1}^m 1/i, 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.

hochberg_procedure.pyI0RawGitHub
# 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 p(j)≤jα/mp_{(j)} \le j\alpha/m for some jj, and proved that its size is exactly α\alpha 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

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.best
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example