advanced36 min studyLesson 264 in Mathematics

Hierarchical models and partial pooling

Derive normal-model shrinkage, interpret exchangeability, and retain uncertainty in shared hyperparameters.

On this page

What you’ll understand

  • Derive a group-level posterior by adding normal precisions.
  • Explain how measurement precision controls partial pooling.
  • Distinguish conditional hyperparameter calculations from full hierarchical inference.

Suppose several laboratories estimate related quantities, but their measurements have different precision. Treating every laboratory separately ignores information about their shared context, while forcing one common value denies genuine variation. A hierarchical model describes the relation between group effects through a population distribution. Partial pooling then arises from conditioning that model, rather than from an arbitrary instruction to average estimates. The amount of pooling depends on both within-group uncertainty and between-group variation, and uncertainty about those quantities should remain visible.

Exchangeability is a modeling assertion

Let a group estimate zjz_j have known sampling variance sj2s_j^2, with zj∣θj∼N(θj,sj2)z_j\mid\theta_j\sim N(\theta_j,s_j^2). Assign conditionally independent group parameters θj∣μ,τ∼N(μ,τ2)\theta_j\mid\mu,\tau\sim N(\mu,\tau^2). Given the hyperparameters, groups have the same prior distribution before their data distinguish them. This is a form of conditional exchangeability, not a claim that their observed values are identical. Relevant group predictors can be introduced into the prior mean rather than pretending dissimilar groups are interchangeable.

The sampling variance measures uncertainty in a group estimate; the population variance measures heterogeneity between true group effects. Interchanging them changes the model. Known sampling variances make this lesson's conditional calculation simple, but estimating them from small samples may require an additional model. Correlation between group estimates also needs representation. Sharing one source of measurement bias is different from independent observation noise, and a hierarchical prior on group effects does not automatically repair a misspecified sampling covariance.

zj∣θj∼N(θj,sj2),θj∣μ,τ∼N(μ,τ2),sj2>0, τ2>0z_j\mid\theta_j\sim N(\theta_j,s_j^2),\qquad\theta_j\mid\mu,\tau\sim N(\mu,\tau^2),\qquad s_j^2>0,\ \tau^2>0
The normal distributions use variance as their second parameter. The formulas below condition on fixed hyperparameters.↔ Scroll wide equations horizontally.

Complete the square to reveal pooling

Multiply the normal likelihood and normal prior for one group. The coefficient of the squared parameter is the sum of sampling precision 1/sj21/s_j^2 and prior precision 1/τ21/\tau^2. The linear coefficient is the corresponding precision-weighted sum of zjz_j and μ\mu. Completing the square gives a normal conditional posterior. Its mean is a convex combination: a precise group estimate receives a larger data weight, while a noisy estimate moves farther toward the population mean.

As sj2s_j^2 approaches zero at fixed positive population variance, the data weight approaches one. As the population variance approaches zero at fixed sampling variance, the conditional mean approaches the common mean. These are limiting calculations, not permission to substitute zero into a density requiring positive variance. A large departure from the population mean does not, by itself, change the shrinkage weight in this fixed-variance normal model. Robust or adaptive alternatives can behave differently because they use different distributions or infer additional parameters.

θj∣zj,μ,τ∼N ⁣(wjzj+(1−wj)μ, τ2sj2τ2+sj2),wj=τ2τ2+sj2\theta_j\mid z_j,\mu,\tau\sim N\!\left(w_jz_j+(1-w_j)\mu,\ \frac{\tau^2s_j^2}{\tau^2+s_j^2}\right),\qquad w_j=\frac{\tau^2}{\tau^2+s_j^2}
The conditional data weight lies strictly between zero and one when both variances are positive.↔ Scroll wide equations horizontally.

Integrate the hyperparameters

In a full Bayesian hierarchy, the population mean and scale receive proper hyperpriors, and their posterior uncertainty is integrated rather than replaced by one fitted pair. For a group parameter with finite posterior second moment, the law of total variance separates average conditional variance from variance of the conditional mean across hyperparameter draws. A plug-in calculation omits this latter component and also replaces the former by its value at one point. It need not reproduce the full posterior uncertainty or even its mean.

Population-scale priors deserve predictive checks because the number of groups may be small. A wide-looking scale prior can imply absurdly heterogeneous groups, while a prior concentrated near zero can impose nearly complete pooling. Predicting a new observation in an existing group and predicting a previously unseen group also involve different integrations: the latter requires a fresh group effect from the population distribution. Computational reparameterizations can improve sampling without changing this generative model, provided the transformed density and any necessary Jacobian are handled consistently.

A noisy group is pulled toward the population

Condition on population mean 10 and variance 4. One group's estimate is 16 with sampling variance 9. Calculate its conditional posterior mean and variance.

  1. The data weight is population variance divided by the sum of variances: 4/(4+9)=4/13. The remaining weight on the population mean is 9/13; both weights are positive and sum to one.

  2. The conditional posterior mean is (4/13) times 16 plus (9/13) times 10, giving 154/13, approximately 11.846. The original estimate 16 moves toward 10 because its sampling variance is relatively large.

  3. The posterior variance is the reciprocal of 1/9+1/4, equal to 36/13, approximately 2.769. This is conditional on the known hyperparameters, so it does not include uncertainty about the population mean or variance.

The result

The conditional posterior is normal with mean 154/13 and variance 36/13. Variance 9 belongs to the measurement model; variance 4 belongs to between-group variation.

Explore the model

Interactive lab

Interactive lab · sampling

Precision changes the evidence from a group

Pause and Reset, then set both controls to p=0.50 and n=4; predict sample-mean variance 0.0625. Reset and set p=0.50 and n=100; predict 0.0025. Compare the exact widths. These are independent Bernoulli sampling distributions illustrating different measurement precision, not a fitted normal hierarchy or posterior shrinkage plot.

Precision changes the evidence from a groupExact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Current readings: Mean sample proportion: 0.5; Sample-mean variance: 0.0125; Uniform CDF error bound: ≤ 0.1062. All parameters are adjustable with the labeled controls below.Exact distribution of the mean of 20 independent Bernoulli variables with success probability 0.5; playback highlights outcome 0.00.250.50.75100.0580.1150.1730.23Sample mean · k / nProbability massNormal bin masses are an approximationk = 0 · exact probability = 9.54e-7
Exact binomial massNormal interval massHighlighted outcome / mean
Mean sample proportion
0.5
Sample-mean variance
0.0125
Uniform CDF error bound
≤ 0.1062
t = 0 s

Exact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forSmaller sampling variance supports a larger data weight in the derived normal hierarchy; the lab itself has no population-variance control.

Check your understanding

With positive population variance fixed, what happens to the normal-model data weight as a group's sampling variance decreases toward zero?

Try it yourself

Keep population mean 10 and variance 4, but give a second estimate of 16 sampling variance 1. Calculate its conditional posterior mean and variance, then compare its pooling with the worked example.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Change only the sampling variance in the two precision formulas; do not infer a new population variance from one group.

Compare with the solution

The data weight is 4/(4+1)=4/5. The posterior mean is (4/5)16+(1/5)10=14.8, and the variance is 4 times 1 divided by 5, or 0.8. The more precise estimate moves only 1.2 units toward the population mean, compared with about 4.154 units in the worked example. These are conditional results with the same fixed hyperparameters; a full hierarchy would additionally integrate their posterior uncertainty.

Take it with you

  • Sampling variation and population heterogeneity play different roles.
  • Partial pooling weights reflect relative precision in the stated normal model.
  • Full hierarchical prediction integrates hyperparameter and group uncertainty.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.