- Introduced by
- Metropolis et al. (1953); hierarchical extension developed through 1980s–1990s Bayesian computation literature
- Year
- 1953 (core); 1990s (multilevel application)
- Type
- MCMC sampling algorithm
- Family
- Bayesian / computational
What does it do?
Multilevel Metropolis-Hastings is the standard Metropolis-Hastings algorithm applied to a hierarchical (multilevel) Bayesian model, not a separately defined method.
It updates group-level parameters and population hyperparameters, either jointly in one block or in alternating blocks, by proposing candidate values and accepting or rejecting them with a ratio based on the joint posterior across all levels of the model.
The intuition behind the method
In a multilevel model, parameters sit at several levels: individual observations, groups, and population hyperparameters, linked through shared probability structure. Metropolis-Hastings explores this space by proposing a move from a tunable proposal distribution and accepting it with a probability set by the acceptance ratio; otherwise the chain stays where it is. Grouping updates into blocks, such as all group-level parameters in one step and hyperparameters in another, and tuning the proposal widths helps the chain move through the nested structure instead of stalling along correlated directions.
History
The Metropolis-Hastings algorithm is usually traced to Metropolis et al. (1953). The general form used in practice allows asymmetric proposals through the forward and reverse proposal densities in the acceptance ratio. Roberts and Sahu (1997) study updating schemes, blocking and parameterisation for the Gibbs sampler, comparing blocking combinations and parameterisations by their convergence rates for Gaussian targets. Their results concern Gibbs sampling and are cited here by analogy only.
When to use it
Choose multilevel Metropolis-Hastings when the data are grouped or nested (for example students within schools or patients within clinics), the model is hierarchical, and the conditional posteriors do not have simple closed forms, so Gibbs updates are not straightforward. It suits discrete parameters, non-differentiable likelihoods, and low-dimensional targets. For continuous, high-dimensional multilevel posteriors, gradient-based samplers such as Hamiltonian Monte Carlo (e.g., NUTS) generally mix better and are usually the first choice. Avoid plain random-walk MH on large multilevel models, where acceptance rates fall and correlations between levels slow the chain. When both a centred and a non-centred parameterisation of the same hierarchy are available, a common rule of thumb is that the non-centred form helps when groups contain little data relative to between-group variation, and the centred form helps when each group is well informed. This is a heuristic rather than a guarantee, because convergence rates depend on the parameterisation (Roberts and Sahu, 1997, for Gibbs samplers), so mixing diagnostics for both forms should be compared on the actual data.
Limitations and considerations
- Random-walk proposals lose efficiency as the number of parameters grows, producing low acceptance rates and slow exploration.
- The proposal covariance usually has to be tuned by hand or through a pilot run; adaptive schemes reduce this burden but add complexity.
- When group-level and hyperparameter posteriors are strongly correlated, the chain moves slowly unless the model is reparameterised.
- Results depend on parameterisation: centred and non-centred versions of the same hierarchy can mix at very different rates, and neither is best for every data configuration.
- For continuous multilevel models of moderate to high dimension, it is generally less efficient than Hamiltonian Monte Carlo.
- Convergence diagnostics can miss poor mixing in short runs, so passing them does not guarantee an adequate sample.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Applies to any posterior that can be evaluated up to a normalising constant, including discrete parameter spaces and non-differentiable likelihoods.
- The acceptance step is one explicit ratio, so each update can be checked directly against the model density.
- Proposal kernels can be designed around the group structure, for example with covariance matrices that reflect dependence between related parameters.
- Blocking can reduce mixing problems when level-1 and level-2 parameters are strongly coupled.
- It can be embedded in larger samplers, such as component-wise updates within a Gibbs scheme.
Applications
- Hierarchical linear and generalized linear models where group-level variance structure must be sampled jointly with fixed effects.
- Educational research: modeling student outcomes nested within schools and districts with unknown between-school variance.
- Clinical trials with patient data nested within sites, requiring random-effects estimation under Bayesian assumptions.
- Ecological studies with observations nested in spatial units, combined with non-standard observation models.
- Any multilevel model component where the conditional posterior lacks a closed form and Gibbs sampling is infeasible.
How it works
How it works
Write the full hierarchy: observations y_ij depend on group-level parameters θ_j, which depend on population hyperparameters φ, and φ has its own prior. Together these define the target joint posterior that the sampler must explore.
Formula
y_{ij} \sim p(y_{ij} \mid \theta_j),\quad \theta_j \sim p(\theta_j \mid \phi),\quad \phi \sim p(\phi)At each iteration, draw a candidate θ* for a parameter or block from a proposal kernel q, often a symmetric Gaussian centred on the current value. Proposal scale is the main tuning choice. Acceptance rates that are very low (most proposals rejected) or very high (accepted moves are tiny, so the chain drifts slowly) both signal a proposal scale that needs adjusting. Pilot runs are the usual way to set the scale, and no fixed acceptance range should be treated as a guarantee.
Formula
\theta^* \sim q(\theta^* \mid \theta^{(t)})Compute the acceptance ratio α in the acceptance formula, which compares the target density at the proposed and current values and corrects for asymmetric proposals through the forward and reverse proposal densities. Accept θ* with probability α, otherwise keep the current value. For a symmetric proposal, q(θ^(t) | θ*) = q(θ* | θ^(t)), so these terms cancel and the ratio reduces to the ratio of posterior densities. The target is the unnormalised joint posterior over all levels of the model, so the normalising constant cancels as well. When a block that contains hyperparameters is proposed, the posterior is evaluated with the other blocks held at their current values, and the same ratio applies.
Formula
\alpha = \min\!\left(1,\; \frac{p(\theta^* \mid \text{data})\, q(\theta^{(t)} \mid \theta^*)}{p(\theta^{(t)} \mid \text{data})\, q(\theta^* \mid \theta^{(t)})}\right)Multilevel parameters are often updated in blocks, for example all group-level effects in one step and hyperparameters in another. Grouping strongly correlated parameters into one block can reduce the correlation the chain has to navigate. Updating one coordinate at a time can mix very slowly when group-level and population-level parameters are tightly linked. Roberts and Sahu (1997) compare updating schemes and blocking combinations for the Gibbs sampler and show how they change convergence rates; their results concern Gibbs updates and are used here only by analogy to the Metropolis-Hastings setting.
Run several chains from dispersed starting values. R-hat values below about 1.01 are one commonly used convention, and an effective sample size of at least 400 post-warmup draws per parameter is a commonly used rule of thumb. Inspect trace plots and posterior predictive checks before interpreting posterior summaries.
Common pitfalls
- Leaving proposal scales untuned: acceptance rates that are very low or very high indicate a proposal that is too wide or too narrow, and the chain then explores slowly.
- Updating group parameters without accounting for their dependence on hyperparameters, which produces slow, correlated chains.
- Declaring convergence from a single chain or from too few post-warmup draws.
- Skipping posterior predictive checks, which can reveal model misspecification even when the chains look converged.
- Using the centred parameterisation when a non-centred one would decouple group effects from hyperparameters and improve mixing; the better choice depends on how much data each group contributes.
Frequently asked questions
How does Multilevel MH differ from standard MH?
Standard MH works with any target density. What changes in a multilevel model is that the target is a joint posterior over parameters at several levels (e.g., individual, group, population). Because these parameters are linked through the hierarchy, the joint posterior is often strongly correlated, so blocked updates and proposal designs that respect that correlation often mix better than single-coordinate updates.
When should I prefer Hamiltonian Monte Carlo over MH for multilevel models?
Prefer HMC (e.g., NUTS in Stan) when parameters are continuous and gradients of the log-posterior can be computed. Gradient information lets HMC make larger, better-directed moves, which usually helps with the correlated posteriors typical of multilevel models. Reserve MH for discrete parameters or cases where gradients are unavailable.
What is centered vs. non-centered parameterization and why does it matter?
In the centered parameterization, group effects θ_j are modeled directly; in the non-centered form, θ_j = μ + σ·z_j with z_j ~ N(0,1). When group-level data are sparse, the non-centered form decouples group effects from hyperparameters, which often reduces posterior correlation and improves mixing, though the better choice depends on how much data each group contributes.
How do I choose the proposal distribution?
Start with a multivariate Gaussian proposal whose covariance approximates the posterior covariance, for example from a pilot run or a Laplace approximation. Check the acceptance rate: very low rates mean the proposal is too wide, and very high rates mean it is too narrow and moves slowly. Adjust the scale until the rate is reasonable for the block, and do not treat any single range as a guarantee. Adaptive MH tunes the proposal automatically during warmup.
What diagnostics should I run after sampling?
Compute R-hat for all parameters (values below about 1.01 are one commonly used convention), check effective sample size (at least 400 post-warmup draws per parameter is a commonly used rule of thumb), inspect trace plots for stationarity and good mixing, and run posterior predictive checks to confirm the model generates data resembling the observed sample.
Related methods
Sources
Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A. & Rubin, D. B. (2013). Bayesian Data Analysis (3rd ed.). CRC Press.
ISBN: 978-1439840955Roberts, G. O. & Sahu, S. K. (1997). Updating schemes, correlation structure, blocking and parameterisation for the Gibbs sampler. Journal of the Royal Statistical Society: Series B, 59(2), 291-317.
Open DOI reference