The Metropolis-Hastings (MH) algorithm is a general-purpose Markov Chain Monte Carlo (MCMC) method that generates samples from a target distribution π(θ) by iterating a proposal–accept/reject step: at each iteration draw a candidate θ∗ from a proposal density q(θ∗∣θt−1), then accept it with probability
r=min(1,π(θt−1)q(θ∗∣θt−1)π(θ∗)q(θt−1∣θ∗))
If rejected, the chain stays at θt−1. The ratio corrects for asymmetric proposals so that the chain's invariant distribution is exactly π, regardless of the proposal form. The acceptance function is derived from the reversibility condition (detailed balance): requiring π(x)p(x,y)=π(y)p(y,x) and minimizing rejection probability yields the Hastings form uniquely (Chib-Greenberg 1995; Peskun 1973).
Key Ideas
The acceptance ratio r requires only the ratio π(θ∗)/π(θt−1), so the normalising constant of π cancels — this is the key advantage for Bayesian posteriors.
The Gibbs Sampler is a special case: when q(θ∗∣θt−1)=π(θ∗∣θ−it−1,Y) (the full conditional), the ratio r=1 everywhere and every candidate is accepted.
Peskun (1973) optimality. Among all acceptance functions α(x,y) that leave π invariant, the Hastings form is optimal: it minimises the rejection probability for any pair (x,y) and therefore minimises the asymptotic variance σ2 of MCMC mean estimates. Barker's (1965) form π(y)q(y,x)/[π(x)q(x,y)+π(y)q(y,x)] is strictly worse.
Product of Kernels principle (Chib-Greenberg 1995). If kernel P1 preserves π(θ1∣θ2) and P2 preserves π(θ2∣θ1), then the composition P1P2 preserves the joint π(θ1,θ2). This justifies all Metropolis-within-Gibbs hybrids: blocks with conjugate conditionals use α=1 (pure Gibbs); intractable blocks use an MH step — the composition still targets π.
Convergence and a Central Limit Theorem (CLT) follow from general state-space Markov chain theory: irreducibility and aperiodicity guarantee ergodic convergence; geometric ergodicity (verified via a drift condition) validates confidence intervals.
When the target f(⋅) is bounded above by c⋅h(⋅) on a set C={x:f(x)<ch(x)}, a pseudodominating density
q(y)={f(y)/(cd)h(y)/dy∈Cy∈/C
(d chosen so q integrates to 1) can be used as the MH proposal. The acceptance probabilities for four cases (x∈/∈/C,y∈/∈/C) are tabulated in Chib-Greenberg (1995) Table 1. The algorithm combines the efficiency of rejection sampling inside the "easy" region C with a Metropolis correction outside it, ensuring invariance of π without burn-in bias.
Six Metropolis Kernel Types (Tierney 1994)
Tierney (1994) unifies the MH literature under six kernel types:
Kernel
Proposal q(⋅∣θ)
Notes
Random-walk
θ∗=θ+ε, ε∼N(0,τ2)
Most common; tune τ for acceptance rate 0.44 (scalar) / 0.23 (high-dim)
Independence chain
q(θ∗∣θ)=q(θ∗) — independent of current state
Efficient when q≈π; collapses when tails of q are too thin
Rejection-sampling chain
Embeds a reject-sampling step in MH; guarantees exactly π even when the envelope occasionally fails
Useful for bounded supports
Autoregressive / shrinkage
θ∗=ρθ+ε, ε∼N(0,σε2)
Shrinks proposals toward origin; useful for near-stationary targets
Grid-based (Griddy)
Evaluate π on a grid; cumulative distribution function (CDF) inversion to propose
Induces negative serial correlations, reducing asymptotic variance
Convergence Theory (Tierney 1994)
Drawing on Nummelin (1984) general state-space theory:
Theorem 1 (Ergodic convergence). If the chain is π-irreducible and aperiodic, then π is the unique invariant distribution and for π-a.e. starting point x:
∥Pn(x,⋅)−π(⋅)∥→0
Geometric ergodicity via drift condition. If there exist V:E→[1,∞), a "small" set C, and constants λ<1, b<∞ such that:
PV(x)≤λV(x)+b⋅1C(x)
then ∥Pn(x,⋅)−π∥≤M(x)ρn for some ρ<1. This is the standard sufficient condition for CLT validity.
Theorem 4 (CLT). If the chain is geometrically ergodic and g∈L2+ε(π):
n(n−1j=1∑ng(θj)−Eπ[g])dN(0,σ2)
The asymptotic variance is the spectral density of the chain at zero frequency:
σ2=Varπ(g)+2j=1∑∞Covπ(g(θ0),g(θj))
Geometric ergodicity guarantees this sum converges absolutely. Uniform ergodicity (stronger) requires only g∈L2(π) (Theorem 5).
Metropolis-within-Gibbs
When a Gibbs sampler has one or more blocks with non-standard full conditionals, MH steps can be nested inside the Gibbs cycle. Each block that cannot be drawn directly is replaced by one or more MH steps targeting that block's full conditional; blocks with standard conjugate forms continue as direct draws. The resulting algorithm is a hybrid (mixture/cycle of kernels) that retains π as its invariant distribution. See Time-Varying Parameter VAR for the five-block Metropolis-within-Gibbs sampler of Cogley-Morozov-Sargent (2003) and Noninformative Prior for VAR for the hit-and-run variant.
WLS Proposal for GLMMs (Gamerman 1997)
For generalized linear mixed models (GLMMs), a highly efficient weighted least squares (WLS) Metropolis proposal is obtained from the iteratively reweighted least squares (IWLS) linearization of the non-Gaussian likelihood. At state η(t), compute pseudo-response y~i=ηi+(yi−μi)g′(μi) and weight Wi−1=b′′(θi)[g′(μi)]2. The resulting working-model posterior N(m(t),C(t)) — a generalized least squares (GLS) posterior for the linearized Normal problem — serves as an independence-chain proposal whose acceptance rate exceeds 85–98% in practice. This is an instance of the independence chain family where the proposal is locally calibrated to the posterior curvature rather than fixed. See Generalized Linear Mixed Model for full details.
Prefetching: Parallelising MH via a Metropolis Tree (Strid 2010)
Standard MH is intrinsically serial: each evaluation of π(θ∗) must complete before the next proposal can be formed. Prefetching breaks this bottleneck by speculating on the accept/reject outcome and evaluating the posterior at multiple future candidate states in parallel.
Metropolis tree. With P processors, build a binary tree where each node corresponds to a possible future state: the left branch (acceptance) moves to θ∗; the right branch (rejection) stays at θt−1. A tour of size P selects P nodes and evaluates them in parallel. The expected draws per tour:
D(P)=p=1∑PPr(node p selected)
is the theoretical speedup over one serial step.
Five variants. Algorithms differ in how branch probabilities are assigned (which determines D):
Variant
Branch probabilities
D at P=7, α=0.25
Basic (Brockwell 2006)
All 0.5
3.00; lower bound log2(P+1)
Static
Known α: reject = 1−α, accept = α
3.54
Dynamic (uniform)
Empirical αk from pilot histogram over U[0,1] bins
3.81
Dynamic (posterior approx.)
min(β,p∗(θacc)/p∗(θcur)) with p∗=N(θm,Hm−1)
4.58
Most likely path
Run P steps ahead with p∗; non-branching tour
4.99
Optimal acceptance rate shifts downward. The joint expected output E(α,P)=E1(α)×D(α,P) is maximised at lower α than the serial optimum 0.234 because lower α lengthens accepted-state runs, increasing D:
P
αopt,P
1
0.234
7
0.120
∞
0
Smets-Wouters benchmark (Table 1, α=0.25). Most likely path achieves theoretical speedup 4.99× (P=7) and actual cluster speedup 5.15× on a Lenngren high-performance computing (HPC) cluster with 8 processors (80 min serial → 15 min parallel). Independence chain MH is embarrassingly parallel (S(P)≈P) but achieves only 13% acceptance on the 40-parameter Smets-Wouters (SW) model, making its parallelism advantage illusory.
Limitations. Practical ceiling ≈10–15 processors; most likely path inapplicable with discontinuous likelihoods (nonlinear Dynamic Stochastic General Equilibrium (DSGE)/particle filter); Gibbs steps (α=1) incompatible with prefetching.
Tuning and Diagnostics
Acceptance rate target (Roberts-Gelman-Gilks 1994):≈0.45 for one-dimensional θ; ≈0.25 for d≥6; ≈0.23 asymptotically as d→∞. These apply to random-walk Gaussian proposals; rates far from target signal a mis-scaled proposal variance.
Burn-in: Discard initial draws until the chain appears stationary (visual inspection of traces; Gelman-Rubin R^ across multiple chains).
Effective sample size: Low ESS relative to total draws indicates slow mixing — reduce proposal variance (random-walk) or improve proposal approximation (independence chain).
Variance estimation: Use the spectral variance formula above; estimate σ2 via batch means or a smoothed periodogram (Geweke 1992). See Gibbs Sampler for implementation details.
Why It Matters
MH is the most general MCMC workhorse: it applies whenever the target π can be evaluated up to a normalising constant, with no conjugacy requirements.
The Gibbs sampler's theoretical properties (convergence, CLT) are understood as consequences of MH theory — Gibbs is the limit of MH as the proposal becomes the full conditional.
Peskun optimality gives a theoretical justification for the Hastings acceptance form over alternatives, settling a design question that had been open since Barker (1965).
Hybrid MH-Gibbs algorithms power modern time-varying parameter VAR (TVP-VAR), stochastic volatility (SV), and other high-dimensional state-space estimators that mix conjugate and non-conjugate blocks.
Open Questions
Optimal proposal scaling in high dimensions (beyond the 0.23 rule for isotropic Gaussian proposals) is an active research area; adaptive MCMC methods (Haario-Saksman-Tamminen) auto-tune but require careful justification of ergodicity.
For multimodal targets, standard random-walk MH may mix across modes only rarely; parallel tempering and simulated tempering extend MH to address this but add tuning complexity.
The drift-condition approach verifies geometric ergodicity theoretically; in practice for specific models (e.g. heavy-tailed posteriors), checking the condition can be non-trivial.