Skip to main content
v2026.11,610 entries · CC-BY 4.0

Bayesian Hierarchical Models: Partial Pooling Explained (With a Worked Example)

Hierarchical (multilevel) Bayesian models use partial pooling to shrink each group’s estimate toward the overall mean by an amount set by its own sample size and the between-group variance — beating both no pooling and complete pooling.

Ask about Bayesian Hierarchical Models: Partial Pooling Explained (With a Worked Example)

Answers are drawn from this guide and the rest of the CASRAI corpus, with a link to every source.

Answers are AI-generated from CASRAI’s own published pages and can be wrong, so check the linked sources before relying on one; your question is logged without personal data — never sold, never used to train a third-party model — to show us what CASRAI is missing, so please do not type personal or confidential details. How we use this

Written and maintained by CASRAI Editorial Board

Last updated

A Bayesian hierarchical model (also called a multilevel model) solves a specific problem: you have data broken into groups — sites, labs, patients, schools, batches — and you must decide how much each group’s estimate should be allowed to differ from the others. Treat every group as completely separate and small groups produce wildly noisy, overfit estimates. Collapse everything into one pooled estimate and you erase real between-group differences that matter. Partial pooling is the third option: each group’s estimate is pulled — “shrunk” — toward the overall average, by an amount that depends on how much data that group actually has and how much groups genuinely differ from one another. It is not a compromise chosen for convenience; it is the estimator that minimizes expected error when groups really do vary, which is the practical reason hierarchical models are now the default choice for grouped data in fields from clinical trials to education research to lab science.

Three Ways to Handle Grouped Data

Any dataset organized into groups — ten clinical sites, thirty labs running the same assay, a hundred students nested in twelve classrooms — can be analyzed three ways:

  • No pooling. Estimate each group entirely on its own data, ignoring every other group. A site with 8 patients gets an estimate built from 8 data points, full stop. This is unbiased in principle but has terrible variance for small groups — the estimate for a small site swings wildly depending on which few observations happened to land in it, and outlier estimates from small groups get treated with the same confidence as stable estimates from large ones.
  • Complete pooling. Ignore the grouping entirely and estimate one number for the whole dataset. This throws away real between-group signal. If ten sites genuinely differ — different patient populations, different equipment, different protocols — a single pooled estimate misrepresents every one of them, understating some and overstating others, and gives no way to say which sites are actually different from the rest.
  • Partial pooling (the hierarchical/multilevel approach). Model group-level estimates as themselves drawn from a shared distribution, and estimate that distribution’s parameters — its mean and its spread (the between-group variance) — from the data at the same time as the individual group estimates. Each group’s own data pulls its estimate toward that group’s specific mean; the shared distribution pulls every group’s estimate toward the overall mean. The result sits between the no-pooling and complete-pooling extremes, and where exactly it sits depends on the data, not on an analyst’s judgment call.

The name “hierarchical” refers to this two-level (or more) structure: individual observations are modeled within groups, and groups are themselves modeled as draws from a higher-level distribution. This is the same nesting structure behind mixed-effects models in frequentist statistics — a Bayesian hierarchical model and a frequentist mixed-effects (multilevel) model are answering the same structural question about the data, but a Bayesian hierarchical model puts full probability distributions, not just point estimates and standard errors, on every parameter at every level, including the group-level variance itself.

Why Partial Pooling Works: the Shrinkage Mechanism

The intuition behind partial pooling is a weighted average. For each group, the model effectively combines two pieces of information:

  • That group’s own observed estimate, weighted by how much data (how much precision) that group has.
  • The overall group-level mean, weighted by how much groups vary from one another (the between-group variance) relative to how much within-group noise there is.

A group with a lot of data gets an estimate that barely moves from its own observed value — its own data is precise enough to dominate the weighted average, so there’s little to gain from borrowing information from other groups. A group with very little data gets an estimate pulled substantially toward the overall mean, because its own observed value is too noisy to trust on its own, and the best available extra information is what every other group’s data says about where group-level values tend to sit. This selective, data-driven shrinkage — more for small or noisy groups, almost none for large or precise ones — is exactly what “borrowing strength across groups” means in practice, and it is the mechanistic reason partial pooling outperforms both extremes: it is not blindly averaging (like complete pooling) and it is not blindly trusting every group’s own noise (like no pooling); it weights each source of information by how reliable it actually is.

This is the same underlying phenomenon as regression to the mean — extreme observed values, especially from small samples, tend to be partly noise, and the correction pulls them back toward the average. A hierarchical model formalizes that correction explicitly and estimates, from the data itself, how much correction is warranted, rather than leaving it as an informal caveat.

A Worked Example: Ten Sites, One Adherence Rate

Illustrative example — the figures below are constructed to demonstrate the shrinkage mechanism, not drawn from a specific published study.

Suppose a multi-site study measures a protocol-adherence rate at ten sites, and site sample sizes vary considerably — some sites enrolled hundreds of participants, others enrolled a handful before the enrollment window closed. The overall (complete-pooling) adherence rate across all sites combined is 72%.

Site n (sample size) Observed rate (no pooling) Partially pooled estimate
Site A 410 75% 75%
Site B 380 68% 68%
Site C 6 100% 78%
Site D 9 33% 63%
Site E 5 0% 58%
Site F 295 70% 70%
Site G 7 86% 75%
Site H 340 78% 78%
Site I 4 50% 68%
Site J 250 66% 66%

Read the two right-hand columns together. The large sites (A, B, F, H, J — hundreds of participants each) barely move between the no-pooling and partially-pooled columns, because their own data is precise enough to stand on its own; the model has little reason to override it. The small sites (C, D, E, G, I — single-digit sample sizes) move substantially: Site E’s raw 0% (from just 5 participants, all of whom happened not to adhere) is pulled up to a plausible 58% rather than being reported as a literal zero; Site C’s raw 100% (6 for 6) is pulled down from a number no one should trust at face value. Under no pooling, Site E and Site C would be reported as the worst- and best-adherence sites in the study — a conclusion driven almost entirely by having too little data to say anything reliable, not by a real underlying difference. Under complete pooling, all ten sites would be reported as an identical 72%, erasing the genuine, well-supported difference between Site B’s 68% (380 participants) and Site H’s 78% (340 participants), which is too well-estimated on both sides to responsibly ignore. The partially pooled column is the only one of the three that treats a large, precise sample as trustworthy and a tiny, noisy one as suspect — in the same analysis, without an analyst having to decide site by site which numbers to trust.

How Much Shrinkage? What Determines the Weighting

The amount a given group’s estimate shrinks toward the overall mean is governed by the ratio of two variances, estimated from the data itself rather than set by the analyst:

  • Within-group variance (how noisy an individual group’s estimate is, driven mostly by its sample size) — larger within-group variance means less trust in that group’s own data, hence more shrinkage.
  • Between-group variance (how much groups genuinely differ from one another) — if the model estimates that groups barely differ at all, it shrinks everything hard toward the mean, approaching complete pooling. If groups clearly differ a lot, it shrinks much less, approaching no pooling.

This is why partial pooling is often described as adapting automatically between the two extremes rather than sitting at a fixed point between them: with very little genuine between-group variation, a hierarchical model’s output converges toward the complete-pooling answer; with large genuine between-group variation and reasonably sized groups, it converges toward the no-pooling answer. The between-group variance parameter itself has a full posterior distribution in a Bayesian hierarchical model, which is what lets the amount of shrinkage respond correctly to genuine uncertainty about how much groups actually vary — a small number of groups (fewer than roughly 5–8) makes that between-group variance itself hard to pin down precisely, the same small-group-count caution that applies to frequentist random effects in a mixed-effects model.

Choosing Priors for the Variance Components

The group-level (between-group) variance is the parameter that needs the most deliberate prior choice in a hierarchical model, because it directly controls how much shrinkage happens. Two points of standard, current guidance:

  • Avoid the classic inverse-gamma(0.001, 0.001) “non-informative” prior on variance components that appeared in a lot of older applied Bayesian work. It is not actually non-informative near zero, and with few groups it can pull the posterior toward implausibly large or small between-group variance in a way that isn’t obvious from the model output.
  • A weakly informative half-normal or half-Cauchy prior on the standard deviation (not the variance) of the group-level effects is the standard modern default: it stays close to flat across a plausible range, avoids the inverse-gamma pathology near zero, and is what modern hierarchical-modeling software (Stan-based tools including brms, and PyMC) recommends and defaults toward.

Priors on the fixed (population-level) parameters — the overall mean and any predictor coefficients — matter much less in most applications once there is a reasonable amount of data; the group-level variance prior is the one worth genuine attention, especially with a small number of groups, where the data alone cannot pin it down precisely and the prior does real work.

When a Hierarchical Model Is (and Isn’t) the Right Tool

A hierarchical structure is worth the added modeling complexity when data has genuine grouping and:

  • Group sizes vary a lot, so a single pooling strategy would be wrong for some groups and right for others.
  • There are enough groups (a rough rule of thumb is at least 5–8) to estimate the between-group variance with any real precision — with only two or three groups, there usually isn’t enough information to distinguish “these groups are genuinely different” from “there’s just sampling noise,” and a simpler fixed-effects-per-group model, treating each group as its own parameter with no shared distribution, is often the more honest choice.
  • The goal includes both group-specific estimates (which sites, which labs) and a defensible overall estimate, not just one or the other.
  • New or small groups will be added later and need a way to be estimated sensibly before they accumulate much data of their own — partial pooling gives a new group with almost no data an estimate close to the overall mean by default, rather than an unusable estimate built from a handful of points.

It is the wrong tool when there genuinely is no meaningful grouping structure in the data (ordinary regression is simpler and sufficient), or when the “groups” are really just a small, fixed, exhaustive set an analyst specifically wants compared to one another by name rather than treated as a sample from a larger population — that case calls for fixed effects, not random effects, exactly as in the frequentist mixed-effects setting.

Estimation: Why This Usually Means MCMC

Hierarchical Bayesian models rarely have a closed-form posterior, because the group-level and population-level parameters depend on each other. In practice they’re fit using Markov Chain Monte Carlo (MCMC) sampling — commonly via Stan-based tools (brms, rstanarm) or PyMC — which returns a full posterior sample for every parameter at every level, including the group-level variance and every individual group’s shrunk estimate simultaneously. That full posterior is also what lets a hierarchical model report a proper credible interval for each group’s estimate, correctly reflecting how much less certain a small group’s estimate really is, rather than a single shrunk point value with no accompanying uncertainty.

Frequently Asked Questions

Is a Bayesian hierarchical model the same thing as a mixed-effects model?

They share the same grouped-data structure and the same shrinkage logic, but they are fit differently. A frequentist mixed-effects model estimates group-level variance components via maximum likelihood (or restricted maximum likelihood) and produces point estimates with standard errors. A Bayesian hierarchical model puts a full prior distribution on every parameter, including the group-level variance, and returns a full posterior distribution for each estimate. With weak priors and enough data the two approaches often converge on similar point estimates, but the Bayesian version handles a small number of groups and propagates uncertainty in the variance components more honestly, since it doesn’t rely on the same large-sample approximations.

How is partial pooling different from just averaging every group toward the overall mean by the same amount?

Averaging every group by a fixed amount would ignore how much data each group actually has. Partial pooling shrinks each group by an amount specific to that group — determined by its own sample size and the estimated between-group variance — so a large, precise group is barely shrunk while a small, noisy group is shrunk substantially. That group-specific weighting, not a single blanket adjustment, is what makes the estimator work.

What happens with only two or three groups?

With that few groups there usually isn’t enough information in the data to reliably estimate the between-group variance itself, which is the parameter that controls how much shrinkage should happen. The model can still be fit, but the group-variance estimate (and therefore the amount of shrinkage) becomes highly sensitive to the prior, and results should be reported and interpreted cautiously. A fixed-effects model treating each of the few groups as its own separate parameter is often the more transparent choice at that scale.

Does partial pooling bias individual group estimates?

It introduces a small, deliberate bias toward the overall mean in exchange for a substantial reduction in variance, particularly for small groups — this bias-variance tradeoff is precisely why the partially pooled estimate has lower expected error than the unbiased-but-noisy no-pooling estimate once groups vary in size. It is the standard, well-established statistical justification for shrinkage estimators generally, not specific to the Bayesian framing.

Can hierarchical models have more than two levels?

Yes — a common extension nests groups within larger groups (patients within clinics within regions, for example), with a separate variance component and its own partial pooling at each level. The same shrinkage logic applies at every level: each level’s estimate borrows strength from the level above it, weighted by how much data and how much between-unit variance exist at that level.

Related Reading

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Regulatory Radar

Stop finding out after the fact

$29/month, cancel anytime. Daily digest updates from our analysis, a dashboard holding the same items, and a cited assistant for everything they raise.

  • Federal Register, Federal Register+, Grants.gov, Regulations.gov, NSF News, UKRI, plus CASRAI’s own published content.
  • 44,322 indexed passages, and every answer cites the ones it drew on.