Metropolis-Hastings for Model Comparison

Statistics
Introduced by
W. K. Hastings (1970); extended for model comparison by P. J. Green (1995)
Year
1970 (extended 1995)
Type
MCMC-based model comparison
Family
Bayesian / computational

What does it do?

Metropolis-Hastings for model comparison uses the Metropolis-Hastings MCMC algorithm to explore both parameter and model space simultaneously, producing posterior probabilities for competing models and enabling Bayes factor estimation without requiring closed-form marginal likelihoods.

The canonical extension — reversible-jump MCMC by Green (1995) — handles models of different dimensionalities within a single sampler.

The intuition behind the method

Picture a random walk that can wander through the parameter space of one model and can also jump to a model with a different number of parameters. Each step proposes either a parameter move within the current model or a jump to another model, and accepts or rejects it according to the likelihood, the priors, and the proposal, with a Jacobian correction when the dimension changes. Over many iterations, the share of time the walk spends in each model estimates that model's posterior probability.

History

Hastings (1970) generalised an earlier Monte Carlo sampling method, and the resulting Metropolis-Hastings algorithm is the basis of this approach. Its extension to model comparison is due to Green (1995), whose reversible-jump framework lets a chain jump between parameter subspaces of differing dimension. Green illustrated the framework with multiple change-point analysis in one and two dimensions and with a Bayesian comparison of binomial experiments.

When to use it

Use Metropolis-Hastings for model comparison when the candidate models may differ in dimensionality and you want them compared within a single MCMC run, when the marginal likelihood of each model has no convenient closed form, or when you need posterior model probabilities and model-averaged parameter estimates together. It suits problems such as variable selection in regression with an unknown subset of predictors, or selecting the number of mixture components. Do not use it when Bayes factors can be computed directly from closed-form or conjugate marginal likelihoods, because the sampler then adds cost without benefit. It is also unsuitable when the number of candidate models is so large that the sampler cannot explore model space.

Limitations and considerations

  • Designing between-model proposals is difficult and depends strongly on the problem, because the proposed parameters for a new model must be matched to the current state through an invertible map.
  • Poor between-model proposals produce very low inter-model acceptance rates, and the chain can remain in one model for long stretches.
  • The computational cost rises with the number of candidate models and their complexity, so exhaustive comparison of a large model space is impractical.
  • Posterior model probabilities depend on the model prior, and the influence of that prior is strongest when the data are limited or the models fit about equally well.
  • Other strategies for between-model moves exist, such as pseudo-prior methods, which avoid constructing an explicit dimension-matching map. Choosing between them depends on the problem, and their relative performance is not covered on this page.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Explores parameter and model uncertainty in a single MCMC run, so posterior model probabilities and within-model parameter estimates come from the same analysis.
  • Reversible-jump moves allow chains to move between parameter subspaces of different dimension, so the candidate models need not share a common parametrisation.
  • Posterior model probabilities are obtained as visit frequencies, so Bayes factors and model-averaged predictions follow without a separate marginal-likelihood calculation.
  • Under the usual conditions for the moves (detailed balance and irreducibility across the joint space), the chain targets the joint posterior over models and parameters.

Applications

  • Change-point analysis, comparing models with different numbers of change-points in one and two dimensions (Green, 1995).
  • Bayesian comparison of binomial experiments (Green, 1995).
  • Other settings with models of differing dimension, such as variable selection in regression and choice of the number of mixture components, use the same framework.

How it works

How it works

1

Assign a prior probability to each candidate model. A uniform prior over the K models is common when there is no strong preference. An informative model prior can encode scientific knowledge or penalise model complexity, and the posterior model probabilities depend on this choice.

Formula
p(M_k) \propto 1/K,\quad k=1,\ldots,K
2

At each iteration propose a new state. For a within-model move, draw a parameter vector from a proposal q centred on the current state, as in a standard Metropolis-Hastings step. For a between-model (reversible-jump) move, introduce dimension-matching auxiliary variables so that the joint map between the two parameter spaces is invertible, following Green (1995).

Formula
\theta^* \sim q(\theta^* \mid \theta^{(t)}, M)
3

The acceptance probability is min(1, r), where r combines the likelihood ratio, the parameter and model prior ratios, and the proposal ratio. For between-model moves r also contains the absolute Jacobian of the dimension-matching transformation. Moves that increase r are always accepted, and all others are accepted with probability r. Because the proposal and Jacobian terms are included, r is not simply the ratio of posterior densities. For between-model moves the full ratio also requires the between-model jump probabilities and the density of the auxiliary variables in Green's dimension-matching construction, which the expression in the mechanics table does not include.

Formula
\alpha = \min\!\left(1,\, \frac{p(y\mid\theta^*, M^*)\,p(\theta^*\mid M^*)\,p(M^*)\,q(\theta\mid\theta^*,M)}{p(y\mid\theta,M)\,p(\theta\mid M)\,p(M)\,q(\theta^*\mid\theta,M^*)}\,|J|\right)
4

Run the chain and record the model index at each retained iteration. This is a bookkeeping step rather than a formula. Standard practice is to tune the within-model and between-model proposals during warm-up and to monitor the acceptance rates of the two move types separately.

5

Estimate each model's posterior probability as the fraction of the T iterations retained for inference (after discarding warm-up draws) that the chain spends in that model. Bayes factors between two models follow from the ratio of their posterior model odds to their prior model odds.

Formula
\hat{p}(M_k\mid y) = \frac{1}{T}\sum_{t=1}^{T}\mathbf{1}[M^{(t)}=M_k]

Common pitfalls

  • Omitting the Jacobian term in a reversible-jump move breaks detailed balance and biases the estimated posterior model probabilities.
  • Monitoring only the overall acceptance rate hides low between-model acceptance; the within-model and between-model rates should be reported separately.
  • Reading posterior model probabilities as independent of the model prior is an error, because they are always proportional to the prior model probability times the marginal likelihood.
  • Running too few iterations can leave a model unvisited, so its estimated posterior probability is zero for the wrong reason.
  • Reporting model comparison results without a sensitivity analysis over the model prior.

Frequently asked questions

What is reversible-jump MCMC and why is it needed?

Standard Metropolis-Hastings moves within a fixed-dimensional parameter space. When models have different numbers of parameters, the sampler needs a between-model move with a dimension-matching step, so that the joint proposal map is invertible. Green (1995) builds this construction with auxiliary random variables and includes a Jacobian term in the acceptance ratio to preserve reversibility.

How does this approach compare with computing Bayes factors directly?

Direct Bayes factor computation needs the marginal likelihood of each model, which often has no closed form and must be estimated separately. The model-comparison MCMC approach estimates posterior model probabilities, and hence Bayes factors, from a single run, but the estimates are only reliable if the chain mixes well across models.

How do I know whether the chain is mixing well across models?

Report the inter-model acceptance rate separately from the within-model rate, inspect the model-index trace to confirm that every model is visited repeatedly, and compute the effective sample size of the model indicator. If the chain rarely leaves a dominant model, the between-model proposals need retuning.

Can I use this for comparing many models at once?

In principle yes, but the sampler struggles when the number of candidate models grows very large, as in variable selection with many predictors, because the model space grows combinatorially. In that case the number of models that can be explored in a run is the practical limit, and alternative formulations of the model space may be needed.

Are the posterior model probabilities sensitive to the model prior?

Yes. Each posterior model probability is proportional to the prior probability of that model times its marginal likelihood, so a weakly informative data set or models that fit about equally well leave the prior with a strong influence. Repeat the analysis under several different model priors and report how the conclusions change.

Related methods

Sources

  1. Hastings, W. K. (1970). Monte Carlo sampling methods using Markov chains and their applications. Biometrika, 57(1), 97-109.

    Open DOI reference
  2. Green, P. J. (1995). Reversible jump Markov chain Monte Carlo computation and Bayesian model determination. Biometrika, 82(4), 711-732.

    Open DOI reference