intermediate 60 min read · October 22, 2026

Empirical Bayes

Learning the prior from the ensemble. Topic 28 fit a Normal prior's two hyperparameters; Topic 33 leaves the prior unrestricted and either bypasses it — Robbins' formula and Tweedie's formula — or estimates it outright with the Kiefer–Wolfowitz NPMLE. Six full proofs: Tweedie's formula (featured), the compound-decision theorem, Robbins' formula, exponential-family Tweedie, the selection invariance of the Bayes rule, and the average coverage of empirical-Bayes intervals. Auto-insurance claims and 6,033 prostate-cancer z-scores as the spine datasets; the winner's curse, local false discovery rates, and the score-matching identity behind diffusion models as the ML payoff. The nonparametric coda to Track 7.

33.1 Motivation: the winner’s curse

Suppose we tune a model by trying 1,000 hyperparameter configurations and scoring each one once on a held-out validation set. The configuration at the top of the leaderboard looks excellent. Score it again on fresh data and it almost always looks worse. Nothing is wrong with that configuration; what went wrong is the ranking. Every validation score is a true quality plus noise, and the top of a ranked list is exactly where the noise has piled up in the flattering direction. This is the winner’s curse, and it is the oldest problem empirical Bayes solves.

Here is the notation we’ll use for the rest of the topic. Write θi\theta_i for the true score of configuration ii — what we would see with an infinitely large validation set — and xix_i for the score we actually observed. The simplest honest model of the noise is

xi=θi+εi,εi∼N(0,σ2),x_i = \theta_i + \varepsilon_i, \qquad \varepsilon_i \sim \mathcal{N}(0, \sigma^2),

independently across ii. Read εi∼N(0,σ2)\varepsilon_i \sim \mathcal{N}(0, \sigma^2) as “the error εi\varepsilon_i is drawn from a Normal distribution with mean 0 and variance σ2\sigma^2.” We treat the noise level σ\sigma as known; for a validation accuracy p^\hat p computed on nvaln_{\text{val}} examples it is about p^(1−p^)/nval\sqrt{\hat p(1 - \hat p)/n_{\text{val}}}. Equivalently, xi∣θi∼N(θi,σ2)x_i \mid \theta_i \sim \mathcal{N}(\theta_i, \sigma^2): given the true score, the observation scatters symmetrically around it. Throughout, E[⋅]E[\cdot] is an expectation (a probability-weighted average) and Var(⋅)\mathrm{Var}(\cdot) is a variance (the average squared distance from the mean). The true scores themselves vary across configurations according to some distribution gg — most configurations are mediocre, a few are good — and gg is exactly what we will not know.

Example 1 Leaderboard winner's curse

Take N=1000N = 1000 configurations whose true scores follow g=0.9 N(0,0.32)+0.1 N(2.5,0.52)g = 0.9\,\mathcal{N}(0, 0.3^2) + 0.1\,\mathcal{N}(2.5, 0.5^2) — 90% baseline configurations clustered near 0 and 10% genuinely better ones near 2.5 — with validation noise σ=1\sigma = 1. Rank by observed score and keep the top 20. On average, their observed scores overstate their true scores by +1.41.

Two corrections, previewed here and justified in §33.4–§33.5:

  • The oracle Bayes rule E[θ∣x]E[\theta \mid x], which knows gg, overstates the top 20 by only +0.08.
  • Tweedie’s formula with an estimated marginal — a Gaussian kernel density estimate (bandwidth h=0.35h = 0.35) fit to the 1,000 observed scores, with gg unknown — overstates them by +0.21.

The leaderboard also hides an impostor: the configuration at rank 13 has true score 0.47. It is a baseline configuration that got lucky on the validation draw.

Two panels. Left: a scatter of observed score against true score for 1,000 simulated configurations; the top 20 by observed score are highlighted in amber and sit below the dashed diagonal theta equals x; the oracle Bayes curve, E of theta given x, bends below the diagonal. Right: the top 20 configurations by rank, showing observed scores (amber circles, mean gap plus 1.41), Tweedie with a KDE marginal (sky triangles, plus 0.21), the oracle Bayes rule (gray diamonds, plus 0.08), and the true scores (emerald squares).

Figure 1. The winner’s curse on a simulated leaderboard. Selected winners sit below the diagonal; the oracle Bayes rule and Tweedie’s formula with an estimated marginal both deflate them.

The second spine dataset is genomic. Singh et al. (SIN2002) measured the expression of 6,033 genes on 102 men — 50 healthy controls and 52 prostate-cancer patients. For each gene, a two-sample tt-statistic converted to a zz-score ziz_i measures how differently that gene behaves in the two groups (the file ships with EFR2016). A gene with no effect has zi∼N(0,1)z_i \sim \mathcal{N}(0, 1); a gene with effect μi\mu_i has, to a good approximation, zi∼N(μi,1)z_i \sim \mathcal{N}(\mu_i, 1). The largest of the 6,033 zz-scores is z=5.29z = 5.29. How big is that gene’s effect, really? It was selected because it is the largest, so, like the leaderboard winner, it is almost certainly overestimated. We answer the question in §33.5 Example 8.

When we face many parallel estimation problems at once — thousands of genes, hundreds of model configurations, every policy holder in an insurance book — the ensemble of observations carries information about the prior that no single observation does, and empirical Bayes is the discipline of learning that prior from the data it governs. Topic 28 did the parametric half, fitting a Normal prior’s two hyperparameters by Type-II maximum likelihood; Topic 33 takes the nonparametric half, where the prior gg is left unrestricted and is either bypassed (f-modeling: Robbins’ formula and Tweedie’s formula) or estimated outright (g-modeling: the Kiefer–Wolfowitz NPMLE). The organizing picture is geometric: under Normal noise the Bayes rule is the identity plus a shrinkage vector field equal to the score of the marginal density, x+σ2(log⁡f)′(x)x + \sigma^2 (\log f)'(x), so every correction points uphill on ff and can be estimated without ever naming gg. That one identity explains why the best-looking model on a leaderboard is overestimated and how to deflate it, why James–Stein is a special case rather than a paradox, why local false-discovery rates are an empirical-Bayes computation, and why a diffusion model’s denoiser is trained by score matching.

The spine of the topic runs Robbins (§33.3) → Tweedie (§33.4–§33.5) → the nonparametric MLE of the prior (§33.6), then compares the two strategies (§33.7), re-reads large-scale testing as empirical Bayes (§33.8), and ends with what empirical-Bayes confidence intervals do and do not promise (§33.9).

Remark 1 What Topic 28 did and what this topic does

Topic 28 learned the two hyperparameters (μ,τ2)(\mu, \tau^2) of a Normal prior θk∼N(μ,τ2)\theta_k \sim \mathcal{N}(\mu, \tau^2) by maximizing the marginal likelihood — Type-II maximum likelihood, §28.7. James–Stein (§28.5) was the striking special case: shrinking d≥3d \geq 3 Normal means toward a common point beats the MLE for every configuration of the means. Nothing here re-proves any of that. What changes is that gg is no longer forced to be Normal — it can be spiky, skewed, or multimodal, which is what real ensembles of effects look like. One notational change: Topic 28’s KK groups become this topic’s NN parallel problems, because NN will grow large and asymptotics in NN are the point.

Remark 2 Why 'empirical Bayes' is not an oxymoron

Robbins (ROB1956) coined the phrase. A single problem’s Bayes rule needs a prior gg, and with one observation there is no way to check it. But a large ensemble of parallel problems, each drawing its parameter from the same gg, carries its own information about gg: the histogram of the xix_i is a blurred picture of gg. The prior stops being a statement of belief and becomes an estimable population distribution — the distribution of true effects across genes, of true quality across configurations, of true accident rates across drivers.

33.2 The compound decision problem

Before estimating anything we need to say what “good” means when we estimate NN parameters at once. The frame is Robbins’ compound decision problem (ROB1951): many parameters, one estimation rule applied to all of them, judged by average error. That is the situation of a hyperparameter sweep, an experimentation platform running thousands of A/B tests, or a recommender estimating a click-through rate for every item in the catalog.

Definition 1 Compound decision problem; separable rule; compound risk

Fix real numbers θ=(θ1,…,θN)\theta = (\theta_1, \dots, \theta_N) — no prior, just NN unknown constants — and observe independent Xi∼p(⋅∣θi)X_i \sim p(\cdot \mid \theta_i), i=1,…,Ni = 1, \dots, N. A separable rule applies one function tt to every coordinate: θ^i=t(Xi)\hat\theta_i = t(X_i). Its compound risk is the average mean squared error

RN(t;θ)=1N∑i=1NEθi[(t(Xi)−θi)2],R_N(t; \theta) = \frac{1}{N}\sum_{i=1}^N E_{\theta_i}\big[(t(X_i) - \theta_i)^2\big],

where EθiE_{\theta_i} averages over Xi∼p(⋅∣θi)X_i \sim p(\cdot \mid \theta_i) with θi\theta_i held fixed.

Definition 2 Oracle Bayes rule; empirical-Bayes rule; regret

For a prior GG on the parameter, the Bayes rule is the posterior mean tG(x)=EG[ϑ∣X=x]t_G(x) = E_G[\vartheta \mid X = x], computed with ϑ∼G\vartheta \sim G and X∣ϑ∼p(⋅∣ϑ)X \mid \vartheta \sim p(\cdot \mid \vartheta). With GN=1N∑iδθiG_N = \frac1N\sum_i \delta_{\theta_i} — the empirical distribution that puts mass 1/N1/N on each true parameter — tGNt_{G_N} is the oracle Bayes rule (EFR2019’s “oracle Bayes”): it would be available only to someone who knew the histogram of the θi\theta_i. An empirical-Bayes rule t^\hat t is any rule built from the data X1,…,XNX_1, \dots, X_N to estimate tGNt_{G_N}, and its regret is RN(t^;θ)−RN(tGN;θ)R_N(\hat t; \theta) - R_N(t_{G_N}; \theta).

This is where most readers lose the thread, so let’s slow down. Nothing in Definition 1 is random except the noise. The θi\theta_i are fixed, and the compound risk is a purely frequentist quantity: an average over hypothetical re-draws of the noise. Yet the theorem below says the best separable rule is a posterior mean — a Bayesian object — under a particular prior, GNG_N. The prior was never assumed; it falls out of the averaging over ii. Part (ii) of the proof treats that average as an iterated integral, first over XX given the parameter and then over the parameter drawn from GNG_N, which is the order-of-integration bookkeeping of formalCalculus: Multiple Integrals & Fubini's Theorem .

Theorem 1 Fundamental theorem of compound decisions (ROB1951, ZHA2003)

Let θ1,…,θN\theta_1, \dots, \theta_N be fixed real numbers and let X1,…,XNX_1, \dots, X_N be independent with Xi∼p(⋅∣θi)X_i \sim p(\cdot \mid \theta_i). For a separable rule θ^i=t(Xi)\hat\theta_i = t(X_i) with finite compound risk, and with GN=1N∑i=1NδθiG_N = \frac1N\sum_{i=1}^N \delta_{\theta_i} the empirical distribution of the parameters:

(i) the compound risk equals the Bayes risk of tt under the prior GNG_N,

RN(t;θ)  =  ∫Eϑ[(t(X)−ϑ)2] dGN(ϑ);R_N(t; \theta) \;=\; \int E_\vartheta\big[(t(X) - \vartheta)^2\big]\, dG_N(\vartheta);

(ii) RN(t;θ)≥RN(tGN;θ)R_N(t; \theta) \ge R_N(t_{G_N}; \theta) for every separable tt, where

tGN(x)  =  ∑i=1Nθi p(x∣θi)∑i=1Np(x∣θi),t_{G_N}(x) \;=\; \frac{\sum_{i=1}^N \theta_i\, p(x \mid \theta_i)}{\sum_{i=1}^N p(x \mid \theta_i)},

with equality if and only if t=tGNt = t_{G_N} almost everywhere under the marginal mGN(x)=1N∑ip(x∣θi)m_{G_N}(x) = \frac1N\sum_i p(x \mid \theta_i).

Proof 1 Proof of Thm 1 (fundamental theorem of compound decisions) [show]

(i) For any function hh, the average 1N∑ih(θi)\frac1N\sum_i h(\theta_i) is the integral of hh against GNG_N, because GNG_N puts mass 1/N1/N on each θi\theta_i. Apply this to h(ϑ)=Eϑ[(t(X)−ϑ)2]h(\vartheta) = E_\vartheta[(t(X) - \vartheta)^2].

(ii) Introduce a random pair (ϑ,X)(\vartheta, X) with ϑ∼GN\vartheta \sim G_N and X∣ϑ∼p(⋅∣ϑ)X \mid \vartheta \sim p(\cdot \mid \vartheta). By (i), the compound risk is the joint expectation

RN(t;θ)  =  E[(t(X)−ϑ)2].R_N(t; \theta) \;=\; E\big[(t(X) - \vartheta)^2\big].

Condition on XX and write m(x)=E[ϑ∣X=x]m(x) = E[\vartheta \mid X = x]. For fixed xx, expanding (t(x)−ϑ)2=(t(x)−m(x))2+2(t(x)−m(x))(m(x)−ϑ)+(m(x)−ϑ)2(t(x) - \vartheta)^2 = (t(x) - m(x))^2 + 2(t(x) - m(x))(m(x) - \vartheta) + (m(x) - \vartheta)^2 and taking the conditional expectation — the cross term has conditional mean zero — gives

E[(t(X)−ϑ)2∣X=x]  =  (t(x)−m(x))2+Var(ϑ∣X=x).E\big[(t(X) - \vartheta)^2 \mid X = x\big] \;=\; \big(t(x) - m(x)\big)^2 + \mathrm{Var}(\vartheta \mid X = x).

Averaging over XX with the tower property,

RN(t;θ)  =  E[(t(X)−m(X))2]+E[Var(ϑ∣X)].R_N(t; \theta) \;=\; E\big[(t(X) - m(X))^2\big] + E\big[\mathrm{Var}(\vartheta \mid X)\big].

The second term does not depend on tt; the first is nonnegative and vanishes exactly when t=mt = m almost everywhere under the law of XX, which is mGNm_{G_N}. Finally, Bayes’ theorem with the discrete prior GNG_N (mass 1/N1/N at each θi\theta_i; the 1/N1/N cancels) gives m(x)=∑iθip(x∣θi)/∑ip(x∣θi)=tGN(x)m(x) = \sum_i \theta_i p(x \mid \theta_i)/\sum_i p(x \mid \theta_i) = t_{G_N}(x). ■\blacksquare — using the tower property of conditional expectation and Bayes’ theorem for a discrete prior (ROB1951; ZHA2003).

◼

Theorem 1 turns estimation into a target. The best we can do with a separable rule is tGNt_{G_N}; we can’t compute it, because it depends on the unknown θi\theta_i, but every empirical-Bayes method is an attempt to estimate it from the XiX_i. The two families of attempts differ in what they estimate.

Definition 3 f-modeling and g-modeling (EFR2014)

f-modeling estimates the marginal density ff of the observations (or a functional of it, such as its log-derivative) and plugs the estimate into a formula for the Bayes rule tGt_G that depends on GG only through ff. g-modeling estimates the prior GG itself and computes the Bayes rule tG^t_{\hat G} of the estimate.

Example 2 The best linear separable rule is James–Stein

Restrict attention to linear rules t(x)=a+bxt(x) = a + bx with Normal noise, Xi∼N(θi,σ2)X_i \sim \mathcal{N}(\theta_i, \sigma^2). For each coordinate, t(Xi)−θi=b(Xi−θi)+(a+(b−1)θi)t(X_i) - \theta_i = b(X_i - \theta_i) + (a + (b - 1)\theta_i) is a mean-zero noise term plus a constant, so its mean square is b2σ2+(a+(b−1)θi)2b^2\sigma^2 + (a + (b-1)\theta_i)^2. Averaging over ii,

RN(a+bx;θ)=b2σ2+1N∑i=1N(a+(b−1)θi)2.R_N(a + bx; \theta) = b^2\sigma^2 + \frac1N\sum_{i=1}^N \big(a + (b-1)\theta_i\big)^2.

For fixed bb, the second term is the average squared distance between aa and the points (1−b)θi(1-b)\theta_i, minimized at their mean: a=(1−b)θˉa = (1-b)\bar\theta, where θˉ=1N∑iθi\bar\theta = \frac1N\sum_i\theta_i. Substituting, with s2=1N∑i(θi−θˉ)2s^2 = \frac1N\sum_i(\theta_i - \bar\theta)^2 the spread of the true parameters,

RN=b2σ2+(1−b)2s2.R_N = b^2\sigma^2 + (1-b)^2 s^2.

Setting the derivative in bb to zero, 2bσ2−2(1−b)s2=02b\sigma^2 - 2(1-b)s^2 = 0, gives b∗=s2/(s2+σ2)b^* = s^2/(s^2 + \sigma^2). The best linear rule is therefore θˉ+b∗(x−θˉ)=x−(1−b∗)(x−θˉ)\bar\theta + b^*(x - \bar\theta) = x - (1 - b^*)(x - \bar\theta), with shrinkage fraction 1−b∗=σ2/(s2+σ2)1 - b^* = \sigma^2/(s^2 + \sigma^2).

Now estimate the two unknowns. Replace θˉ\bar\theta by Xˉ\bar X, and estimate 1−b∗1 - b^* by (N−3)σ2/∑i(Xi−Xˉ)2(N-3)\sigma^2/\sum_i (X_i - \bar X)^2. Under Normal-prior sampling, θi∼N(μ,τ2)\theta_i \sim \mathcal{N}(\mu, \tau^2), the observations are marginally N(μ,σ2+τ2)\mathcal{N}(\mu, \sigma^2 + \tau^2), so ∑i(Xi−Xˉ)2∼(σ2+τ2)χN−12\sum_i (X_i - \bar X)^2 \sim (\sigma^2 + \tau^2)\chi^2_{N-1}; since E[1/χN−12]=1/(N−3)E[1/\chi^2_{N-1}] = 1/(N-3), the estimator has expectation exactly σ2/(σ2+τ2)\sigma^2/(\sigma^2 + \tau^2). The result is the Efron–Morris rule (EFR1973),

θ^i=Xˉ+(1−(N−3)σ2∑j(Xj−Xˉ)2)(Xi−Xˉ).\hat\theta_i = \bar X + \left(1 - \frac{(N-3)\sigma^2}{\sum_j (X_j - \bar X)^2}\right)(X_i - \bar X).

James–Stein is not a paradox: it is the empirical-Bayes estimate of the best linear separable rule. Nonparametric empirical Bayes drops the word “linear.”

Remark 3 A frequentist question with a Bayesian answer

No prior was assumed anywhere in Theorem 1 — the θi\theta_i are fixed — and yet the optimal separable rule is a posterior mean under GNG_N. Robbins called procedures that approach this optimum without knowing GNG_N “asymptotically subminimax” (ROB1951): for large NN they do nearly as well as if the histogram of the true parameters had been revealed. Separable rules are the natural class because the problems are exchangeable before we see the data — nothing distinguishes problem 7 from problem 700. A non-separable rule can beat tGNt_{G_N} only by exploiting the ordering of the indices, which carries no information when the labels are arbitrary.

Remark 4 The f/g taxonomy

Figure 2 shows why the two strategies are genuinely different. A prior gg can be spiky — here, three point masses — but the data never see it directly. They see the marginal f=g∗φσf = g \ast \varphi_\sigma: the prior convolved with (smeared by) the Normal noise, which is always smooth. f-modeling works with that smooth object; g-modeling tries to undo the smearing. f-modeling is Robbins’ formula (§33.3) and Tweedie’s formula (§33.4–§33.5); g-modeling is the nonparametric MLE of the prior (§33.6); §33.7 compares them head to head.

Two panels. Left: a three-atom prior g drawn as teal stems, the three Normal components each atom produces drawn dotted, and the smooth marginal density f, their sum, drawn in sky blue. Right: a flow diagram from data to two routes, estimate f and apply Robbins or Tweedie, or deconvolve to estimate g and apply the Bayes rule under the estimate, both ending in theta-hat i equals t-hat of x i.

Figure 2. The data see the marginal f, never the prior g. f-modeling estimates f and plugs it into a formula; g-modeling deconvolves an estimate of g and computes its Bayes rule.

33.3 Robbins’ formula

Robbins’ first example was insurance. Each policy holder has an unknown accident rate θ>0\theta > 0 — expected claims per year — and the number of claims XX in a year is Poisson(θ)\mathrm{Poisson}(\theta), the standard model for counts of rare, independent events. Rates vary across the book according to an unknown distribution gg on (0,∞)(0, \infty). The marginal probability f(x)=P(X=x)f(x) = P(X = x) is the fraction of all holders with exactly xx claims, and it is directly visible in the data. The same structure governs per-user event counts in a product — clicks, purchases, sessions — and the question Robbins answered is the cold-start question: what should we predict next period for a user we observed xx times this period?

Theorem 2 Robbins' formula (ROB1956)

Let θ∼g\theta \sim g, any probability measure on (0,∞)(0, \infty), and X∣θ∼Poisson(θ)X \mid \theta \sim \mathrm{Poisson}(\theta), with marginal

f(x)  =  ∫0∞e−θθxx! dg(θ),x=0,1,2,…f(x) \;=\; \int_0^\infty \frac{e^{-\theta}\theta^x}{x!}\, dg(\theta), \qquad x = 0, 1, 2, \dots

Then for every xx with f(x)>0f(x) > 0,

E[θ∣X=x]  =  (x+1) f(x+1)f(x).E[\theta \mid X = x] \;=\; (x + 1)\,\frac{f(x+1)}{f(x)}.
Proof 2 Proof of Thm 2 (Robbins' formula) [show]

By Bayes’ theorem the posterior is dg(θ∣x)=e−θθx/x!  dg(θ)/f(x)dg(\theta \mid x) = e^{-\theta}\theta^x/x!\; dg(\theta)/f(x), so

E[θ∣X=x]  =  1f(x)∫0∞θ⋅e−θθxx! dg(θ)  =  1f(x)∫0∞e−θθx+1x! dg(θ).E[\theta \mid X = x] \;=\; \frac{1}{f(x)} \int_0^\infty \theta \cdot \frac{e^{-\theta}\theta^{x}}{x!}\, dg(\theta) \;=\; \frac{1}{f(x)} \int_0^\infty \frac{e^{-\theta}\theta^{x+1}}{x!}\, dg(\theta).

Multiply and divide the integrand by x+1x + 1, using (x+1)⋅x!=(x+1)!(x+1)\cdot x! = (x+1)!:

∫0∞e−θθx+1x! dg(θ)  =  (x+1)∫0∞e−θθx+1(x+1)! dg(θ)  =  (x+1) f(x+1).\int_0^\infty \frac{e^{-\theta}\theta^{x+1}}{x!}\, dg(\theta) \;=\; (x+1)\int_0^\infty \frac{e^{-\theta}\theta^{x+1}}{(x+1)!}\, dg(\theta) \;=\; (x+1)\, f(x+1).

Dividing by f(x)f(x) gives the formula. ■\blacksquare — using Bayes’ theorem and the Poisson pmf (ROB1956).

◼

The prior has disappeared. Replacing f(x)f(x) by the empirical frequency yx/Ny_x/N, where yxy_x is the number of holders with exactly xx claims, gives Robbins’ estimator (x+1) yx+1/yx(x+1)\,y_{x+1}/y_x, in which NN cancels. For each fixed xx with f(x)>0f(x) > 0, the frequencies yx/Ny_x/N and yx+1/Ny_{x+1}/N converge almost surely to f(x)f(x) and f(x+1)f(x+1) by the strong law of large numbers (Topic 10), and the ratio converges because it is a continuous function of them away from f(x)=0f(x) = 0.

Example 3 Insurance claims

CASI Table 6.1 (EFR2016) records one year of claims for 9,461 policy holders of a European auto insurer:

Claims xx01234567
Holders yxy_x784013172394214441
Robbins (x+1)yx+1/yx(x+1)y_{x+1}/y_x0.1680.3630.5271.331.436.001.75—

These are identical to CASI’s published row. The first entry is the cold-start answer: customers with no claims this year should expect 1317/7840=0.1681317/7840 = 0.168 claims next year — not 0, which is what the MLE θ^=x\hat\theta = x says. Customers with one claim should expect 0.363, far less than 1: one claim is weak evidence of a high rate, because most of the book has low rates and some of them file a claim by chance.

Example 4 Gamma–Poisson parametric empirical Bayes

The parametric alternative assumes a shape for gg: θ∼Gamma(ν,s)\theta \sim \mathrm{Gamma}(\nu, s) with shape ν\nu and scale ss. Then the posterior given xx is Gamma(ν+x, s/(1+s))\mathrm{Gamma}(\nu + x,\, s/(1+s)), with mean

E[θ∣x]=(x+ν) s1+s,E[\theta \mid x] = \frac{(x + \nu)\, s}{1 + s},

and the marginal of XX is negative binomial. Its maximum-likelihood fit preserves the sample mean, ν^s^=xˉ=0.2144\hat\nu\hat s = \bar x = 0.2144, so the fit reduces to a one-dimensional profile in ν\nu, which gives ν^=0.7015\hat\nu = 0.7015 and s^=0.3056\hat s = 0.3056. The fitted rule for x=0,…,6x = 0, \dots, 6 is

0.164, 0.398, 0.632, 0.866, 1.100, 1.334, 1.568

(CASI: .164 .398 .633 .87 1.10 1.34 1.57). Figure 3 puts the two side by side: they agree where the counts are large, and Robbins goes erratic where they are small.

Two panels. Left: insurance claim counts by number of claims on a log scale, with the Gamma-Poisson fitted counts in violet. Right: estimated next-year claim rate against this year's claims: the MLE diagonal dashed in amber, Robbins' estimates in sky blue spiking to 6.00 at x equals 5 (annotated 6 times 4 over 4), and the Gamma-Poisson empirical Bayes rule in violet, a straight line with nu-hat 0.702 and s-hat 0.306.

Figure 3. Robbins’ formula on 9,461 insurance policy holders. It needs no prior and no parameters, and it is erratic exactly where the counts are small.

The explorer below puts both rules next to each other on the insurance data and on a simulated book where the true posterior mean is known. Click a count bar to perturb that count by ±1 and watch which estimates move.

Dataset:
- - MLE: θ̂ = x● Robbins (x+1)y₍ₓ₊₁₎/yₓ■ Gamma–Poisson EB
6.0001234560246claims this year, xÊ[θ | x]
Counts yₓ (log scale) — click a bar to perturb it
1101001k10k78400131712392423144454617x
y5 = 4
Gamma fit: ν̂ = 0.702, ŝ = 0.306
xyₓRobbinsGamma EB
078400.1680.164
113170.3630.398
22390.5270.632
3421.3330.866
4141.4291.100
546.0001.334
641.7501.568
Remark 5 Instability where counts are small

At x=5x = 5, Robbins’ estimate is 6⋅y6/y5=6⋅4/4=6.006 \cdot y_6/y_5 = 6 \cdot 4/4 = 6.00: two tiny counts drive it. A single extra policy holder with six claims would change it to 6⋅5/4=7.56 \cdot 5/4 = 7.5. The parametric fit borrows strength across every xx; Robbins borrows only from the neighboring cell x+1x + 1. The explorer’s perturbation buttons make the difference tactile — perturbing y5y_5 moves Robbins at x=4x = 4 and x=5x = 5 substantially and leaves the Gamma rule essentially unchanged.

Remark 6 Robbins' rule need not be monotone; the Bayes rule is

For the Poisson family, E[θ∣x]E[\theta \mid x] is nondecreasing in xx for every prior. The posterior at x+1x + 1 is the posterior at xx tilted by a factor of θ\theta, so

E[θ∣x+1]=E[θ2∣x]E[θ∣x]  ≥  E[θ∣x],E[\theta \mid x+1] = \frac{E[\theta^2 \mid x]}{E[\theta \mid x]} \;\ge\; E[\theta \mid x],

because E[θ2∣x]−(E[θ∣x])2=Var(θ∣x)≥0E[\theta^2 \mid x] - (E[\theta \mid x])^2 = \mathrm{Var}(\theta \mid x) \ge 0. This is the discrete twin of §33.4 Theorem 3(iii). Robbins’ drop from 6.00 at x=5x = 5 to 1.75 at x=6x = 6 is therefore an estimation artifact, not a feature of any prior. We’ll turn this observation into a diagnostic in §33.7.

Now return to the setting of §33.1: Normal noise with known variance σ2\sigma^2 and an arbitrary prior gg. Write

φσ(u)=12πσ2 e−u2/(2σ2)\varphi_\sigma(u) = \frac{1}{\sqrt{2\pi\sigma^2}}\, e^{-u^2/(2\sigma^2)}

for the N(0,σ2)\mathcal{N}(0, \sigma^2) density — the bell curve of the noise — and φ=φ1\varphi = \varphi_1 for the standard Normal density. The marginal density of an observation is f(x)=∫φσ(x−θ) dg(θ)f(x) = \int \varphi_\sigma(x - \theta)\, dg(\theta), written f=g∗φσf = g \ast \varphi_\sigma: the prior smeared out by the noise. Let ℓ=log⁡f\ell = \log f. Its derivative ℓ′\ell' is the score of the marginal — the slope of the log-density, which tells us which way, and how steeply, the data pile up. Robbins (ROB1956) credits the next result to Maurice Tweedie; Efron’s “Tweedie’s formula and selection bias” (EFR2011) is the modern treatment. It is the Normal-noise version of Robbins’ formula, and it is the featured result of this topic.

Theorem 3 Tweedie's formula (ROB1956, crediting Tweedie; EFR2011)

Let gg be any probability measure on R\mathbb{R}, θ∼g\theta \sim g, and X∣θ∼N(θ,σ2)X \mid \theta \sim \mathcal{N}(\theta, \sigma^2) with σ2>0\sigma^2 > 0 known. Write φσ(u)=(2πσ2)−1/2e−u2/(2σ2)\varphi_\sigma(u) = (2\pi\sigma^2)^{-1/2}e^{-u^2/(2\sigma^2)} and

f(x)  =  ∫φσ(x−θ) dg(θ),ℓ(x)=log⁡f(x).f(x) \;=\; \int \varphi_\sigma(x - \theta)\, dg(\theta), \qquad \ell(x) = \log f(x).

Then ff is strictly positive and twice differentiable, and for every xx:

(i) E[θ∣X=x]=x+σ2 ℓ′(x)E[\theta \mid X = x] = x + \sigma^2\,\ell'(x);

(ii) Var(θ∣X=x)=σ2(1+σ2 ℓ′′(x))\mathrm{Var}(\theta \mid X = x) = \sigma^2\big(1 + \sigma^2\,\ell''(x)\big);

(iii) ddxE[θ∣X=x]=Var(θ∣X=x)/σ2≥0\dfrac{d}{dx}E[\theta \mid X = x] = \mathrm{Var}(\theta \mid X = x)/\sigma^2 \ge 0 — the Bayes rule is nondecreasing in xx.

Proof 3 Proof of Thm 3 (Tweedie's formula) [show]

Step 0 — differentiating under the integral. The xx-derivatives of the integrand are

∂∂xφσ(x−θ)=−x−θσ2 φσ(x−θ),∂2∂x2φσ(x−θ)=((x−θ)2σ4−1σ2)φσ(x−θ).\frac{\partial}{\partial x}\varphi_\sigma(x - \theta) = -\frac{x - \theta}{\sigma^2}\,\varphi_\sigma(x - \theta), \qquad \frac{\partial^2}{\partial x^2}\varphi_\sigma(x - \theta) = \Big(\frac{(x - \theta)^2}{\sigma^4} - \frac{1}{\sigma^2}\Big)\varphi_\sigma(x - \theta).

Both are bounded functions of (x,θ)(x, \theta), because u↦∣u∣ke−u2/(2σ2)u \mapsto |u|^k e^{-u^2/(2\sigma^2)} is bounded for k=1,2k = 1, 2. A bounded function is integrable against the probability measure gg, so dominated convergence lets us differentiate ff twice under the integral sign ( formalCalculus: The Lebesgue Integral , Ex 10). The integrand is strictly positive, so f>0f > 0 and ℓ\ell is well defined.

Step 1 — the mean. By Step 0,

f′(x)  =  1σ2∫(θ−x) φσ(x−θ) dg(θ).f'(x) \;=\; \frac{1}{\sigma^2}\int (\theta - x)\,\varphi_\sigma(x - \theta)\, dg(\theta).

The posterior is dg(θ∣x)=φσ(x−θ) dg(θ)/f(x)dg(\theta \mid x) = \varphi_\sigma(x - \theta)\,dg(\theta)/f(x), so dividing by f(x)f(x) turns the integral into a posterior expectation:

ℓ′(x)  =  f′(x)f(x)  =  1σ2 E[θ−x∣X=x]  =  E[θ∣X=x]−xσ2.\ell'(x) \;=\; \frac{f'(x)}{f(x)} \;=\; \frac{1}{\sigma^2}\,E[\theta - x \mid X = x] \;=\; \frac{E[\theta \mid X = x] - x}{\sigma^2}.

Multiplying by σ2\sigma^2 and adding xx gives (i).

Step 2 — the variance. Again by Step 0 and the same division,

f′′(x)f(x)  =  E[(θ−x)2∣X=x]σ4−1σ2.\frac{f''(x)}{f(x)} \;=\; \frac{E[(\theta - x)^2 \mid X = x]}{\sigma^4} - \frac{1}{\sigma^2}.

Since ℓ′′=f′′/f−(f′/f)2\ell'' = f''/f - (f'/f)^2 and f′/f=E[θ−x∣X=x]/σ2f'/f = E[\theta - x \mid X = x]/\sigma^2,

ℓ′′(x)  =  E[(θ−x)2∣X=x]−(E[θ−x∣X=x])2σ4−1σ2  =  Var(θ∣X=x)σ4−1σ2,\ell''(x) \;=\; \frac{E[(\theta - x)^2 \mid X = x] - \big(E[\theta - x \mid X = x]\big)^2}{\sigma^4} - \frac{1}{\sigma^2} \;=\; \frac{\mathrm{Var}(\theta \mid X = x)}{\sigma^4} - \frac{1}{\sigma^2},

where the last step uses that shifting θ\theta by the constant xx does not change its conditional variance. Multiplying by σ4\sigma^4 and rearranging gives (ii).

Step 3 — monotonicity. Differentiating (i) gives 1+σ2ℓ′′(x)1 + \sigma^2\ell''(x), which equals Var(θ∣X=x)/σ2\mathrm{Var}(\theta \mid X = x)/\sigma^2 by (ii), and a variance is nonnegative. ■\blacksquare — using dominated convergence (formalCalculus: The Lebesgue Integral) and Bayes’ theorem (ROB1956; EFR2011).

◼

Read (i) geometrically. The Bayes rule is the identity map plus a correction, and the correction σ2ℓ′(x)\sigma^2\ell'(x) is a vector field on the line: at each point it says which way the marginal density increases and how fast. Figure 4 draws it.

Two stacked panels. Top: a histogram of 2,000 draws from the spike-and-slab marginal, the true marginal density f in near-black, and a kernel density estimate with bandwidth 0.32 dashed in sky blue; violet horizontal arrows on the curve at x equals plus or minus 0.75 through plus or minus 3.75 show sigma squared times the score, every one pointing toward the peak at zero. Bottom: shrinkage rules on minus 5.5 to 5.5, the identity dashed in amber, the oracle Bayes rule in near-black, and Tweedie with the KDE marginal dashed in sky blue, with the gap between identity and oracle shaded violet.

Figure 4. Tweedie’s formula as geometry: the Bayes correction is σ² times the score of the marginal, a field of arrows pointing uphill on f. Bottom: the resulting nonlinear shrinkage rule, oracle versus KDE estimate.

The explorer makes the field live. Choose a prior, change the sample size and the bandwidth, and compare the KDE-estimated rule to the oracle. Try the Normal prior first: the oracle rule becomes a straight line, which is Topic 28’s linear shrinkage (Example 5 below). Then shrink NN or the bandwidth and watch the estimated rule wiggle in the tails.

Prior g:
Seed
histogram of xtrue marginal fKDE f̂σ²ℓ′(x): x → E[θ | x]
-6-4-20246observation xdensity
identity (MLE: θ̂ = x)oracle Bayes E[θ | x]Tweedie–KDE
-6-6-4-4-2-200224466observation xestimate of θ
Per-coordinate MSE
MLE (x)0.997
Tweedie–KDE0.207
Oracle Bayes0.168
MSE on 1,000 random points
KDE bandwidth
h = 0.314 (1.00× Silverman)

Tweedie–KDE recovers 95% of the oracle's improvement over the MLE.

Example 5 A Normal prior recovers Topic 28

Take g=N(μ,τ2)g = \mathcal{N}(\mu, \tau^2). The marginal is f=N(μ,σ2+τ2)f = \mathcal{N}(\mu, \sigma^2 + \tau^2) — a Normal prior smeared by Normal noise is Normal with the variances added — so

ℓ(x)=−(x−μ)22(σ2+τ2)+const,ℓ′(x)=−x−μσ2+τ2,ℓ′′(x)=−1σ2+τ2.\ell(x) = -\frac{(x - \mu)^2}{2(\sigma^2 + \tau^2)} + \text{const}, \qquad \ell'(x) = -\frac{x - \mu}{\sigma^2 + \tau^2}, \qquad \ell''(x) = -\frac{1}{\sigma^2 + \tau^2}.

Tweedie’s formula returns x−σ2(x−μ)/(σ2+τ2)=(1−B)x+Bμx - \sigma^2(x - \mu)/(\sigma^2 + \tau^2) = (1 - B)x + B\mu with B=σ2/(σ2+τ2)B = \sigma^2/(\sigma^2 + \tau^2), and part (ii) gives the posterior variance σ2(1−B)=(1−B)σ2\sigma^2(1 - B) = (1 - B)\sigma^2. This is exactly Topic 28’s partial-pooling formula (§28.6, Thm 4), now a one-line special case. The rule is linear because ℓ\ell is quadratic; every non-Normal prior bends it.

Example 6 Spike-and-slab prior: oracle versus KDE

Take g=0.9 δ0+0.1 N(0,32)g = 0.9\,\delta_0 + 0.1\,\mathcal{N}(0, 3^2) — 90% of the effects are exactly zero, the rest are spread widely — with σ=1\sigma = 1 and N=2000N = 2000 draws. The oracle rule E[θ∣x]E[\theta \mid x] at x=1,2,3,5x = 1, 2, 3, 5 is 0.047, 0.316, 1.805, 4.498: near-total shrinkage near 0, where an observation is most likely a null plus noise, and near-identity in the tails, where it is most likely a real effect.

For the f-modeling estimate, fit a Gaussian KDE (Topic 30) with Silverman’s bandwidth h=0.32h = 0.32: f^h(x)=1Nh∑jφ((x−Xj)/h)\hat f_h(x) = \frac{1}{Nh}\sum_j \varphi((x - X_j)/h). Differentiating term by term and dividing by f^h\hat f_h, the KDE score has the closed form

(log⁡f^h)′(x)=∑j=1Nwj(x) Xj−xh2,wj(x)=φ((x−Xj)/h)∑kφ((x−Xk)/h),(\log \hat f_h)'(x) = \sum_{j=1}^N w_j(x)\,\frac{X_j - x}{h^2}, \qquad w_j(x) = \frac{\varphi((x - X_j)/h)}{\sum_k \varphi((x - X_k)/h)},

a softmax-weighted pull toward nearby data points. Per-coordinate mean squared error on the sample: the MLE θ^i=xi\hat\theta_i = x_i scores 1.033, Tweedie–KDE 0.244, the oracle 0.193. With gg unknown, Tweedie–KDE captures about 94% of the oracle’s improvement over the MLE.

Remark 7 The shrinkage field points uphill

Part (i) says the correction σ2ℓ′(x)\sigma^2\ell'(x) points toward higher marginal density. Observations in sparse regions get pulled toward where the data are dense — Figure 4’s arrows all point at the spike. The noise variance σ2\sigma^2 sets the step size: noisier measurements are pulled harder, because they say less about their own θ\theta. That is the whole content of shrinkage, stated without a prior.

Remark 8 Tweedie never names g

The rule depends on gg only through ff, which is what makes f-modeling possible: estimate ff from the xix_i, differentiate its logarithm, done. The price is that we need a derivative of a density estimate, and derivative estimates are noisy where data are thin — Example 6’s KDE rule wiggles in the tails. Bandwidth controls the trade-off exactly as in Topic 30: see the MISE/AMISE analysis in §30.5 and data-driven bandwidth selection in §30.8.

Remark 9 Diffusion models are Tweedie machines

Corrupt a clean sample x0x_0 with Gaussian noise, xt=x0+σtεx_t = x_0 + \sigma_t\varepsilon with ε∼N(0,I)\varepsilon \sim \mathcal{N}(0, I). Theorem 3 in Rd\mathbb{R}^d — the proof runs coordinate by coordinate — gives

E[x0∣xt]=xt+σt2 ∇log⁡pt(xt),E[x_0 \mid x_t] = x_t + \sigma_t^2\,\nabla \log p_t(x_t),

where ptp_t is the density of the noisy samples. A denoiser trained by squared error, minimizing E∥D(xt)−x0∥2E\|D(x_t) - x_0\|^2, converges to the posterior mean E[x0∣xt]E[x_0 \mid x_t], so (D(xt)−xt)/σt2(D(x_t) - x_t)/\sigma_t^2 estimates the score ∇log⁡pt\nabla\log p_t. That is denoising score matching (VIN2011), the training objective behind score-based diffusion models: every denoising network is an f-modeling estimate of Tweedie’s correction. formalML’s representation-learning topic develops the identity (§3.4 there, Thm 3.2): formalML: representation-learning .

33.5 Tweedie beyond the Normal, and selection bias

Tweedie’s formula is not special to Normal noise. Any one-parameter exponential family (Topic 7) has the same structure: the posterior mean of the natural parameter is a log-derivative of the marginal, corrected by the carrier. This matters in ML because many of the quantities we shrink are not Normal — counts, rates, variances.

Theorem 4 Exponential-family Tweedie (EFR2011)

Let p(x∣η)=eηx−ψ(η)h(x)p(x \mid \eta) = e^{\eta x - \psi(\eta)}h(x) be a one-parameter exponential family of densities on an open interval X\mathcal{X}, in Topic 7’s notation (natural parameter η\eta, cumulant function ψ\psi, carrier h>0h > 0 twice differentiable on X\mathcal{X}). Let η∼g\eta \sim g, a probability measure on the natural parameter space with ∫(1+∣η∣+η2) eηx−ψ(η) dg(η)<∞\int (1 + |\eta| + \eta^2)\, e^{\eta x - \psi(\eta)}\, dg(\eta) < \infty for every x∈Xx \in \mathcal{X}. With f(x)=∫p(x∣η) dg(η)f(x) = \int p(x \mid \eta)\,dg(\eta) and ℓ=log⁡f\ell = \log f:

(i) E[η∣X=x]=ℓ′(x)−(log⁡h)′(x)E[\eta \mid X = x] = \ell'(x) - (\log h)'(x); (ii) Var(η∣X=x)=ℓ′′(x)−(log⁡h)′′(x)\mathrm{Var}(\eta \mid X = x) = \ell''(x) - (\log h)''(x).

Proof 4 Proof of Thm 4 (exponential-family Tweedie) [show]

Factor the carrier out of the marginal:

f(x)  =  h(x) M(x),M(x)=∫eηx−ψ(η) dg(η),f(x) \;=\; h(x)\, M(x), \qquad M(x) = \int e^{\eta x - \psi(\eta)}\, dg(\eta),

so ℓ=log⁡h+log⁡M\ell = \log h + \log M and it suffices to show (log⁡M)′=E[η∣X=x](\log M)' = E[\eta \mid X = x] and (log⁡M)′′=Var(η∣X=x)(\log M)'' = \mathrm{Var}(\eta \mid X = x). For xx in a compact sub-interval [a,b]⊂X[a, b] \subset \mathcal{X}, ηx≤max⁡(ηa,ηb)\eta x \le \max(\eta a, \eta b) gives eηx≤eηa+eηbe^{\eta x} \le e^{\eta a} + e^{\eta b}, so ∣η∣keηx−ψ(η)|\eta|^k e^{\eta x - \psi(\eta)} (k=0,1,2k = 0, 1, 2) is dominated by a gg-integrable function not depending on xx. Dominated convergence ( formalCalculus: The Lebesgue Integral ) then justifies

M′(x)=∫η eηx−ψ(η) dg(η),M′′(x)=∫η2 eηx−ψ(η) dg(η).M'(x) = \int \eta\, e^{\eta x - \psi(\eta)}\, dg(\eta), \qquad M''(x) = \int \eta^2\, e^{\eta x - \psi(\eta)}\, dg(\eta).

The posterior is dg(η∣x)=p(x∣η) dg(η)/f(x)=eηx−ψ(η) dg(η)/M(x)dg(\eta \mid x) = p(x \mid \eta)\,dg(\eta)/f(x) = e^{\eta x - \psi(\eta)}\,dg(\eta)/M(x) — the carrier cancels. Hence M′/M=E[η∣X=x]M'/M = E[\eta \mid X = x] and M′′/M=E[η2∣X=x]M''/M = E[\eta^2 \mid X = x], so

(log⁡M)′=M′M=E[η∣X=x],(log⁡M)′′=M′′M−(M′M)2=Var(η∣X=x).(\log M)' = \frac{M'}{M} = E[\eta \mid X = x], \qquad (\log M)'' = \frac{M''}{M} - \Big(\frac{M'}{M}\Big)^2 = \mathrm{Var}(\eta \mid X = x).

Substituting log⁡M=ℓ−log⁡h\log M = \ell - \log h gives (i) and (ii). ■\blacksquare — using dominated convergence, as in Thm 3, and the exponential-family representation of Topic 7 (EFR2011).

◼

Check that Theorem 4 contains Theorem 3. The Normal density factors as φσ(x−θ)=exp⁡(xθ/σ2−θ2/(2σ2)) φσ(x)\varphi_\sigma(x - \theta) = \exp\big(x\theta/\sigma^2 - \theta^2/(2\sigma^2)\big)\,\varphi_\sigma(x), so the natural parameter is η=θ/σ2\eta = \theta/\sigma^2, the cumulant function is ψ(η)=σ2η2/2\psi(\eta) = \sigma^2\eta^2/2, and the carrier is h=φσh = \varphi_\sigma, with (log⁡h)′(x)=−x/σ2(\log h)'(x) = -x/\sigma^2 and (log⁡h)′′(x)=−1/σ2(\log h)''(x) = -1/\sigma^2. Part (i) reads E[θ/σ2∣x]=ℓ′(x)+x/σ2E[\theta/\sigma^2 \mid x] = \ell'(x) + x/\sigma^2, which is Theorem 3(i) after multiplying by σ2\sigma^2; part (ii) reads Var(θ∣x)/σ4=ℓ′′(x)+1/σ2\mathrm{Var}(\theta \mid x)/\sigma^4 = \ell''(x) + 1/\sigma^2, which is Theorem 3(ii).

Example 7 Robbins is discrete Tweedie

For an integer-valued family p(x∣η)=eηx−ψ(η)h(x)p(x \mid \eta) = e^{\eta x - \psi(\eta)}h(x), derivatives in xx are replaced by shifts. Dividing the marginal by the carrier,

f(x+1)h(x+1)=∫eη eηx−ψ(η) dg(η),f(x)h(x)=∫eηx−ψ(η) dg(η),\frac{f(x+1)}{h(x+1)} = \int e^{\eta}\, e^{\eta x - \psi(\eta)}\, dg(\eta), \qquad \frac{f(x)}{h(x)} = \int e^{\eta x - \psi(\eta)}\, dg(\eta),

and the ratio of the two is a posterior expectation, because the posterior given xx is proportional to eηx−ψ(η) dg(η)e^{\eta x - \psi(\eta)}\,dg(\eta):

E[eη∣x]=h(x) f(x+1)h(x+1) f(x).E[e^{\eta} \mid x] = \frac{h(x)\, f(x+1)}{h(x+1)\, f(x)}.

For the Poisson family, p(x∣θ)=e−θθx/x!=exp⁡(xlog⁡θ−θ)/x!p(x \mid \theta) = e^{-\theta}\theta^x/x! = \exp(x\log\theta - \theta)/x!, so η=log⁡θ\eta = \log\theta, eη=θe^\eta = \theta, and h(x)=1/x!h(x) = 1/x!, which makes h(x)/h(x+1)=x+1h(x)/h(x+1) = x + 1. The display becomes E[θ∣x]=(x+1)f(x+1)/f(x)E[\theta \mid x] = (x+1)f(x+1)/f(x) — Theorem 2.

To use Tweedie’s formula on real data we need an estimate of ℓ′\ell'. The KDE of Example 6 is one choice. A second, which Efron uses for the prostate data, fits a smooth exponential family to the histogram.

Definition 4 Lindsey's method (EFR1996)

Bin the data into KK equal-width bins with centers ckc_k, width Δ\Delta, and counts yky_k. Fit the Poisson regression

log⁡E[yk]=∑j=0Jβjukj,\log E[y_k] = \sum_{j=0}^{J}\beta_j u_k^j,

where uku_k is the standardized bin center, and set f^(x)=exp⁡(∑jβju(x)j)/(NΔ)\hat f(x) = \exp\big(\sum_j \beta_j u(x)^j\big)/(N\Delta). The estimated score ℓ^′\hat\ell' is the derivative of a polynomial — smooth everywhere. The fit is exactly the Poisson generalized linear model of Topic 22, with histogram counts as the response.

Now the selection question. The top genes were chosen because their zz-scores were large, and the winning configuration was chosen because its validation score was largest. Does choosing on the data invalidate the posterior mean? It does not.

Theorem 5 The Bayes rule is immune to selection (DAW1994, EFR2011)

Let (θi,Xi)(\theta_i, X_i), i=1,…,Ni = 1, \dots, N, be independent pairs with θi∼g\theta_i \sim g and Xi∣θi∼p(⋅∣θi)X_i \mid \theta_i \sim p(\cdot \mid \theta_i), and let tg(x)=E[θ∣X=x]t_g(x) = E[\theta \mid X = x]. Let S⊆{1,…,N}S \subseteq \{1, \dots, N\} be any selection rule that is a function of X=(X1,…,XN)\mathbf{X} = (X_1, \dots, X_N) — the indices of the kk largest XiX_i, or all ii with Xi>cX_i > c. Then for every ii with P(i∈S)>0P(i \in S) > 0,

E[θi∣X]=tg(Xi)almost surely, andE[θi−tg(Xi) ∣ i∈S]=0.E[\theta_i \mid \mathbf{X}] = t_g(X_i) \quad \text{almost surely, and} \quad E\big[\theta_i - t_g(X_i) \,\big|\, i \in S\big] = 0.
Proof 5 Proof of Thm 5 (selection invariance of the Bayes rule) [show]

Independence of the pairs means θi\theta_i is conditionally independent of (Xj)j≠i(X_j)_{j \ne i} given XiX_i, so the other coordinates carry no information about θi\theta_i once XiX_i is known:

E[θi∣X]  =  E[θi∣Xi]  =  tg(Xi).E[\theta_i \mid \mathbf{X}] \;=\; E[\theta_i \mid X_i] \;=\; t_g(X_i).

The indicator 1{i∈S}\mathbf{1}\{i \in S\} is a function of X\mathbf{X}, so it can be pulled inside a conditional expectation given X\mathbf{X}. By the tower property,

E[(θi−tg(Xi)) 1{i∈S}]  =  E[1{i∈S} (E[θi∣X]−tg(Xi))]  =  0.E\big[(\theta_i - t_g(X_i))\,\mathbf{1}\{i \in S\}\big] \;=\; E\Big[\mathbf{1}\{i \in S\}\,\big(E[\theta_i \mid \mathbf{X}] - t_g(X_i)\big)\Big] \;=\; 0.

Dividing by P(i∈S)>0P(i \in S) > 0 gives the conditional statement. ■\blacksquare — using the tower property and conditional independence (DAW1994; EFR2011).

◼

By contrast, E[Xi−θi∣i∈S]>0E[X_i - \theta_i \mid i \in S] > 0 when SS selects large XiX_i — that is the winner’s curse of §33.1. Selection biases the naive estimate, not the posterior mean. The posterior mean already accounts for the fact that a large xx is more likely to be a moderate θ\theta plus favorable noise than a large θ\theta, and that accounting doesn’t care why we are looking at this particular xx.

Example 8 The prostate top genes, corrected

Fit Lindsey’s method to the 6,033 prostate zz-scores with 90 bins on [min⁡z,max⁡z][\min z, \max z] and degree J=6J = 6. The leading coefficient is negative, so the fitted density is integrable, and 1+ℓ^′′(z)≥0.0301 + \hat\ell''(z) \ge 0.030 across the data range, so the estimated rule z+ℓ^′(z)z + \hat\ell'(z) is monotone, as Theorem 3(iii) says a Bayes rule must be. For the ten largest zz-scores:

zz5.294.834.474.404.254.194.144.124.103.98
E^[μ∣z]\hat E[\mu \mid z]4.643.863.263.142.902.802.722.712.672.49

The top gene’s effect is estimated at 4.64, not 5.29; the tenth gene’s at 2.49, not 3.98. Is this f^\hat f really Efron’s? A cross-check: with the theoretical null N(0,1)\mathcal{N}(0, 1) and null proportion 1, the local false discovery rate φ(z)/f^(z)≤0.2\varphi(z)/\hat f(z) \le 0.2 flags 51 genes (26 right, 25 left) — EFR2008’s count exactly.

Two panels. Left: prostate z-score bin counts on a log scale over 90 bins, with the degree-6 Lindsey fit in sky blue and the all-null curve, N times bin width times the standard Normal density, dashed in slate. Right: the Tweedie rule z plus the estimated score in sky blue against the naive rule z dashed in amber, the top 10 genes marked, and violet arrows showing the deflation of the top 3; an annotation reads z equals 5.29 maps to 4.64.

Figure 5. Lindsey’s method on the prostate z-scores, and Tweedie’s selection-bias correction for the top genes: the largest z-score, 5.29, deflates to an estimated effect of 4.64.

Example 9 Deflating a hyperparameter sweep

Return to Example 1, now with gg unknown, as it always is in practice. Fit a Gaussian KDE to the 1,000 observed scores themselves and apply Tweedie’s formula: the top-20 overstatement falls from +1.41 to +0.21 (the oracle, which knows gg, gets +0.08). The practical recipe for a sweep:

  1. Standardize each configuration’s validation score by its sampling standard deviation — for an accuracy, p^(1−p^)/nval\sqrt{\hat p(1 - \hat p)/n_{\text{val}}} — so that the noise is approximately N(0,1)\mathcal{N}(0, 1).
  2. Fit a KDE (or Lindsey’s method) to the standardized scores and apply x+ℓ^′(x)x + \hat\ell'(x).
  3. Report the corrected score of the leader, not its raw score; by Theorem 5, the correction stays valid even though we selected the leader on the data.

The explorer below runs the experiment. The default scenario is Example 1’s; averaged over the default draw and the next 19 resamples, the implementation here gives naive +1.27, Tweedie–KDE +0.13, and oracle −0.04 — the oracle sits near zero, as Theorem 5 predicts — and a single resample varies around those values. Raise the validation noise and watch the curse get worse and the correction get larger.

Scenario:
observed score xTweedie–KDE (g unknown)oracle E[θ | x]true score θ
234512468101214161820rank by observed validation scorescore
Mean overstatement, top 20
Naive (x)+1.02
Tweedie–KDE+0.02
Oracle Bayes−0.23
Is the leader really a leader?
This leaderboard's #1 truly scores θ = 3.79; 0.1% of the configurations score at least that well.
Across 200 simulated leaderboards like this one, the observed #1 is truly in the top 10% in 100% of them.
Remark 10 Other exponential families

Theorem 4 covers the Gamma and chi-square families as well, which is how one shrinks thousands of sample variances at once — the idea behind moderated tt-statistics in genomics (the limma approach), where each gene’s variance estimate borrows strength from all the others. Poisson rates are covered through Example 7. The structure is always the same: estimate the marginal, take a log-derivative, correct by the carrier.

Remark 11 Choosing the marginal estimate: KDE versus Lindsey

The KDE continues Topic 30 and needs no model, but its score oscillates in sparse tails, where only a few data points contribute to the softmax weights. Lindsey’s polynomial is smooth and extrapolates sensibly, but it needs a degree choice: J=5J = 5 to 77 is standard, and EFR2011 uses natural splines with 5 degrees of freedom and a sixth-degree polynomial in its examples. The interactive components in this topic use KDE; the prostate figures use Lindsey.

Remark 12 Selection: Bayesian immunity versus frequentist selective inference

Theorem 5 needs the true gg. Empirical Bayes estimates tgt_g, so the immunity is inherited only approximately; EFR2011 gives the empirical evidence that it holds up well in practice. The frequentist alternative keeps θ\theta fixed and builds intervals that are valid conditional on the selection event — selective inference: formalML: selective-inference . The two answer different questions: selective inference controls error over repetitions of the selection, while the posterior mean averages over the ensemble of effects that produced the data.

33.6 g-modeling: the nonparametric MLE of the prior

f-modeling sidesteps the prior. g-modeling goes straight at it: find the prior that makes the observed data most likely, over all priors. This is maximum likelihood (Topic 14) over an infinite-dimensional parameter — a probability measure.

Definition 5 NPMLE of the mixing distribution (KIE1956)

The nonparametric maximum-likelihood estimator of the prior is

G^=arg⁡max⁡G∑i=1Nlog⁡fG(xi),fG(x)=∫φσ(x−θ) dG(θ),\hat G = \arg\max_G \sum_{i=1}^N \log f_G(x_i), \qquad f_G(x) = \int \varphi_\sigma(x - \theta)\,dG(\theta),

where the maximum is over all probability measures GG on R\mathbb{R}. The objective is concave in GG: fGf_G is linear in GG, and the logarithm of a linear function is concave.

Theorem 6 Existence, discreteness, and the gradient characterization of the NPMLE (stated, LIN1983)

Let x1,…,xNx_1, \dots, x_N have nn distinct values, and ℓ(G)=∑ilog⁡fG(xi)\ell(G) = \sum_i \log f_G(x_i) with fG(x)=∫φσ(x−θ) dG(θ)f_G(x) = \int \varphi_\sigma(x - \theta)\,dG(\theta) over all probability measures GG on R\mathbb{R}. (a) ℓ\ell attains its maximum, and the fitted values fG^(x1),…,fG^(xN)f_{\hat G}(x_1), \dots, f_{\hat G}(x_N) are the same for every maximizer G^\hat G. (b) Some maximizer is discrete with at most nn support points, all in [min⁡ixi,max⁡ixi][\min_i x_i, \max_i x_i]. (c) G^\hat G maximizes ℓ\ell if and only if the gradient function

DG^(θ)  =  1N∑i=1Nφσ(xi−θ)fG^(xi)D_{\hat G}(\theta) \;=\; \frac1N\sum_{i=1}^N \frac{\varphi_\sigma(x_i - \theta)}{f_{\hat G}(x_i)}

satisfies DG^(θ)≤1D_{\hat G}(\theta) \le 1 for all θ\theta, with equality at every support point of G^\hat G.

The intuition for (c): DG^(θ)−1D_{\hat G}(\theta) - 1 is the directional derivative of the concave average log-likelihood in the direction of a point mass at θ\theta. At the optimum, no direction improves it, so D≤1D \le 1 everywhere; and moving mass off a support point can’t help either, which forces D=1D = 1 there (LIN1983).

Theorem 7 Consistency and regret of NPMLE empirical Bayes (stated, KIE1956, JIA2009)

(a) (Kiefer–Wolfowitz 1956.) If θi∼G\theta_i \sim G i.i.d. and Xi∣θi∼N(θi,σ2)X_i \mid \theta_i \sim \mathcal{N}(\theta_i, \sigma^2), then G^N→G\hat G_N \to G weakly, almost surely. (b) (Jiang–Zhang 2009.) Under mild moment conditions on the unknown means, the rule tG^Nt_{\hat G_N} (“general maximum likelihood empirical Bayes”) has compound risk RN(tG^N;θ)=(1+o(1)) RN(tGN;θ)R_N(t_{\hat G_N}; \theta) = (1 + o(1))\,R_N(t_{G_N}; \theta) — asymptotically as good as the oracle separable rule of Theorem 1 — provided that oracle risk is of larger order than (log⁡N)5/N(\log N)^5/N.

Part (b) is the payoff of the whole compound-decision frame: the NPMLE rule achieves the benchmark of Theorem 1 without knowing GNG_N, for essentially any configuration of the means. Part (a) says the estimated prior converges too, but weakly — in the sense of distribution functions, not densities — which is why we judge g-modeling by its rule rather than by how G^\hat G looks.

Computing the NPMLE. Restrict GG to a fixed grid ϑ1<⋯<ϑK\vartheta_1 < \dots < \vartheta_K on [min⁡x,max⁡x][\min x, \max x] with weights wk≥0w_k \ge 0 summing to 1. The EM algorithm (LAI1978) updates

wk  ←  wk⋅1N∑i=1Nφσ(xi−ϑk)f^(xi),f^(xi)=∑k′wk′φσ(xi−ϑk′).w_k \;\leftarrow\; w_k \cdot \frac1N\sum_{i=1}^N \frac{\varphi_\sigma(x_i - \vartheta_k)}{\hat f(x_i)}, \qquad \hat f(x_i) = \sum_{k'} w_{k'}\varphi_\sigma(x_i - \vartheta_{k'}).

The factor multiplying wkw_k is exactly the gradient function D(ϑk)D(\vartheta_k) of Theorem 6: EM raises the weight of every grid point where D>1D > 1 and lowers it where D<1D < 1, and its fixed points have D=1D = 1 wherever wk>0w_k > 0. Each step increases the likelihood, and we stop when max⁡kD(ϑk)≤1+ϵ\max_k D(\vartheta_k) \le 1 + \epsilon — the certificate of Theorem 6(c). The empirical-Bayes rule is then

tG^(x)=∑kϑk wk φσ(x−ϑk)∑kwk φσ(x−ϑk),t_{\hat G}(x) = \frac{\sum_k \vartheta_k\, w_k\, \varphi_\sigma(x - \vartheta_k)}{\sum_k w_k\, \varphi_\sigma(x - \vartheta_k)},

a genuine Bayes rule for the prior G^\hat G, and therefore monotone by Theorem 3(iii).

Example 10 Recovering a three-atom prior

Take g=0.15 δ−1.5+0.6 δ0+0.25 δ2g = 0.15\,\delta_{-1.5} + 0.6\,\delta_0 + 0.25\,\delta_2 — three types of unit, with no spread within a type — with N=1000N = 1000, σ=1\sigma = 1, a 181-point grid on [−4,5][-4, 5], and 20,000 EM steps. The estimated mass concentrates in three clusters near the true atoms, with cluster masses 0.07 / 0.66 / 0.26 (true 0.15 / 0.60 / 0.25), and max⁡θD(θ)=1.00003\max_\theta D(\theta) = 1.00003: the Theorem 6(c) certificate is satisfied. The fit is not perfect, and it shouldn’t be — the atoms at −1.5-1.5 and 00 are only 1.5σ1.5\sigma apart, so at N=1000N = 1000 the data can’t fully separate them, and some of the −1.5-1.5 atom’s mass is absorbed by the atom at 0.

Two panels. Left: the NPMLE prior estimated by grid EM drawn as teal stems, with the three true atoms as emerald diamonds and cluster-mass labels 0.07, 0.66, and 0.26 against true masses 0.15, 0.60, and 0.25. Right: the gradient function D of theta in teal, touching the dashed line D equals 1 on the support of the estimate and lying below it elsewhere.

Figure 6. g-modeling: the NPMLE concentrates its mass near the true atoms, and the gradient function certifies optimality by touching 1 exactly on its support.

The fitter below runs the EM live. Step it a few times from the uniform start, then run it to the certificate and watch the gradient function settle onto the line D=1D = 1. The bottom panel compares the resulting NPMLE rule with Tweedie–KDE and the oracle.

True prior g:
Grid
iteration 0log-lik -2215.23mass > 0.001 on 181 of 181 grid pointsmax D = 1.9600 — not yet optimal
| NPMLE Ĝ (grid weights) · ◆ true atoms
00.20.40.6Ĝ 0.36 · true 0.15Ĝ 0.19 · true 0.60Ĝ 0.44 · true 0.25-4-2024θprior mass
— gradient function D(θ) · - - D = 1 · ● support points
00.511.52-4-2024θD(θ)
- - identity— oracle Bayes- - Tweedie–KDE (f-modeling)—● NPMLE rule t_Ĝ (g-modeling)
-4-2024-4-2024observation xestimate of θ
Remark 13 EM is slow; convex solvers are fast

EM smears mass over adjacent grid points — Example 10’s fit has 17 support points, not 3 — and converges sublinearly, which is why it needed 20,000 steps. On a fixed grid the problem is a finite-dimensional convex program, and interior-point methods solve it exactly in seconds (KOE2014; the R package REBayes). We use EM here because each step is one line, it is monotone, and it can be paused and resumed — which is what the fitter’s step buttons need.

Remark 14 A discrete prior estimate, a smooth rule

Theorem 6(b) makes G^\hat G discrete even when the true gg is continuous — try the Normal preset in the fitter. That is not a defect. The rule tG^t_{\hat G} is still a smooth function of xx, because it averages the atoms with Gaussian weights, and Theorem 7(b) is a statement about the rule, not about G^\hat G.

Remark 15 Reclaiming Topic 28's nonparametric prior

Topic 28 Remark 11 pointed “a nonparametric empirical-Bayes prior” toward formalML. The NPMLE is that object, and it lives here: James–Stein shrinks toward an implicitly estimated Normal prior, while g-modeling estimates the prior with no shape restriction at all. Positive-part James–Stein and the Baranchik family themselves remain Topic 28’s (§28.5).

33.7 f-modeling versus g-modeling

We now have two complete empirical-Bayes strategies. Which is better? The question matters in practice because the two disagree exactly where the decisions are made: in the tails, where the interesting genes and the winning configurations live.

Example 11 Regret against the oracle

Take a sparse prior g=0.9 δ0+0.1 N(3,0.52)g = 0.9\,\delta_0 + 0.1\,\mathcal{N}(3, 0.5^2) with σ=1\sigma = 1 — most effects are exactly zero, a few sit well above it — and run 40 replications for each NN. Regret is the per-coordinate mean squared error of each rule minus that of the oracle Bayes rule under the true gg, on the same sample:

NN100200500100020005000
MLE θ^=x\hat\theta = x0.79520.78020.78290.78970.76680.7681
Positive-part James–Stein0.25250.25640.25580.25010.24740.2482
Tweedie–KDE0.14160.09580.06560.04560.02860.0196
NPMLE–EB0.06470.03360.01800.00960.00330.0025

The MLE’s regret does not shrink with NN: it never learns anything from the ensemble. Positive-part James–Stein’s regret is flat too, at about 0.25 — linear shrinkage cannot adapt to sparsity, because no single shrinkage factor is right both for the zeros and for the effects near 3. The two nonparametric rules learn the prior: Tweedie–KDE’s regret falls from 0.142 to 0.020, and the NPMLE rule’s from 0.065 to 0.0025.

Log-log plot of regret against the oracle Bayes rule versus the number of parallel problems N from 100 to 5,000, with plus or minus one Monte Carlo standard error bars: the MLE in amber, flat near 0.78; positive-part James-Stein in violet, flat near 0.25; Tweedie with a KDE marginal in sky blue, falling from 0.142 to 0.020; and the NPMLE rule in teal, falling from 0.065 to 0.0025.

Figure 7. Regret against the oracle Bayes rule. Empirical Bayes learns the prior — Tweedie–KDE and NPMLE regret fall with N — while the MLE and linear shrinkage stay flat.

Theorem 3(iii) gives a cheap diagnostic that needs no oracle: every Bayes rule is nondecreasing. An estimated rule that decreases somewhere cannot be the Bayes rule for any prior, so wherever it decreases it is wrong.

Example 12 Where f and g disagree: the prostate right tail

Restrict to z∈[2,5.4]z \in [2, 5.4], which contains the 223 genes with z>2z > 2, and compare three empirical-Bayes rules. The Tweedie–KDE rule (bandwidth h=0.21h = 0.21) is wildly non-monotone, with minimum slope −18.2-18.2: it maps z=4.47z = 4.47 to 1.20 while mapping z=4.25z = 4.25 to 2.35, so a larger observed effect gets a smaller estimated effect. Tweedie–Lindsey is monotone (minimum slope 0.57). The NPMLE rule is monotone (minimum slope 0.02) and saturates near 2.7, because the largest atom of G^\hat G sits at about 2.7 — a posterior mean can never exceed the largest value the prior allows. For the top gene, Lindsey estimates 4.64 and the NPMLE 2.72.

Two panels on the prostate right tail, z from 2 to 5.4. Left: the Tweedie rule with a KDE marginal dashed in sky blue, oscillating; the Tweedie rule with Lindsey's fit solid in sky blue; the NPMLE Bayes rule in teal, saturating near 2.7; and the naive rule dashed in amber; a rug marks the 223 genes with z above 2. Right: the slopes of the three rules, with the regions where the KDE rule's slope is negative shaded rose and labeled impossible for a Bayes rule.

Figure 8. Every Bayes rule is monotone. In the sparse prostate tail the KDE-based rule is not; Lindsey’s smooth fit and the NPMLE rule are — but they disagree about how far to shrink.

Remark 16 Reading the disagreement

In the bulk of the data all three rules agree. In the sparse tail, f-modeling extrapolates the shape of f^\hat f — Lindsey’s polynomial keeps bending at the rate it bent where data were plentiful — while g-modeling refuses to place prior mass where no cluster of data supports it, and so caps the estimate at its largest atom. Neither is “right” from 223 tail genes. EFR2019 discusses the oracle-Bayes benchmark and why g-modeling’s extra structure usually wins on regret (Example 11), while f-modeling is easier to compute and to explain. A good habit: when the two disagree about the decision you care about, report both.

Remark 17 Rates and shape constraints

Brown and Greenshtein (BRO2009) show that kernel f-modeling with a slowly shrinking bandwidth has vanishing relative regret, so the KDE route is asymptotically sound; Example 12’s pathology is a finite-sample problem. Koenker and Mizera (KOE2014) repair it directly: imposing monotonicity of the rule — equivalently, convexity of x2/2+σ2log⁡f(x)x^2/2 + \sigma^2\log f(x) — turns the KDE estimate into a convex program whose solution is always a legitimate Bayes-rule shape.

33.8 Large-scale inference as empirical Bayes

Topic 27 introduced the two-groups model for thousands of simultaneous tests (§27.9). Each zz-score comes from the null with probability π0\pi_0 and from a non-null distribution otherwise, so the marginal density is f=π0f0+(1−π0)f1f = \pi_0 f_0 + (1 - \pi_0) f_1, and the local false discovery rate

fdr(z)=π0f0(z)f(z)\mathrm{fdr}(z) = \frac{\pi_0 f_0(z)}{f(z)}

is the posterior probability that a case with score zz is null — a Bayes quantity. Topic 27 assumed the three ingredients were known: ff, the null density f0f_0, and π0\pi_0. Here we estimate all three from the 6,033 genes. That estimation step is empirical Bayes, and it is how screening at scale — genomics, fraud flags, A/B-test portfolios — is done in practice.

Definition 6 Empirical null by central matching (EFR2004)

Fit a quadratic log⁡f^(z)≈a+bz+cz2\log\hat f(z) \approx a + bz + cz^2 to the log of the estimated marginal on a central interval ([−2,2][-2, 2] here), where nearly all cases are null, and match it to the log of a scaled Normal, log⁡[π0φδ0,σ0(z)]\log[\pi_0\varphi_{\delta_0,\sigma_0}(z)], where φδ0,σ0\varphi_{\delta_0,\sigma_0} is the N(δ0,σ02)\mathcal{N}(\delta_0, \sigma_0^2) density. Matching the coefficients of z2z^2, zz, and 11 gives

σ^0=(−2c)−1/2,δ^0=−b2c,π^0=exp⁡ ⁣(a+δ^022σ^02)2π σ^0.\hat\sigma_0 = (-2c)^{-1/2}, \qquad \hat\delta_0 = -\frac{b}{2c}, \qquad \hat\pi_0 = \exp\!\Big(a + \frac{\hat\delta_0^2}{2\hat\sigma_0^2}\Big)\sqrt{2\pi}\,\hat\sigma_0.
Example 13 Prostate empirical null

Central matching on the Lindsey fit of Example 8 gives (δ^0,σ^0,π^0)=(\hat\delta_0, \hat\sigma_0, \hat\pi_0) = (−0.001, 1.060, 0.980); EFR2008 reports (0.00,1.06)(0.00, 1.06). The null is centered where theory says, but it is 6% wider than N(0,1)\mathcal{N}(0, 1). That small change matters a great deal. Counting genes with fdr^≤0.2\widehat{\mathrm{fdr}} \le 0.2: the theoretical null flags 51 (26 right, 25 left); the empirical null flags 21 (13 right, 8 left). A 6% wider null removes more than half of the discoveries, because the discoveries live in the tails, where a slightly wider null puts a lot more null mass.

Two panels. Left: a density histogram of the prostate z-scores with Lindsey's estimated marginal in sky blue, the theoretical null standard Normal dashed in slate, and the empirical null, pi-hat-zero times a Normal with mean 0.00 and standard deviation 1.06, in rose. Right: the estimated local false discovery rate under the theoretical null, 51 genes, 26 right and 25 left, and under the empirical null, 21 genes, 13 right and 8 left, with a dotted line at 0.2.

Figure 9. Large-scale inference as empirical Bayes: an empirical null fit by central matching is 6% wider than N(0,1) and cuts the genes at fdr ≤ 0.2 from 51 to 21.

The Benjamini–Hochberg procedure of Topic 20 looks like a purely frequentist device. It is also an empirical-Bayes estimate.

Example 14 Benjamini–Hochberg is an empirical-Bayes estimate

Define the tail-area false discovery rate Fdr(z)=π0S0(z)/S(z)\mathrm{Fdr}(z) = \pi_0 S_0(z)/S(z), where SS and S0S_0 are the survival functions of ∣Z∣|Z| under the mixture and under the null: the posterior probability that a case is null given that its score is at least as extreme as zz. Estimate each piece crudely: π0=1\pi_0 = 1; S0(∣z∣)=pS_0(|z|) = p, the two-sided pp-value; and the empirical survival function S^(p(k))=k/N\hat S(p_{(k)}) = k/N at the kk-th smallest pp-value. Then

Fdr^(p(k))=Np(k)k.\widehat{\mathrm{Fdr}}(p_{(k)}) = \frac{N p_{(k)}}{k}.

Benjamini–Hochberg rejects the hypotheses with the k∗k^* smallest pp-values, where

k∗=max⁡{k:p(k)≤kq/N}=max⁡{k:Fdr^(p(k))≤q},k^* = \max\{k : p_{(k)} \le kq/N\} = \max\{k : \widehat{\mathrm{Fdr}}(p_{(k)}) \le q\},

which is the largest tail region whose empirical-Bayes estimate of the Fdr is at most qq. On the prostate data with q=0.1q = 0.1, BH rejects 60 genes. The frequentist guarantee — FDR control under independence — is Topic 20’s §20.7 Theorem 5 (Topic 20); the empirical-Bayes reading explains why the procedure has the form it has.

Remark 18 What is new relative to Topic 27

Topic 27 derived the local fdr with a theoretical null and a known mixture. The only new content here is estimating π0\pi_0, ff, and f0f_0 from the ensemble — and that is exactly the empirical-Bayes step. Topic 27’s LocalFDRExplorer already exposes a theoreticalNull: false switch (Topic 27 Remark 24); central matching is the estimator behind it.

Remark 19 Why the null widens

Correlation among genes, unobserved covariates that affect many genes at once, and miscalibrated test statistics all widen the central peak of the zz-score histogram, and Efron’s analyses find all three at work in microarray data. The empirical null absorbs them without our having to model them. Correlation-adjusted inference proper is out of scope for this topic.

33.9 Empirical-Bayes confidence intervals

Point estimates are half the job. Per-item uncertainty — an interval for each gene’s effect, each item’s click-through rate, each user’s treatment effect — is the other half, and it is where empirical Bayes is most often misused. Topic 28 Remark 16 said that empirical-Bayes intervals are “too narrow.” This section makes that precise, and shows the sense in which they are not. We need two more pieces of notation: Φ(c)=P(Z≤c)\Phi(c) = P(Z \le c) is the standard Normal cumulative distribution function, and z1−α/2z_{1-\alpha/2} is its (1−α/2)(1 - \alpha/2) quantile (z0.975=1.96z_{0.975} = 1.96).

Definition 7 EBCI; average versus conditional coverage

In the Normal–Normal model with known (μ,τ2,σ2)(\mu, \tau^2, \sigma^2) and shrinkage factor B=σ2/(σ2+τ2)B = \sigma^2/(\sigma^2 + \tau^2), the parametric empirical-Bayes confidence interval (EBCI) is

(1−B)X+Bμ  ±  z1−α/2(1−B)σ2.(1 - B)X + B\mu \;\pm\; z_{1-\alpha/2}\sqrt{(1 - B)\sigma^2}.

Its conditional coverage at θ\theta is P(θ∈CI∣θ)P(\theta \in \mathrm{CI} \mid \theta), a frequentist probability with θ\theta held fixed. Its average coverage is ∫P(θ∈CI∣θ) dg(θ)\int P(\theta \in \mathrm{CI} \mid \theta)\,dg(\theta) — equivalently, the long-run fraction of the NN intervals that cover their own θi\theta_i.

Theorem 8 EBCI coverage: exact on average, not conditionally

Let θ∼N(μ,τ2)\theta \sim \mathcal{N}(\mu, \tau^2) and X∣θ∼N(θ,σ2)X \mid \theta \sim \mathcal{N}(\theta, \sigma^2) with (μ,τ2,σ2)(\mu, \tau^2, \sigma^2) known, B=σ2/(σ2+τ2)B = \sigma^2/(\sigma^2 + \tau^2), m(X)=(1−B)X+Bμm(X) = (1-B)X + B\mu, v=(1−B)σ2v = (1-B)\sigma^2, z=z1−α/2z = z_{1-\alpha/2}, and CI(X)=[m(X)−zv,  m(X)+zv]\mathrm{CI}(X) = [m(X) - z\sqrt v,\; m(X) + z\sqrt v]. Then:

(i) P(θ∈CI(X))=1−αP\big(\theta \in \mathrm{CI}(X)\big) = 1 - \alpha, the probability taken over (θ,X)(\theta, X) jointly;

(ii) for fixed θ\theta with δ=θ−μ\delta = \theta - \mu and b=Bδ/((1−B)σ)b = B\delta/((1-B)\sigma),

c(δ)  =  P(θ∈CI(X)∣θ)  =  Φ(z1−B−b)−Φ(−z1−B−b);c(\delta) \;=\; P\big(\theta \in \mathrm{CI}(X) \mid \theta\big) \;=\; \Phi\Big(\frac{z}{\sqrt{1-B}} - b\Big) - \Phi\Big(-\frac{z}{\sqrt{1-B}} - b\Big);

(iii) c(0)>1−αc(0) > 1 - \alpha and c(δ)→0c(\delta) \to 0 as ∣δ∣→∞|\delta| \to \infty.

Proof 6 Proof of Thm 8 (average and conditional coverage of the parametric EBCI) [show]

(i) By Topic 28 §28.6 Thm 4, θ∣X∼N(m(X),v)\theta \mid X \sim \mathcal{N}(m(X), v). Hence, for every value of XX, P(θ∈CI(X)∣X)=P(∣Z∣≤z)=1−αP(\theta \in \mathrm{CI}(X) \mid X) = P(|Z| \le z) = 1 - \alpha with Z∼N(0,1)Z \sim \mathcal{N}(0,1); averaging over XX leaves 1−α1 - \alpha.

(ii) Fix θ\theta. Rewrite the estimation error as a noise part and a bias part:

θ−m(X)  =  (1−B)(θ−X)+B(θ−μ).\theta - m(X) \;=\; (1 - B)(\theta - X) + B(\theta - \mu).

Given θ\theta, X−θ∼N(0,σ2)X - \theta \sim \mathcal{N}(0, \sigma^2), so θ−m(X)∼N(Bδ, (1−B)2σ2)\theta - m(X) \sim \mathcal{N}\big(B\delta,\, (1-B)^2\sigma^2\big). Standardizing by (1−B)σ(1-B)\sigma gives W∼N(b,1)W \sim \mathcal{N}(b, 1). The interval covers exactly when ∣θ−m(X)∣≤zv|\theta - m(X)| \le z\sqrt v, that is, when

∣W∣  ≤  z(1−B)σ2(1−B)σ  =  z1−B,|W| \;\le\; \frac{z\sqrt{(1-B)\sigma^2}}{(1-B)\sigma} \;=\; \frac{z}{\sqrt{1-B}},

and P(∣W∣≤c)=Φ(c−b)−Φ(−c−b)P(|W| \le c) = \Phi(c - b) - \Phi(-c - b) for W∼N(b,1)W \sim \mathcal{N}(b, 1).

(iii) At δ=0\delta = 0, b=0b = 0 and c(0)=2Φ(z/1−B)−1>2Φ(z)−1=1−αc(0) = 2\Phi(z/\sqrt{1-B}) - 1 > 2\Phi(z) - 1 = 1 - \alpha, because 0<1−B<10 < 1 - B < 1. As ∣δ∣→∞|\delta| \to \infty, ∣b∣→∞|b| \to \infty and both Φ\Phi terms tend to the same limit (both to 1 if b→−∞b \to -\infty, both to 0 if b→+∞b \to +\infty), so c(δ)→0c(\delta) \to 0. ■\blacksquare — using the Normal–Normal posterior (Topic 28 §28.6 Thm 4).

◼

A consistency check ties (ii) back to (i). Averaging over δ∼N(0,τ2)\delta \sim \mathcal{N}(0, \tau^2) makes b∼N(0,σ2/τ2)b \sim \mathcal{N}(0, \sigma^2/\tau^2), since B/(1−B)=σ2/τ2B/(1-B) = \sigma^2/\tau^2. Unconditionally, then, W∼N(0,1+σ2/τ2)=N(0,1/(1−B))W \sim \mathcal{N}(0, 1 + \sigma^2/\tau^2) = \mathcal{N}(0, 1/(1-B)), and P(∣W∣≤z/1−B)=1−αP(|W| \le z/\sqrt{1-B}) = 1 - \alpha — part (i) again, by direct computation. The two parts together say what “too narrow” means: the interval is exactly right on average across units, and it pays for that by overcovering units near the prior mean and badly undercovering units far from it.

The parametric guarantee leans on the prior being Normal. Armstrong, Kolesár, and Plagborg-Møller (ARM2022) keep only its variance.

Theorem 9 Robust EB confidence intervals (stated, ARM2022)

Let θ^=μ+w(X−μ)\hat\theta = \mu + w(X - \mu) with w=1−B=τ2/(τ2+σ2)w = 1 - B = \tau^2/(\tau^2 + \sigma^2), and define the normalized bias b=(w−1)(θ−μ)/(wσ)b = (w - 1)(\theta - \mu)/(w\sigma), the non-coverage function r(b,χ)=P(∣Z−b∣>χ)r(b, \chi) = P(|Z - b| > \chi) for Z∼N(0,1)Z \sim \mathcal{N}(0,1), and

ρ(m2,χ)  =  sup⁡F  EF[r(b,χ)]subject toEF[b2]=m2.\rho(m_2, \chi) \;=\; \sup_F\; E_F\big[r(b, \chi)\big] \quad \text{subject to} \quad E_F[b^2] = m_2 .

With cvaα(m2)\mathrm{cva}_\alpha(m_2) the value of χ\chi solving ρ(m2,χ)=α\rho(m_2, \chi) = \alpha: (a) for every distribution of θ\theta with E(θ−μ)2=τ2E(\theta - \mu)^2 = \tau^2 — so that m2=σ2/τ2m_2 = \sigma^2/\tau^2 — the interval θ^±cvaα(m2) wσ\hat\theta \pm \mathrm{cva}_\alpha(m_2)\, w\sigma has average coverage at least 1−α1 - \alpha; (b) writing r0(t,χ)=r(t,χ)r_0(t, \chi) = r(\sqrt t, \chi) and t0=arg⁡max⁡t>0 (r0(t,χ)−r0(0,χ))/tt_0 = \arg\max_{t > 0}\,(r_0(t,\chi) - r_0(0,\chi))/t (t0=0t_0 = 0 when χ<3\chi < \sqrt 3),

ρ(m2,χ)  =  r0(0,χ)+m2max⁡(m2,t0)(r0(max⁡(m2,t0),χ)−r0(0,χ)),\rho(m_2, \chi) \;=\; r_0(0, \chi) + \frac{m_2}{\max(m_2, t_0)}\Big(r_0\big(\max(m_2, t_0), \chi\big) - r_0(0, \chi)\Big),

attained by the distribution putting mass 1−m2/t01 - m_2/t_0 at b=0b = 0 and m2/t0m_2/t_0 split equally at b=±t0b = \pm\sqrt{t_0} when m2<t0m_2 < t_0. The parametric EBCI of Theorem 8 corresponds to the smaller critical value z1−α/21+m2z_{1-\alpha/2}\sqrt{1 + m_2}.

The intuition: once only the variance of θ\theta is pinned down, nature can choose the prior that hurts the interval most, and the worst case piles most units exactly at the prior mean (where the interval overcovers, wasting nothing) and puts a few far out (where it undercovers badly). The robust critical value is the smallest one that survives that adversary (ARM2022, §2 and Prop. B.1).

Example 15 Equal noise and prior spread

Take σ=τ=1\sigma = \tau = 1, so B=1/2B = 1/2 and the parametric half-width is 1.960.5=1.3861.96\sqrt{0.5} = 1.386. Conditional coverage at ∣θ−μ∣=0,1,2,3|\theta - \mu| = 0, 1, 2, 3 (in units of τ\tau) is 0.994, 0.962, 0.780, 0.410, while the average is exactly 0.95. A unit three prior standard deviations from the mean — a genuine outlier, the kind we most want to get right — is covered 41% of the time.

The robust critical value is cva0.05(1)=\mathrm{cva}_{0.05}(1) = 3.259, so the robust half-width is 3.259×0.5=1.6303.259 \times 0.5 = 1.630, 18% wider than the parametric one. Average coverage under three priors, all with variance τ2\tau^2:

Prior ggParametricRobust
Normal N(μ,τ2)\mathcal{N}(\mu, \tau^2)0.9500.979
Spike-and-slab 0.9 δμ+0.1 N(μ,10)0.9\,\delta_\mu + 0.1\,\mathcal{N}(\mu, 10)0.9550.966
Least favorable: mass 0.889 at μ\mu, 0.111 split at μ±2.995τ\mu \pm 2.995\tau0.9290.950

The parametric interval’s average guarantee breaks under the least-favorable prior; the robust interval’s holds for all three.

Two panels. Left: conditional coverage against theta minus mu in units of tau for the parametric EBCI with critical value 2.772 in indigo, the robust EBCI with critical value 3.259 in teal, and the unshrunk interval x plus or minus 1.96 sigma in amber, flat at 0.95, over a shaded prior density. Right: average coverage bars under Normal, spike-and-slab, and least-favorable priors, all with variance tau squared: parametric 0.950, 0.955, and 0.929; robust 0.979, 0.966, and 0.950.

Figure 10. Empirical-Bayes intervals cover on average but not individually: conditional coverage dips in the tails, and robust intervals keep the average guarantee for every prior with the right variance.

Example 16 Eight schools: the zero-width interval

Topic 28’s Type-II MLE on the eight-schools data (§28.7, Example 9) found τ^2=0\hat\tau^2 = 0. Then B^k=1\hat B_k = 1 for every school, and every plug-in EBCI collapses to the single point μ^=7.69\hat\mu = 7.69 with zero width — the extreme case of “too narrow.” Plug-in robust EBCIs inherit the problem, since m2=σk2/τ^2=∞m_2 = \sigma_k^2/\hat\tau^2 = \infty. The fix is to account for the uncertainty in τ^2\hat\tau^2 (Remark 20) or to go fully Bayes with a weakly informative hyperprior (Topic 28 Remark 17).

Remark 20 Hyperparameter uncertainty: Morris and Laird–Louis

Theorem 8 assumed (μ,τ2)(\mu, \tau^2) known. In practice they are estimated, and the plug-in interval ignores that error. Morris (MOR1983) inflates the interval with an analytic correction for estimating the hyperparameters; Laird and Louis (LAI1987) use a parametric bootstrap — the “corrected EB” workflow Topic 28 Remark 16 named. Nonparametric EBCIs that drop the Normal-prior assumption altogether (Ignatiadis and Wager) are beyond this topic.

Remark 21 How badly can the parametric interval undercover?

Across all priors with the right variance and all shrinkage levels, the parametric EBCI’s average non-coverage can reach 1/max⁡{z1−α/22,1}=0.2601/\max\{z_{1-\alpha/2}^2, 1\} = 0.260 at α=0.05\alpha = 0.05 (ARM2022, Lemma 4.1) — 74% coverage for a nominal 95% interval. Adding a constraint on the kurtosis of the prior narrows the robust interval (ARM2022, §3). The ML reading: per-item uncertainty for shrunken estimates — per-arm click-through rates in a bandit, per-user treatment effects, per-segment conversion rates — should be reported with robust EBCIs, not plug-in posterior intervals, whenever there is no strong reason to believe the effects are Normally distributed.

33.10 Forward look

The spine of this topic is one idea in five forms. Robbins showed that a large ensemble can stand in for an unknown prior, and that for Poisson counts the Bayes rule can be read off the marginal frequencies. Tweedie’s formula did the same for Normal noise and made the picture geometric: the Bayes correction is σ2\sigma^2 times the score of the marginal, a field of arrows pointing uphill on ff, which is why it deflates the winner’s curse and why it survives selection. The NPMLE estimated the prior outright and, through the compound-decision theorem, achieved the oracle’s risk without knowing the oracle’s prior. Large-scale testing turned out to be the same computation applied to the null, and empirical-Bayes intervals turned out to promise average coverage across units — no more, and no less. Topic 28 remains the closer of Track 7’s core arc; this topic is its nonparametric coda, and the remaining threads lead to formalML.

Remark 22 Fully Bayesian nonparametrics

g-modeling maximizes over priors. The fully Bayesian alternative puts a prior on the prior — a Dirichlet process on gg — and integrates over it instead of maximizing. Dirichlet-process mixtures are the Bayesian counterpart of the NPMLE, with posterior uncertainty about gg built in: formalML: bayesian-nonparametrics .

Remark 23 Meta-learning is empirical Bayes over tasks

In meta-learning, many related tasks play the role of the NN parallel problems, and the learned initialization or prior plays the role of g^\hat g: training across tasks estimates the prior, and adapting to a new task shrinks its estimate toward what the prior expects. formalML’s meta-learning topic develops the parametric (Type-II) version in its §6.3; this topic supplies the nonparametric toolkit and the compound-decision justification: formalML: meta-learning .

Remark 24 Heteroskedastic and multivariate empirical Bayes

Everything here assumed a common noise level σ\sigma. Real ensembles rarely cooperate: Efron and Morris’s baseball batting averages (EFR1975) already had unequal sample sizes, and shrinkage with unequal σi\sigma_i is done well by minimizing Stein’s unbiased risk estimate (SURE; XIE2012). The NPMLE extends to multivariate parameters and to heteroskedastic noise, and nonparametric empirical-Bayes intervals are an active research area. Each is a natural next step from the tools of this topic.


References

  1. Robbins, Herbert. (1956). An Empirical Bayes Approach to Statistics. In Proceedings of the Third Berkeley Symposium on Mathematical Statistics and Probability, Vol. 1 (University of California Press), 157–163.
  2. Robbins, Herbert. (1951). Asymptotically Subminimax Solutions of Compound Statistical Decision Problems. In Proceedings of the Second Berkeley Symposium on Mathematical Statistics and Probability (University of California Press), 131–148.
  3. Zhang, Cun-Hui. (2003). Compound Decision Theory and Empirical Bayes Methods. Annals of Statistics, 31(2), 379–390.
  4. Efron, Bradley, and Carl Morris. (1973). Stein’s Estimation Rule and Its Competitors — An Empirical Bayes Approach. Journal of the American Statistical Association, 68(341), 117–130.
  5. James, Willard, and Charles Stein. (1961). Estimation with Quadratic Loss. In Proceedings of the Fourth Berkeley Symposium on Mathematical Statistics and Probability, Vol. 1 (University of California Press), 361–379.
  6. Efron, Bradley, and Trevor Hastie. (2016). Computer Age Statistical Inference: Algorithms, Evidence, and Data Science. Cambridge University Press.
  7. Efron, Bradley. (2011). Tweedie’s Formula and Selection Bias. Journal of the American Statistical Association, 106(496), 1602–1614.
  8. Vincent, Pascal. (2011). A Connection Between Score Matching and Denoising Autoencoders. Neural Computation, 23(7), 1661–1674.
  9. Dawid, A. Philip. (1994). Selection Paradoxes of Bayesian Inference. In Multivariate Analysis and Its Applications, IMS Lecture Notes–Monograph Series 24, 211–220.
  10. Efron, Bradley, and Robert Tibshirani. (1996). Using Specially Designed Exponential Families for Density Estimation. Annals of Statistics, 24(6), 2431–2461.
  11. Singh, Dinesh, Phillip G. Febbo, Kenneth Ross, et al. (2002). Gene Expression Correlates of Clinical Prostate Cancer Behavior. Cancer Cell, 1(2), 203–209.
  12. Kiefer, J., and J. Wolfowitz. (1956). Consistency of the Maximum Likelihood Estimator in the Presence of Infinitely Many Incidental Parameters. Annals of Mathematical Statistics, 27(4), 887–906.
  13. Laird, Nan. (1978). Nonparametric Maximum Likelihood Estimation of a Mixing Distribution. Journal of the American Statistical Association, 73(364), 805–811.
  14. Lindsay, Bruce G. (1983). The Geometry of Mixture Likelihoods: A General Theory. Annals of Statistics, 11(1), 86–94.
  15. Jiang, Wenhua, and Cun-Hui Zhang. (2009). General Maximum Likelihood Empirical Bayes Estimation of Normal Means. Annals of Statistics, 37(4), 1647–1684.
  16. Koenker, Roger, and Ivan Mizera. (2014). Convex Optimization, Shape Constraints, Compound Decisions, and Empirical Bayes Rules. Journal of the American Statistical Association, 109(506), 674–685.
  17. Brown, Lawrence D., and Eitan Greenshtein. (2009). Nonparametric Empirical Bayes and Compound Decision Approaches to Estimation of a High-Dimensional Vector of Normal Means. Annals of Statistics, 37(4), 1685–1704.
  18. Efron, Bradley. (2014). Two Modeling Strategies for Empirical Bayes Estimation. Statistical Science, 29(2), 285–301.
  19. Efron, Bradley. (2019). Bayes, Oracle Bayes and Empirical Bayes. Statistical Science, 34(2), 177–201.
  20. Efron, Bradley. (2004). Large-Scale Simultaneous Hypothesis Testing: The Choice of a Null Hypothesis. Journal of the American Statistical Association, 99(465), 96–104.
  21. Efron, Bradley. (2008). Microarrays, Empirical Bayes and the Two-Groups Model. Statistical Science, 23(1), 1–22.
  22. Efron, Bradley. (2010). Large-Scale Inference: Empirical Bayes Methods for Estimation, Testing, and Prediction. Cambridge University Press.
  23. Morris, Carl N. (1983). Parametric Empirical Bayes Inference: Theory and Applications. Journal of the American Statistical Association, 78(381), 47–55.
  24. Laird, Nan M., and Thomas A. Louis. (1987). Empirical Bayes Confidence Intervals Based on Bootstrap Samples. Journal of the American Statistical Association, 82(399), 739–750.
  25. Armstrong, Timothy B., Michal Kolesár, and Mikkel Plagborg-Møller. (2022). Robust Empirical Bayes Confidence Intervals. Econometrica, 90(6), 2567–2602.
  26. Efron, Bradley, and Carl Morris. (1975). Data Analysis Using Stein’s Estimator and Its Generalizations. Journal of the American Statistical Association, 70(350), 311–319.
  27. Xie, Xianchao, S. C. Kou, and Lawrence D. Brown. (2012). SURE Estimates for a Heteroscedastic Hierarchical Model. Journal of the American Statistical Association, 107(500), 1465–1479.