Hierarchical Model

A hierarchical model (or multilevel model) is a Bayesian model in which unit-level parameters share a common distribution indexed by a hyperparameter :

The top-level prior is the hyperprior; the distribution is the population distribution; is the unit-level likelihood. The graphical structure is a tree: hyperparameter at the root, unit parameters as children, observations as leaves. Each observation depends on its own , but all ‘s are coupled through their shared ancestor .

Posterior structure. The joint posterior factorizes as

Conditional on , the ‘s are independent with individual posteriors obtained from Bayes’ rule within each unit. Marginalizing out couples the units, which is why hierarchical models need numerical techniques (Gibbs sampling, Hamiltonian Monte Carlo, or empirical Bayes) even when the within-unit updates are conjugate.

Headline result — partial pooling. The posterior mean is pulled (shrunk) from the unit-level MLE toward the population-level mean, by an amount increasing in the population prior’s concentration and decreasing in the unit’s own sample size. Units with little data borrow strength from the pool; units with abundant data are barely affected. This (Partial Pooling) property is the defining advantage of hierarchical models: it beats both the no-pooling fit (separate MLE per unit, which overfits small units) and the complete-pooling fit (ignore unit identity, which underfits heterogeneity).

Two approaches to inference. Full Bayes puts a hyperprior and integrates by MCMC. Empirical Bayes estimates by maximizing the marginal likelihood and plugs in in the unit-level posteriors. Empirical Bayes underestimates uncertainty about but is computationally cheap and gives nearly identical posterior means.

James-Stein phenomenon. In the Normal-Normal hierarchy, the empirical-Bayes posterior mean for each is the James-Stein estimator — an explicit shrinkage estimator that strictly dominates the MLE under squared-error loss whenever . This remains the clearest example of a frequentist estimator outperformed by a Bayesian one uniformly in the parameter.

Prerequisites

Intuition

Suppose we observe cancer mortality rates in each of the US counties. Some counties are huge (Los Angeles, ) and some are tiny (). If we compute a separate maximum-likelihood rate for each county, the smallest counties will dominate both the top and the bottom of any ranked list — they have the highest sampling variance, so extreme values are most likely to appear there by chance. Conversely, if we pool all counties together and estimate a single , we lose all geographic variation and obscure real disparities. Neither extreme is correct.

The hierarchical answer is to acknowledge that each county has its own true rate , but that these rates are drawn from a shared population distribution. Large counties estimate their own rate almost independently; small counties borrow strength from the population. The tool that decides how much each county borrows is Bayes’ rule applied within the unit, using the population distribution as the prior. The population itself has to be estimated from the data too — that is what the hyperprior (full Bayes) or the marginal likelihood (empirical Bayes) provides.

The central tension is between heterogeneity and pooling. Unit parameters are assumed exchangeable at some level — we do not know which county will be high and which low before seeing data — so a shared prior on the ‘s is reasonable. But the units are genuinely different; rural and urban counties have different exposures. Pooling too much erases the signal; pooling too little erases the safety. The hyperparameter controls the rate of pooling, and the model learns that rate from data by trading off within-group variance against between-group variance. This is the Bayesian shadow of a random-effects ANOVA.

Properties

(Partial Pooling Beats Both Extremes) Hierarchical posterior means strictly outperform no-pooling and complete-pooling under any reasonable risk measure when heterogeneity is moderate.

Under no pooling (separate MLE per group), small units have huge variance. Under complete pooling (single rate), bias dominates because unit-level variation is ignored. The hierarchical posterior mean interpolates: it shrinks each toward the grand mean by a factor that depends on the group’s sample size and the population variance. Under squared-error loss and the Normal-Normal hierarchy, the optimal shrinkage factor is , where is the sampling variance for group and is the population variance; small groups have near 1 (shrink fully) and large groups have near 0 (essentially MLE).

(Beta-Binomial Hierarchy) The standard binomial hierarchy has Beta population distribution and county-level Beta-Binomial updating.

Let and . Conditional on , the unit-level posterior is with posterior mean

The hyperparameters are themselves estimated by marginal likelihood: , which is maximized numerically. Maximum-likelihood give the empirical-Bayes posterior for each .

(Normal-Normal Hierarchy and James-Stein) The Gaussian hierarchy’s empirical-Bayes posterior mean equals the James-Stein shrinkage estimator.

Let with known sampling variances , and . The conditional posterior is

With known and empirical-Bayes estimates and (where is the sample variance of the ‘s), the posterior mean of is

the classical James-Stein estimator. When , this dominates the MLE under total squared-error risk for every true — a “strict dominance” result that stunned the frequentist world when Stein proved it in 1956.

(Empirical Bayes vs Full Bayes) EB underestimates hyperparameter uncertainty but recovers the same posterior means.

Empirical Bayes plugs in and computes unit-level posteriors as . Full Bayes integrates . Both give nearly identical posterior means, because the integrand is nearly symmetric around . The difference appears in the variance of the unit-level posterior: EB treats as known, so its credible intervals are too narrow by a factor reflecting hyperparameter uncertainty. Full Bayes (via MCMC) recovers calibrated intervals at the cost of substantially more computation. See 3.7 Marginal Likelihood for hyperparameter estimation details.

(Gibbs-Sampling Friendly) Conjugate population distributions yield tractable Gibbs updates.

In the Beta-Binomial and Normal-Normal hierarchies, the full conditional for each given is a closed-form conjugate posterior, and the conditional for given is often also closed form (e.g., Inverse-Gamma for in the Normal hierarchy). This makes hierarchical models a canonical setting for Gibbs samplers; see 3.11.2 Gibbs Sampling. Non-conjugate hierarchies require Metropolis-within-Gibbs steps or Hamiltonian Monte Carlo for the hyperparameter level.

(Variance Stabilization via the Delta Method) Heterogeneous sampling variances can be homogenized by an appropriate transformation before applying the Normal hierarchy.

Raw sample proportions have sampling variance that depends on itself. The arcsine transformation , derived by the delta method applied to stabilize binomial variance, satisfies independent of . Similarly for Poisson counts, has variance independent of the rate. After transformation, Normal-Normal hierarchical machinery (including James-Stein) applies directly. This is how the original James-Stein paper’s kidney-cancer and baseball-batting-average analyses were performed.

(Exchangeability Assumption is Load-Bearing) Hierarchical models assume unit-level parameters are exchangeable; structural covariates should be incorporated.

Exchangeability of means no covariate is known a priori to separate them. If we know that depends systematically on a covariate (e.g., urban vs. rural), a simple exchangeable hierarchy will over-shrink those relationships toward the grand mean. The fix is a regression hierarchy: with , replacing the shared mean with a covariate-dependent mean. This extends directly to multilevel regression and is how GLMMs (generalized linear mixed models) are built.

(Three-Level and Deeper Hierarchies Follow the Same Pattern) Adding more layers produces nested partial pooling.

A three-level hierarchy has , , . A student test-score model might have students nested in classrooms nested in schools. The pooling pattern recurses: each is pulled toward its classroom mean , which is pulled toward the school mean , which is pulled toward nothing (top-level prior). The graphical structure stays a tree. Full Bayes via MCMC is the standard inference method.

Examples

Derivation

Goal: derive the shrinkage weight in the Normal-Normal hierarchy, conditional on known .

Starting from the unit-level joint for given and hyperparameters:

Both terms are quadratic in , so by precision addition (3.5.2 Normal-Normal Model), the posterior is Gaussian with precision and mean

Rearranging as a convex combination:

Shrinkage weight (pull fully to ) when , i.e. unit noisier than population spread. (ignore the pool) when , i.e. unit precise relative to heterogeneity.

James-Stein plug-in: estimate by the weighted mean (for equal , this is ), and estimate by where is the sample variance of the ‘s (for equal ). With equal and , the (slightly adjusted) estimate substituted into the shrinkage factor recovers exactly , yielding the classical James-Stein formula.

Empirical Bayes vs Full Bayes coincidence. Both produce the same posterior mean up to corrections because the marginal likelihood is approximately quadratic in around its maximum (BvM applied at the hyperparameter level), so integrating against a diffuse hyperprior returns the mode to leading order.

See Also