A Bayesian hierarchical model organizes uncertainty into two or more levels: observable data governed by parameters, and those parameters governed by hyperparameters with their own prior distribution. Each level borrows information from the others through the joint posterior, enabling partial pooling — estimates for sparse groups are shrunk toward a common mean while rich groups remain data-driven.
Key Ideas
Partial pooling (Bühlmann credibility): the posterior estimate for group i is a weighted average of the group's own data and the grand mean — the weight determined by the signal-to-noise ratio at each level.
Conjugate structures: Normal/Normal and Poisson/Gamma hierarchies yield closed-form Gibbs conditionals; non-conjugate cases require Griddy-Gibbs or Metropolis steps.
Proper priors at every level guarantee a proper joint posterior and valid Gibbs convergence; improper priors at the top level may still yield proper posteriors when data are informative.
Predictive distributions: f(Y~∣Y)=∫f(Y~∣θ)f(θ∣Y)dθ — automatically propagates parameter uncertainty into future predictions; estimated by averaging f(Y~∣θ(i)) over posterior draws.
Three-Component Marketing Framework and Heterogeneity Distributions (Rossi-Allenby 2003)
Rossi and Allenby articulate that every Bayesian marketing model has three coherent components: (1) a within-unit likelihoodp(yi∣θi) modelling individual consumer behavior, (2) a cross-unit heterogeneity distributionp(θi∣τ), and (3) an action rule derived from a loss function applied to the posterior.
Normal hierarchical model. The canonical three-level specification (where W denotes the Wishart distribution):
θi∼N(θˉ,Vθ),θˉ∼N(θˉˉ,A−1),Vθ−1∼W(ν,V)
Two-block Gibbs: draw {θi∣τ,yi} (conjugate given the likelihood) and τ∣{θi} (conjugate from the Wishart-Normal hyperprior). Shrinkage toward θˉ is strong when within-unit data are sparse and between-unit variation is small.
Observable heterogeneity. When unit-level covariates zi are available:
θi=Bzi+ui,ui∼N(0,Vθ)
B and Vθ are estimated jointly; residual heterogeneity ui is the unexplained part after covariate adjustment.
Mixture-of-normals heterogeneity. To accommodate multimodal or heavy-tailed heterogeneity:
p(θi∣τ)=k=1∑Krkϕ(θi∣θˉk,Vk)
A normal mixture avoids the convex-hull limitation of finite-mixture models (in which predictions are constrained to the convex hull of the component means). Component assignments are auxiliary variables in the Gibbs sampler; the number of components K is selected by marginal likelihood, not BIC (Bayesian Information Criterion, which is "extremely inaccurate" for correlated-parameter models).
Structural heterogeneity. When individuals switch between behavioral regimes within the panel:
p(yit∣{θik})=k=1∑Krkpk(yit∣θik)
The mixture operates at the observation level, not the parameter level — each θik is a complete behavioral type, and the assignment probability rk governs regime prevalence.
Diagnostic check (Allenby-Rossi 1999). Compare unit posterior means θ^i to the marginal predictive:
p(θi′∣data)=∬ϕ(θ∣θˉ,Vθ)p(θˉ,Vθ∣data)dθˉdVθ
Unit posterior means that are outliers relative to this predictive distribution signal that the heterogeneity model is too restrictive. Properly accounting for hyperparameter uncertainty (integrating over θˉ and Vθ) widens the predictive relative to a plug-in check.
Bayesian decision theory. The optimal action is:
a∗=argamin∫l(a,θ)p(θ∣data)dθ
Evaluating profit only at the posterior mean (plug-in) overstates expected profit because it ignores parameter uncertainty — the loss function is typically nonlinear in θ. Full posterior integration is required for valid targeting decisions. The value of disaggregate (unit-level) information is quantified by Πdisagg−Πagg where Πdisagg uses individual posterior θi and Πagg uses a pooled estimate.
Workers Compensation Credibility (Scollnik ~1996, Example 4)
133 occupation classes, 7 years of claim frequency data; Klugman (1992) Data Set 2. Let Yij = claim count, Pij = scaled exposure, xij=Yij/Pij = relative frequency.
HNM (Hierarchical Normal Model):
xij∣θi,τ1∼N(θi,Pij/τ1),θi∣μ,τ2∼N(μ,1/τ2)
Diffuse proper priors: μ∼N(0,0.001); τ1,τ2∼Gamma(0.001,0.001). Full conditionals are Normal/Gamma — closed-form Gibbs. Drawback: allows negative frequencies.
HFLPM (Hierarchical First-Level Poisson Model):
Yij∣λi∼Poisson(λiPij),λi∣μ,τ∼N(μ,1/τ)
Non-negative counts by construction. Best predictive performance on the hold-out year: overall measure of prediction success (OMPS) posterior mean = 12.96 (sd = 0.64).
VSHNM (Variance-Stabilized HNM):
Apply zij=2xij before fitting a Normal hierarchy. Stabilizes the variance of Poisson-like data. OMPS = 13.72 — better than HNM but worse than HFLPM.
Gibbs Sampling for Hierarchical Models
The block structure of the posterior corresponds naturally to Gibbs blocks. For the HNM:
θi∣μ,τ1,τ2,Y∼N — weighted average of group data and prior mean
μ∣θ1:n,τ2∼N — grand mean update
τ1∣θ1:n,Y∼Gamma — within-group precision
τ2∣θ1:n,μ∼Gamma — between-group precision
All four blocks have closed-form conjugate conditionals. BUGS (Bayesian Inference Using Gibbs Sampling) implements this automatically from the model declaration.
Gamma-Poisson Model for Geographic Mortality Data (Tsutakawa 1988)
For count data yij (deaths in region i, demographic group j) with exposure nij, the model adds two random-effect layers above the Poisson observation:
Marginalising over pij gives a negative binomial for yij with variance =nijθjzi+σj2(nijθjzi)2 — Poisson plus extra-Poisson. The regional effect zi is shared across all demographic groups j in region i, inducing positive cross-age correlation within a county.
Posterior mean (partial pooling): E(pij∣yij,ξ,zi) is a weighted average of the observed rate yij/nij (weight ∝nijpˉij) and the expected rate θjzi (weight ∝σj−2). Small counties shrink heavily toward expected; large counties stay data-driven.
Estimation: Empirical Bayes via profile likelihood — estimate hyperparameters ξ=(θ,σ2,γ) by ML (profile over γ, integrate over zi), then estimate rates by posterior means given ξ^. Missouri lung cancer: 115 counties × 4 age groups, 1972–1981; likelihood-ratio (LR) test vs. fixed-effects Poisson = 51.4; Empirical Bayes (EB) standard deviations up to 15% smaller than raw rates.
Hierarchical Pooling of Air Pollution–Mortality Evidence (Dominici-Samet-Zeger 2000)
The NMMAPS (National Morbidity, Mortality, and Air Pollution Study) exemplifies the two-stage approach where Stage 1 delivers sufficient statistics and Stage 2 applies the hierarchical model to those statistics rather than to raw data.
Stage 1 — City-specific Poisson generalized additive model (GAM). For each of 20 US cities, city c, age group a, and day t:
where DOWt is a day-of-week indicator, Skc are natural splines for long-run time trend (7 df/yr), same-day temperature (6 df), 1–3 day lagged temperature (6 df), same-day dew point (3 df), lagged dew point (3 df), and xtac = (PM₁₀, O₃) with lags 0, 1, 2. Output per city: β^c∈Rp and sample covariance Vc. The large sample (T=550–2550 days) justifies the normal approximation β^c∣βc∼Np(βc,Vc).
where zc=(1,Ppovertyc,P>65c,XˉPM10c). All full conditionals are conjugate (normal for α and βc, IW for Σ): a pure Gibbs sampler runs 3000 iterations with burn-in 100 and thinning by 5. Convergence via Raftery-Lewis (1992) CODA (Nmin≈2000).
Spatial extension. City correlations follow an exponential decay model:
corr(βc,βc′)=exp{−θd(c,c′)}
The decay parameter θ∼LogNormal(0.2,0.52) lacks a conjugate conditional; a Metropolis-Hastings (M-H) step with gamma proposal (acceptance 0.3–0.5) is required. A regional step-function alternative recovers closed-form conditionals: τ2∼IG(5,8.5) (IG = Inverse-Gamma).
Key results. Univariate base-line, lag 0: +10 μg/m³ PM₁₀ → +0.48% daily mortality (95% credible interval [CI]: 0.05–0.92), Pr(α₀ > 0) = 0.98. Bivariate (PM₁₀ + O₃): +0.52% (0.16–0.85). Between-city standard deviation σ^≈0.76 (0.41–1.37), approximately twice the pooled effect — substantial heterogeneity. City-level covariates do not explain it. Robust across 27 sensitivity scenarios (3 models × 3 lags × 3 priors).
Limitation. The IW prior with only p+1=3 degrees of freedom is influential relative to 20 cities. The profile likelihood for σ has 95% mass approximately on (0,0.4), narrower than the IW posterior's (0.41,1.37) — a standard small-n problem for IW hyperpriors.
Level-Specific R² and Pooling Factor λ (Gelman-Pardoe 2004)
For a multilevel model with level-m units k=1,…,Km, let θk be the quantity of interest and εk=θk−μk the residual after the linear predictor μk. Two Markov Chain Monte Carlo (MCMC)-computed summary measures (posterior expectations of variance ratios) are:
Level-m R2 (eq. 7):R2=1−E[Vk(θk)]E[Vk(εk)]
Measures the fraction of level-m variance explained by the predictor μ. Vk denotes variance across units k. Reduces to classical ordinary least squares (OLS) R² with no pooling (Xu 2003).
Measures the fraction of residual variance reduced by the hierarchical model for the residuals εk. λ≈0: each group is estimated independently (no pooling). λ≈1: all residual structure is captured by the group-level model.
Parallel structure: R² and λ have the same denominator structure. R² measures predictor fit to θk; λ measures hierarchical shrinkage of εk.
Bayesian adjusted R2 for linear regression (n obs., p predictors):
Radj,Bayes2=1−n−p−2n−3⋅yTIcyyT(I−H)y
Strictly lower than the classical Wherry (1931) adjusted R2 (factor (n−1)/(n−p)). For the balanced one-way hierarchical model, λ reduces to the Bühlmann credibility weight ω=1−σ^α2/(σ^α2+σ^y2/n).
Minnesota radon example (919 houses, J=85 counties; Model 4 with uranium predictor):
Level
R2
λ
Household (y)
0.21
0.03
County intercept (α)
0.53
0.81
County slope (β)
0.83
0.97
Uranium explains 83% of cross-county slope variation; hierarchical pooling accounts for 97% of slope residual variance (slopes are nearly entirely determined by the county-level uranium model).
Both measures are free MCMC byproducts (no null model needed) and can be negative (misspecification signal).
The apparent contradiction — rich states vote Democratic, rich individuals vote Republican — is resolved by allowing the income slope to vary across states and to depend on average state income.
Varying-intercept model (eq. 1): Constant slope β, state-specific intercepts:
Pr(yi=1)=logit−1(αs[i]+βxi)
Varying-intercept, varying-slope model (eq. 2): Both intercept and slope vary by state, each modeled as a linear function of average state income us:
Key finding: b^β<0 — the income–Republican slope is steepest in poor states (Mississippi) and near-zero in rich states (Connecticut). The aggregate relationship runs in the opposite direction because richer states have higher αs (baseline Democratic lean), which dominates the cross-state comparison even as βs>0 within each state.
County-level model (§2.4):yc=αs[c]+βs[c]xc+εc fits county average income and vote shares with the same hierarchical structure — confirms individual-level inference from aggregated data.
Pattern emergence: Essentially absent 1968–1988; emerged post-1992 (Figures 14–16). The geographic income–vote correlation is a post-Cold-War phenomenon. Estimation via WinBUGS; model checking via binned residual plots.
Random-Effects Logit for Conjoint Analysis (Allenby-Rossi-McCulloch 2005, eqs. 16–19)
The standard hierarchical Bayes (HB) conjoint model applies the three-level hierarchy to a logit observation layer:
Priors: Γ∼N(a,A); Vβ−1∼Wishart(w,W). Gibbs cycle — (1) each βh one respondent at a time (Metropolis for non-conjugate logit likelihood); (2) Γ∣{βh},Vβ∼N; (3) Vβ∣{βh},Γ∼IW; (4) repeat.
Credit card application: N=946 bank customers, 14,799 paired comparisons, 7 attributes; 20,000 iterations, convergence by ~6,000. Key finding: comparing low annual fee vs. low fixed interest as incentives to overcome the −3.614 out-of-state penalty, despite low interest having higher mean utility, the low-fee incentive produces 7.5% of respondents above a net-utility profitability threshold vs. 4.5% for low interest — nearly 2×. The explanation is the off-diagonal of V^β: Cov(low fee, out-of-state)=8.5 (ρ=0.80) vs. Cov(low interest, out-of-state)=1.9 (ρ=0.23). Respondents who are fee-sensitive also tend to be less penalized by the out-of-state attribute.
Blocked MCMC for Longitudinal Models (Chib-Carlin 1999)
The standard Gaussian linear mixed model yi=Xiβ+Wibi+εi, bi∼Nq(0,D), εi∼N(0,σ2I) with Wishart prior on D−1 and Gamma prior on σ−2, admits progressively blocked Gibbs samplers that dramatically reduce autocorrelation relative to the standard 4-block algorithm (Gelfand-Smith 1990).
Algorithm 2 (partial blocking): Marginalize yi over bi: yi∣β,σ2,D∼Nni(Xiβ,Vi) where Vi=σ2I+WiDWi′. This gives a closed-form β∣y,σ2,D∼Np(β^,B) that does not condition on the random effects. After sampling β, draw bi∣β,σ2,D from its standard conditional. Autocorrelation time κ(β) drops to 1.0 (essentially iid) in the HIV CD4 example.
Algorithm 3 (single block): The joint marginal π(σ2,D−1∣y) has no closed form, but the integrated likelihood f(y∣σ2,D) can be evaluated via the Chib (1995) identity as a ratio of three tractable Normal densities:
f(y∣σ2,D)=ϕp(β∗∣β^,B)ϕp(β∗∣β0,B0)∏iϕni(yi∣Xiβ∗,Vi)
evaluated at the Algorithm 2 posterior mean β∗. Update θ=(σ2,ψ) jointly by M-H with a multivariate-t proposal calibrated from a short Algorithm 2 warmup run. Reduces κ(D21) from 60 → 11.
Binary longitudinal extension: For binary responses with probit link, data augmentation (Albert-Chib 1993) introduces latent zit∣bi∼N(xit′β+wit′bi,1). Marginalizing Zi over bi yields Zi∼Nni(Xiβ,Ini+WiDWi′) — a special case of the Chib-Greenberg (1998) multivariate probit. Algorithm 7 marginalizes over both bi and Z by computing f(yi∣β,D) via the GHK (Geweke–Hajivassiliou–Keane) method (Cholesky + sequential truncated-Normal draws + product of Normal CDFs); lag-10 β autocorrelation drops from 0.934 to 0.009 (PSID (Panel Study of Income Dynamics), two random effects (REs)) but at high computational cost. Algorithm 5 (partial blocking only) is the recommended practical choice.
Universal rule: fixed effects should always be sampled marginalized over random effects. See Gibbs Sampler and Chib-Carlin (1999).
Conjugate Likelihood Distributions and Hyperparameter Gibbs Sampling (George-Makov-Smith 1993)
In a conjugate exponential-family hierarchical model — data layer xi∣θi∼f(x∣θi) and prior layer θi∣α,β∼π(θ∣α,β) — the Gibbs conditionals for θi are standard conjugate draws. The obstacle is the hyperparameter block: its full conditional is proportional to the conjugate likelihood distribution,
π(α,β∣θ1,…,θp)∝L(α,β∣θ1,…,θp)⋅π(α,β)
where L(x0,n0∣θ1:p)∝exp[x0∑iθi−n0∑iψ(θi)−pφ(x0,n0)].
Theorem 3.3 (George-Makov-Smith 1993): L is log-concave in (α,β) — enabling Gilks-Wild (1992) adaptive rejection sampling (ARS) — and jointly proper iff p≥2. This resolves the hyperparameter bottleneck: the shape hyperparameter samples by ARS; the scale hyperparameter often draws conjugately; every step is exact.
Gamma-Poisson pump failure application (p=10, §4): With xi∣θi∼Poisson(θiti) and θi∣α,β∼Gamma(α,β), the explicit conjugate likelihood is LG(α,β∣θ1:p)∝(βα/Γ(α))p(∏iθi)α−1exp(−β∑iθi). The complete Gibbs cycle: (a) θi∣⋅∼Gamma(α+xi,β+ti); (b) α∣⋅ by ARS; (c) β∣⋅∼Gamma. 100,000 draws across four hyperprior specifications confirm shrinkage of pump-specific rates toward a common value — shrinkage calibrated by data through α and β.
Why It Matters
Credibility theory (actuarial): the hierarchical posterior exactly formalizes Bühlmann's classical credibility formula — prior mean weighted by credibility factor Z=n/(n+k) where k = within/between variance ratio.
Small-area estimation: the Tsutakawa gamma-Poisson model shows how hierarchical partial pooling prevents both over-reliance on sparse county data and the smoothing-away of true geographic signal; a direct precursor to the mortality-modelling literature (Lee-Carter, Vector Error Correction Model [VECM] mortality).
Shrinkage in econometrics: the Minnesota Prior in Bayesian Vector Autoregressions (VARs) is conceptually analogous — each equation's coefficients are shrunk toward a common prior mean (zero), with the tightness parameter playing the role of k.
Data-sparse subgroups: groups with few observations borrow heavily from the global distribution, avoiding the overfitting that OLS would produce on each group separately.
Software: BUGS makes hierarchical models almost trivially programmable; the model declaration maps directly to the graphical model structure.
Open Questions
Choice of hyperprior: improper priors at the hyperparameter level sometimes produce proper posteriors but make convergence analysis difficult.
Choice of model (HNM vs. HFLPM vs. VSHNM): model selection via marginal data density or posterior predictive loss.
Extension to crossed or nested hierarchies (multiple grouping factors).