AI Glossary / Probabilistic machine learning / Intermediate

Hierarchical Bayesian model

Definition

A hierarchical Bayesian model describes related quantities through multiple connected levels of probability distributions. Group-specific parameters share a population distribution, whose own parameters can have priors and be learned from data. This structure supports partial pooling: information from one group can inform another while allowing genuine differences between them.

What it means

Suppose several service centers have different completion rates. Estimating each rate independently may be unstable for small centers, while assuming one identical rate ignores possible differences. A hierarchical model gives each center its own rate and connects those rates through a shared distribution.

The hierarchy is statistical, not necessarily an organizational reporting chart. Levels can represent measurements, individuals, groups or other related quantities. In a fully Bayesian analysis, uncertainty about shared population parameters is retained rather than replaced with a single fitted value. The amount of sharing depends on the model, prior assumptions and information in the observations.

How it works

A typical structure has observations y_j generated using group parameter theta_j. Each theta_j comes from a distribution governed by shared hyperparameters, such as a population mean and spread. Hyperpriors describe uncertainty about those hyperparameters. Bayes' rule combines the entire structure with the observed data.

Data influence both local parameters and the shared distribution, which in turn informs local estimates. Small or weakly observed groups often receive more influence from the population model than groups with substantial relevant data. This is conditional on the groups being meaningfully related under the specified model.

Inference may use analytic calculations in simple cases or methods such as MCMC for more complex models. Predictions for a new group require a new group parameter drawn from the population distribution, together with uncertainty in its hyperparameters. They differ from predictions for an existing group whose own observations have already informed its parameter.

Three practical examples

1. Service-center rates: estimate success probabilities across centers with unequal sample sizes. Report uncertainty and relevant case differences rather than interpreting raw rankings as stable performance measures.

2. Product demand: connect demand parameters for related products while retaining product-specific variation. The hierarchy should reflect credible similarities rather than forcing unrelated products into one shared pattern.

3. Repeated measurements: connect observations within people or machines and model variation between those units. Distinguish measurement noise from between-unit differences.

Think of it this way

Think of learning about individual branches while also learning what the collection of branches tends to look like. Information moves both ways through a shared description. The analogy explains borrowing strength, but does not imply that all branches are interchangeable in every respect or that the shared description is correct by definition.

Worked example

Consider a deliberately tiny hierarchy with shared mean mu taking values 0.25 or 0.75, each with prior probability one half. Conditional on mu, two group probabilities theta_A and theta_B are independent Beta(4mu, 4(1-mu)). Each group contributes one Bernoulli observation. This discrete hyperprior makes the full calculation transparent.

First observe a success in A. Its probability given mu is mu, so the posterior probabilities of mu=0.25 and mu=0.75 become 0.25 and 0.75. Conditional posterior means for theta_A are (4mu+1)/5: respectively 0.4 and 0.8. Averaging over mu gives 0.25 × 0.4 + 0.75 × 0.8 = 0.7.

Now observe a failure in B. The combined data likelihood is mu(1-mu), equal to 0.1875 for either possible mu. Their posterior weights become one half each. A's posterior mean therefore changes to 0.5 × 0.4 + 0.5 × 0.8 = 0.6, despite no additional A observation. B's conditional means are 4mu/5, namely 0.2 and 0.6, averaging to 0.4. Information from B has affected A through the shared uncertain hyperparameter. These are exact calculations for this invented model, not a fitted service dataset.

Illustrative case study

Fictional case: Aspen Support compares task completion across centers. A small center records a perfect rate from very few tasks and initially tops a raw ranking. Analysts fit a hierarchical model, examine its uncertainty and review whether centers handle comparable tasks.

They introduce relevant task predictors where justified and avoid presenting a posterior point estimate as a definitive league table. They also distinguish forecasts for established centers from forecasts for a newly opened center. This fictional case illustrates model structure and interpretation, not a guarantee that pooling produces fair or accurate performance comparisons.

Common misconceptions and mistakes

Partial pooling is not simply replacing every group estimate with the overall average. It also does not guarantee that every posterior summary lies between a raw estimate and one universal mean in every nonlinear or multivariate model.

Exchangeability assumptions require thought: systematic differences may need predictors, additional levels or separate models. More levels do not automatically improve inference when the data cannot identify their variation. Hyperpriors matter, especially with few groups. Fixing estimated hyperparameters gives an empirical Bayes-style calculation rather than automatically retaining the full uncertainty of a hierarchical Bayesian analysis.

Business use

Use a hierarchy when the business question involves related units and both shared patterns and unit-specific differences matter. Define the population to which the groups belong and review whether the proposed sharing is credible. Include enough detail to separate genuine group differences from differences in case mix or measurement.

Check prior and posterior predictions, sensitivity to hyperpriors and the behavior of small groups. Validate for the intended deployment, including unseen groups if relevant. Communicate interval estimates and decision consequences rather than treating shrinkage as an automatic correction that makes comparisons objective or causal.

People also ask

What is a hyperparameter here?

It is a parameter governing a distribution over other parameters, such as the population spread of group effects.

Does every group share one identical value?

No. Partial pooling allows separate group values while connecting their distributions.

Why can another group's data change my group's estimate?

Both groups inform shared hyperparameters, which influence the posterior distribution for each group's parameter.

Check your understanding

Why does A's posterior mean fall from 0.7 to 0.6 after B's failure?

Answer: B's result changes the posterior weights on the shared mean mu. A's estimate averages over that shared uncertainty, so it changes too.

Related terms

  • Hyperprior
  • Empirical Bayes
  • Posterior predictive distribution
  • Shrinkage
  • Partial pooling
  • exchangeability
  • multilevel model
  • random effect

Learn next

Trace the two-level calculation in the example, then compare complete pooling, no pooling and partial pooling on grouped binary observations. Next study prediction for an entirely new group and sensitivity to the population-spread prior.

More in Probabilistic machine learning

  • Hard expectation maximization - Hard expectation maximization, or hard EM, fits a latent-variable model by replacing uncertainty about hidden variables with selected assignments and then...
  • Harmonic mean estimator - The harmonic mean estimator is a method for estimating a Bayesian model's marginal likelihood from posterior samples by taking the harmonic mean of their...
  • Hidden semi-Markov model - A hidden semi-Markov model, or HSMM, is a probabilistic model for sequences in which unobserved states can have explicitly modeled durations.
  • Hierarchical softmax - Hierarchical softmax represents a probability distribution over many output classes by arranging them as leaves of a tree and multiplying conditional branch...
  • Hierarchical variational autoencoder - A hierarchical variational autoencoder is a variational autoencoder whose generative model contains multiple dependent layers or groups of latent variables.
  • Hierarchical variational posterior - A hierarchical variational posterior is an approximate posterior distribution constructed with additional layers of random variables or randomized...

Sources

Carpenter, Gabry and Goodrich, Hierarchical Partial Pooling for Repeated Binary Trials, official rstanarm vignette: https://mc-stan.org/rstanarm/articles/pooling.html

Independent review consulted the rstanarm tutorial’s pooling definitions and hierarchical population formulation. Original two-point hyperprior calculation verified; support-center case fictional.

Previous: Hidden units Next: Hierarchical Classification

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer