45.03.03 · mathematical-statistics / 03-bayesian-inference

Hierarchical and Empirical Bayes

shipped3 tiersLean: none

Anchor (Master): Efron 2010 Large-Scale Inference (Cambridge) Ch. 1-3 (parametric and nonparametric empirical Bayes, the f-modeling formula); Robbins 1956 An Empirical Bayes Approach to Statistics (Proc. Third Berkeley Symp. 1, 157-163); Morris 1983 Parametric Empirical Bayes Inference (J. Amer. Statist. Assoc. 78, 47-65)

Intuition Beginner

Imagine you must estimate the same kind of quantity for many groups at once — the success rate of a treatment in each of eight hospitals, say. You could pool everything into one number and pretend the hospitals are identical, or you could estimate each hospital alone and ignore the others. Both extremes waste information. The hospitals are not identical, but they are similar, and a sensible estimate for a hospital with little data should lean on what the other hospitals reveal about the typical rate.

A hierarchical model captures this middle ground. It says each group has its own true value, and those values are themselves a sample from a shared population of groups. You put a prior on each group's value, and a second prior — a hyperprior — on the population the groups are drawn from. The data then teach you two things at once: where each group sits, and what the whole population looks like.

The payoff is borrowing strength. A group with noisy or sparse data gets pulled toward the population average, because the model trusts the crowd when one group is uncertain. A group with plenty of clean data barely moves, because its own evidence speaks for itself. This selective pulling — strong for the uncertain, gentle for the confident — is called partial pooling, and it usually beats both extremes.

Visual Beginner

Picture three layers stacked like a family tree. At the top sits the population description (its center and spread). Below it hang the individual group values, each one a child of the population. At the bottom sit the data points, each a noisy reading of its group's value.

Layer What lives here Role
Top (hyperprior) population center and spread describes how groups vary
Middle (group values) one true value per group borrows from the population
Bottom (data) noisy measurements speaks for its own group

Read the arrows downward and you have the model: population shapes groups, groups shape data. Read them upward and you have the inference: data inform the groups, and pooled across groups they also reveal the population, which then pulls the uncertain groups inward.

Worked example Beginner

Two clinics measure the average recovery time for a procedure. The true clinic averages are unknown. Each clinic's measurement has noise of standard deviation days. Past experience says clinic averages scatter around a population center days with spread days.

Clinic A reports a measured average of days; clinic B reports days.

Step 1. Find the pull factor. The shrinkage factor measures how much weight the data deserve against the population. It is .

Step 2. Shrink clinic A. The hierarchical estimate moves the data toward the population center: days.

Step 3. Shrink clinic B. Same rule: days.

Step 4. Compare. Clinic A's raw became ; clinic B's raw became . Both were pulled about a third of the way to the population center .

What this tells us. The noise () is larger than the population spread (), so the model distrusts any single clinic's reading and pulls it firmly toward . If the clinics had been measured very precisely (small ), the factor would be near and the estimates would barely move. The hierarchy automatically tunes the pull to how much each level knows.

Check your understanding Beginner

Formal definition Intermediate+

A hierarchical (multilevel) model specifies a joint distribution through a chain of conditional distributions. For groups with group parameters , observed data , and a population-level hyperparameter , the model is

so that the joint density factors as

The defining structural feature is conditional independence: given the group parameters are independent, and given the datum is independent of everything else. The hyperprior is the prior on the population from which the are drawn; is the population distribution (sometimes called the prior at the second level). The marginal (or compound) sampling density of a single group, with held fixed, is

the data-generating density after integrating out the group parameter; it is the object 45.03.02 computes in closed form for conjugate pairs and the object empirical Bayes will estimate from.

The Gaussian hierarchical normal-means model. Take the conjugate normal hierarchy with known sampling variance and hyperparameter :

With fixed, the conjugate normal-normal update of 45.03.02 gives the group posterior

where is the shrinkage factor and measures how far each estimate is pulled from its own datum toward the population center . The posterior mean is a convex combination of the population center and the group's datum: partial pooling interpolates between complete pooling (, all ) and no pooling (, all ).

Empirical Bayes. Parametric empirical Bayes (EB) replaces the integration over by a point estimate obtained from the data through the marginal: the marginal MLE maximises the marginal likelihood

and the EB estimator of each is the conjugate posterior mean evaluated at . For the Gaussian hierarchy the marginal of given is , so and is read off the marginal sample variance, yielding estimated from the spread of the themselves.

Nonparametric (Robbins) empirical Bayes does not assume a parametric form for the population distribution at all. It estimates the posterior functional directly from the marginal — the -modeling strategy — using identities that express the posterior mean in terms of alone. For the Poisson sampling model with an arbitrary mixing distribution on the rates, Robbins' formula

recovers the posterior mean of the rate from ratios of the marginal frequencies, with no parametric assumption on .

Counterexamples to common slips Intermediate+

  • Empirical Bayes is not full hierarchical Bayes. EB plugs a point estimate into the posterior and treats it as known; hierarchical Bayes integrates against its hyperprior. The EB posterior therefore understates uncertainty, because it ignores the variability in . The two agree to first order when is large (the hyperprior is overwhelmed and is sharp), and diverge when is small.

  • A hyperprior is not optional decoration. Omitting the hyperprior — fixing at a guessed value — collapses the hierarchy to an ordinary conjugate model with no borrowing of strength across groups in the choice of . The borrowing comes precisely from letting all groups jointly inform the population level.

  • Improper hyperpriors can produce improper posteriors. The flat hyperprior or may seem harmless, but for the Gaussian hierarchy the joint posterior can fail to be integrable, especially the prior , which puts infinite mass near and yields an improper posterior. Propriety must be checked, not assumed.

Key theorem with proof Intermediate+

The organising result is that the hierarchical posterior mean is exactly the conjugate posterior mean evaluated at the hyperparameter, and that empirical Bayes estimates that hyperparameter from the marginal, so the EB shrinkage factor is a data-driven version of the hierarchical one.

Theorem (the Gaussian hierarchical posterior and its empirical-Bayes estimate). Let independently and independently, , with known.

(i) (Group posterior given the hyperparameter.) For fixed the posterior of is with , and the posterior mean is the partial-pooling estimate .

(ii) (Marginal.) Integrating out , the marginal of given is , with the independent across .

(iii) (Empirical-Bayes shrinkage.) The marginal MLE is and (taking the positive part of ), so the EB shrinkage factor is estimated from the empirical spread of the ; the EB estimator is .

Proof of (i). With fixed, the joint of is the conjugate normal-normal model of 45.03.02 with prior and likelihood . Working in precisions, the posterior precision is the sum of prior and data precisions, , and the posterior mean is the precision-weighted average

with . The posterior variance is .

Proof of (ii). Write with and independent. A sum of independent normals is normal with summed mean and variance, so . Independence across follows from the conditional-independence factorisation: .

Proof of (iii). By part (ii) the are i.i.d. with . The likelihood is the ordinary normal likelihood in , whose MLEs are the sample mean and sample variance . Inverting gives , the positive part guarding against a negative variance estimate when the groups cluster more tightly than sampling noise alone would predict. Substituting into yields and , the conjugate posterior mean of part (i) with replaced by their marginal MLEs.

Bridge. This theorem builds toward the parametric and nonparametric empirical-Bayes constructions of the Advanced section and the variance correction that hierarchical Bayes supplies over the plug-in EB estimate, and it appears again in the James-Stein estimator 45.06.04, whose shrinkage factor is precisely an unbiased estimate of the EB factor derived here. This is exactly the device that turns a fixed conjugate prior into a data-driven one: the marginal of 45.03.02 is the bridge between the parameter level and the population level, and maximising it over lets all groups jointly determine the prior. The central insight is that hierarchical and empirical Bayes are the same model read at two levels of completeness — the hierarchy integrates the hyperparameter, EB point-estimates it — so partial pooling, shrinkage, and borrowing strength are one phenomenon: a group with little information is pulled toward a population center the other groups reveal. Putting these together, the partial-pooling estimate exhibits the shrinkage of 45.03.01 as a convex combination whose weight generalises the single-group conjugate weight by tying it to the cross-group spread, and the prior-precision dial is dual to the ridge regularisation strength of 45.06.03, with EB choosing that dial automatically from the data.

Exercises Intermediate+

Advanced results Master

The hierarchy as a compound model and the marginal as the EB objective

The hierarchical model , , separates inference into two coupled problems: estimating the population level and estimating the group level . The coupling runs through the marginal , which is the only place the data touch once is integrated out. Full hierarchical Bayes computes the posterior and then the group posteriors , averaging the conjugate group posterior of 45.03.02 over the hyperparameter posterior. Parametric empirical Bayes truncates this to the single value , the marginal MLE, and reports . The two coincide in the limit , where concentrates at and the average over degenerates to evaluation at the mode. The marginal-MLE optimisation is itself a latent-variable problem — the are the latents — solved cleanly by the EM algorithm 45.08.07, whose E-step computes the conjugate group posteriors and whose M-step updates from the expected complete-data sufficient statistics; for the Gaussian hierarchy EM reproduces the closed-form , of the Key theorem.

Parametric EB, the variance correction, and the cost of point-estimating

The defect of plug-in empirical Bayes is that it treats the estimated hyperparameter as known, so the reported group-posterior variance omits the contribution of the uncertainty in . The honest variance, by the law of total variance, adds a term of order that records the randomness of and [Morris 1983]. Carl Morris' parametric-EB programme supplies the correction explicitly for the Gaussian hierarchy: the shrinkage factor is estimated by with (the rather than accounting for the estimation of ), and the corrected posterior variance inflates by a data-based estimate of the -uncertainty term. This is the precise sense in which empirical Bayes is approximate hierarchical Bayes: the point estimate is asymptotically efficient but throws away the hyperparameter's posterior spread, and the correction restores the part that matters at finite . The connection to shrinkage is exact — is the James-Stein factor 45.06.04, and the EB derivation is the cleanest route to understanding why estimating many means jointly dominates estimating each alone.

Nonparametric (Robbins) empirical Bayes and -modeling

Robbins' 1956 insight was that for many sampling models the posterior functional of interest depends on the mixing distribution only through the marginal , so one may estimate from the data and never estimate at all [Robbins 1956]. For the Poisson model the posterior mean is , recoverable from marginal frequencies; for the normal model with and arbitrary , Tweedie's formula gives the posterior mean as , again a functional of the marginal alone. This is the -modeling strategy — model the marginal density and differentiate, as opposed to -modeling, which posits a parametric or flexible form for and deconvolves [Efron 2010]. The -modeling route is robust because the marginal is directly observed, but it is delicate near the tails where is poorly estimated, and the derivative or ratio amplifies estimation error; modern large-scale-inference practice smooths the marginal (e.g. by a low-order exponential-family fit) before applying the formula. The deep point is that with thousands of parallel problems the marginal is estimated very accurately, so the empirical-Bayes correction becomes nearly as good as knowing the true prior — the regime Efron calls learning the prior from the ensemble.

Hierarchical generalisations and computation

Beyond the conjugate Gaussian and gamma-Poisson hierarchies, multilevel models stack arbitrarily many levels (groups within regions within countries), allow non-conjugate population distributions and link functions (hierarchical logistic and Poisson regression), and place structured hyperpriors (the half-Cauchy on is a standard weakly-informative default that avoids the improper-posterior hazards of the flat or choices). Outside the conjugate case the marginal has no closed form and neither full hierarchical Bayes nor the marginal MLE is analytic; the resolution is Markov chain Monte Carlo 45.03.05, where Gibbs sampling exploits the conditional conjugacy exhibited in Exercise 8 — each full conditional of a conjugate-within-level hierarchy is a closed-form update — and Hamiltonian Monte Carlo handles the non-conjugate and highly correlated cases. The hierarchy reorganises a high-dimensional posterior into a sequence of low-dimensional conditional updates, which is precisely what makes Gibbs sampling natural for multilevel models. Empirical Bayes survives in this computational landscape as the fast approximation: where MCMC integrates , EB maximises over it, trading a known understatement of uncertainty for a substantial reduction in cost.

Synthesis. The central insight is that hierarchical and empirical Bayes are one model read at two levels of completeness: the hierarchy of 45.03.02's conjugate update repeated across groups, with a hyperprior on the population, integrated in full Bayes and point-estimated in EB, so partial pooling, shrinkage, and borrowing strength are a single phenomenon. The foundational reason the marginal organises everything is that, after integrating out , it is the only channel through which data inform the population level — full Bayes computes , EB maximises , and Robbins estimates a posterior functional from alone — so the closed-form conjugate marginal of 45.03.02 is exactly the EB objective and the Robbins/Tweedie -modeling input. Putting these together, the Gaussian partial-pooling estimate generalises the single-group conjugate posterior mean by tying its weight to the cross-group spread, its EB factor is dual to the James-Stein factor 45.06.04 and to the ridge penalty of 45.06.03 under prior-precision-equals-regularisation, and the understatement of variance EB incurs appears again in the Morris correction and is resolved by integrating . The bridge is computation: the marginal MLE is an EM problem 45.08.07, the conditional conjugacy of the hierarchy is what a Gibbs sampler cycles, and the boundary where closed forms end — non-conjugate or deeply nested hierarchies — is where MCMC 45.03.05 takes over.

Full proof set Master

Proposition 1 (Gaussian hierarchical posterior and partial pooling). For and with fixed and known, with .

Proof. By the conditional-independence factorisation, . Collecting the quadratic in , the coefficient of is and the coefficient of is , so the posterior is normal with precision and mean . Multiplying numerator and denominator by gives mean and variance .

Proposition 2 (closed-form marginals: normal and negative-binomial). In the Gaussian hierarchy ; in the gamma-Poisson hierarchy is negative binomial with size and success probability .

Proof. For the Gaussian case is a sum of independent and variables, hence by convolution of normals. For the gamma-Poisson case,

using and for the generalised binomial coefficient. This is the negative binomial.

Proposition 3 (Robbins' formula and Tweedie's formula). For , , the posterior mean is . For , , the posterior mean is .

Proof. Poisson: with , the posterior mean is . The numerator equals , giving the ratio. Normal: write with the density. Differentiating under the integral, . Hence , where the last step uses that the posterior density of given is . Rearranging, .

Proposition 4 (asymptotic agreement of EB and hierarchical Bayes). In the Gaussian hierarchy with a fixed proper hyperprior and the marginal MLE, the hierarchical-Bayes group posterior mean and the empirical-Bayes mean differ by as .

Proof (sketch). The hierarchical posterior mean is . By the Bernstein-von Mises theorem applied to the marginal likelihood — a regular i.i.d. model in with observations — the posterior is asymptotically , concentrating at at rate . Expanding the smooth map around in a second-order Taylor series and integrating against this posterior, the first-order term vanishes (it multiplies the posterior-mean deviation ) and the second-order term contributes the curvature against the posterior covariance . Hence . The discrepancy is exactly the hyperparameter-uncertainty term the plug-in EB variance omits, of the same order.

Proposition 5 (improper hyperprior can give improper posterior). For the Gaussian hierarchy with groups and the hyperprior on , , the joint posterior is improper.

Proof. Integrate the joint posterior over to obtain the marginal posterior of , proportional to up to the -integration constant, where ; this follows from Proposition 2 (the marginal of the is ) and integrating the flat . With the integrand behaves like as , and diverges at the origin. The marginal posterior of is therefore not integrable near , so the joint posterior is improper. The flat prior avoids this particular divergence at the origin but must still be checked at infinity; the half-Cauchy on is proper at both ends.

Connections Master

  • Conjugate priors and exponential-family Bayesian inference 45.03.02 is the engine each level of the hierarchy runs: the group posterior is the conjugate normal-normal update with as the prior, the closed-form marginal that couples the levels is the conjugate marginal likelihood proved there, and the conditional conjugacy a Gibbs sampler exploits is that same update applied block by block. Hierarchical Bayes is conjugate Bayes repeated across groups with a hyperprior on the shared parameters.

  • Bayes estimation under loss 45.03.01 supplies the decision-theoretic reading: the partial-pooling estimate is the squared-error Bayes estimator of under the hierarchical prior, and the EB estimator is the feasible approximation that estimates that prior from the ensemble, so shrinkage toward the population center is the optimal compromise between the group's datum and the borrowed crowd information.

  • The James-Stein estimator and inadmissibility of the MLE 45.06.04 is the same shrinkage seen from frequentist decision theory: the James-Stein factor is an unbiased estimate of the hierarchical shrinkage , so James-Stein is the empirical-Bayes plug-in of the Gaussian hierarchy, and the dimension threshold is the condition under which the cross-group pooling strictly improves on estimating each mean alone.

  • The EM algorithm 45.08.07 solves the marginal-likelihood maximisation that defines parametric empirical Bayes: with the group parameters as latent variables, the E-step computes the conjugate group posteriors and the M-step updates the hyperparameter from the expected sufficient statistics, reproducing the closed-form , in the Gaussian case.

  • Markov chain Monte Carlo 45.03.05 is the resolution when the hierarchy is non-conjugate: full hierarchical Bayes integrates the hyperparameter rather than point-estimating it, and outside the conjugate case that integration is performed by Gibbs sampling — cycling the conditional-conjugate full conditionals derived here — or by Hamiltonian Monte Carlo for the correlated and non-conjugate levels.

Historical & philosophical context Master

The empirical-Bayes idea was introduced by Herbert Robbins at the Third Berkeley Symposium in 1956 [Robbins 1956], who observed that in a sequence of parallel estimation problems the prior could be estimated from the accumulated data without ever being assumed, deriving the formula for the Poisson mean from marginal frequencies alone. The connection to the Stein phenomenon was made by Bradley Efron and Carl Morris in a sequence of papers in the early 1970s, who showed the James-Stein estimator is the empirical-Bayes rule for the Gaussian hierarchy with the prior variance estimated from the ensemble; Carl Morris' 1983 Journal of the American Statistical Association paper [Morris 1983] gave the systematic parametric-EB theory, including the variance correction that accounts for the uncertainty in the estimated hyperparameter and so closes the honesty gap between empirical and full Bayes.

The full hierarchical (multilevel) treatment, in which the hyperparameter carries its own prior and is integrated rather than point-estimated, was developed in the Bayesian decision-theory tradition of I. J. Good, who coined the term hierarchical Bayes, and Dennis Lindley and Adrian Smith's 1972 Journal of the Royal Statistical Society B paper on Bayes estimates for the linear model, which derived the exchangeable normal hierarchy and its shrinkage estimators. The modern computational and applied synthesis is in Andrew Gelman and colleagues' Bayesian Data Analysis [Gelman 2013], whose eight-schools example became the canonical illustration of partial pooling, and Bradley Efron's Large-Scale Inference [Efron 2010] reframed empirical Bayes for the thousands-of-parallel-problems regime of genomics and high-throughput testing, distinguishing the -modeling and -modeling routes and establishing that with enough parallel problems the estimated prior is nearly as good as the true one.

Bibliography Master

@inproceedings{robbins1956empirical,
  author    = {Robbins, Herbert},
  title     = {An Empirical Bayes Approach to Statistics},
  booktitle = {Proceedings of the Third Berkeley Symposium on Mathematical Statistics and Probability},
  volume    = {1},
  pages     = {157--163},
  publisher = {University of California Press},
  year      = {1956}
}

@article{lindleysmith1972bayes,
  author  = {Lindley, Dennis V. and Smith, Adrian F. M.},
  title   = {Bayes Estimates for the Linear Model},
  journal = {Journal of the Royal Statistical Society. Series B},
  volume  = {34},
  number  = {1},
  pages   = {1--41},
  year    = {1972}
}

@article{efronmorris1973stein,
  author  = {Efron, Bradley and Morris, Carl},
  title   = {Stein's Estimation Rule and Its Competitors --- An Empirical Bayes Approach},
  journal = {Journal of the American Statistical Association},
  volume  = {68},
  number  = {341},
  pages   = {117--130},
  year    = {1973}
}

@article{morris1983parametric,
  author  = {Morris, Carl N.},
  title   = {Parametric Empirical Bayes Inference: Theory and Applications},
  journal = {Journal of the American Statistical Association},
  volume  = {78},
  number  = {381},
  pages   = {47--65},
  year    = {1983}
}

@book{efron2010large,
  author    = {Efron, Bradley},
  title     = {Large-Scale Inference: Empirical Bayes Methods for Estimation, Testing, and Prediction},
  series    = {Institute of Mathematical Statistics Monographs},
  publisher = {Cambridge University Press},
  year      = {2010}
}

@book{gelman2013bayesian,
  author    = {Gelman, Andrew and Carlin, John B. and Stern, Hal S. and Dunson, David B. and Vehtari, Aki and Rubin, Donald B.},
  title     = {Bayesian Data Analysis},
  edition   = {3rd},
  publisher = {CRC Press},
  year      = {2013}
}

@book{casellaberger2002statistical,
  author    = {Casella, George and Berger, Roger L.},
  title     = {Statistical Inference},
  edition   = {2nd},
  publisher = {Duxbury},
  year      = {2002}
}