MCMC convergence diagnostics

Description

Checks that Markov chain Monte Carlo samples have explored the posterior properly and are precise enough before any Bayesian estimate is reported.

A Bayesian model fitted by MCMC produces samples that are only usable if the chains have reached the stationary distribution, mixed well and yielded enough effectively independent draws. The routine runs several chains from dispersed starting points and checks them by plots and statistics: trace plots for stationarity and rapid mixing, rank (trank) plots in which all chains should overlap evenly, autocorrelation and cumulative-mean plots, the Gelman-Rubin statistic (Rhat) near 1.00, effective sample size adequate for the quantity wanted, and stationarity tests such as Geweke and Heidelberger-Welch. Hamiltonian Monte Carlo adds diagnostic warnings (divergent transitions, maximum treedepth) that usually point to a problem in the model, not the software. No diagnostic proves convergence and regions a chain never visited cannot be seen, so warnings are treated as diagnoses to fix rather than noise.

Attributes

Loss type
Siloed
Stage
Evaluation
Effort
Hours

Steps

  1. Prepare a trimmed data list with only the variables used and transformations computed in advance.
  2. Debug with one short chain, then run about four chains from dispersed starting points; discard warmup samples.
  3. Read Rhat (should be 1.00; values above about 1.01 signal non-convergence) and effective sample size (a few hundred for means, many more for tail quantiles).
  4. Inspect trace, rank (trank), autocorrelation and cumulative-mean plots; one chain sitting apart for long stretches means poor exploration.
  5. Where needed, apply stationarity tests (Geweke, Heidelberger-Welch, Kolmogorov-Smirnov on chain halves) and batch means to decide whether precision is adequate.
  6. Treat divergent transitions, treedepth warnings and slow sampling as model problems: use weakly informative priors, reparameterise multilevel models, or remove redundant parameters.
  7. Refit until all checks pass and record the diagnostics table and warnings resolved alongside the results.

Sources

  • Statistical Rethinking (McElreath, 2020)
  • Introducing Monte Carlo Methods with R (Robert & Casella, 2010)
  • Bayesian Analysis for the Social Sciences (Jackman, 2009)
  • Applied Bayesian Modelling (Congdon, 2003)
  • Structural Equation Modeling: A Bayesian Approach (Lee, 2007)
  • Bayesian Statistical Modelling (Congdon, 2006)
  • Bayesian Networks: An Introduction (Koski & Noble, 2009)
  • Pattern Recognition and Machine Learning (Bishop, 2006)
  • Probability and Statistics (DeGroot & Schervish, 2012)
  • Information Theory, Inference, and Learning Algorithms (MacKay, 2003)

Also known as

  • Checking MCMC output before trusting a Bayesian fit
  • MCMC diagnostics
  • Convergence diagnostics
  • Rhat and effective sample size checks
  • Gelman-Rubin shrink factor
  • Geweke diagnostic
  • Heidelberger-Welch test
  • Effective sample size
  • Batch means
  • coda

Categories

  • Analytics & Behaviour
  • Statistics & Modelling