01 / 21

MCMC Convergence
Diagnostics

Learn how to determine when your Markov chain Monte Carlo sampler has converged, compute effective sample size, and avoid unreliable posterior estimates.

Graduate Statistics

What is MCMC?

Markov chain Monte Carlo constructs a Markov chain whose stationary distribution equals the target posterior \( \pi(\theta \mid y) \). By drawing correlated samples from this chain, we approximate integrals like \( E_\pi[g(\theta)] \) without closed-form solutions.

Why Convergence Matters

Bias
Pre-convergence samples reflect the initial value, not the posterior, biasing means and quantiles.
Variance
Autocorrelated draws inflate Monte Carlo standard error, giving false precision to estimates.
Coverage
Credible intervals from a non-converged chain have wrong coverage: 95% intervals may cover far less.

The Trace Plot: Your First Check

Iteration \(\theta\) Burn-in target Chain 1 Chain 2

The Gelman-Rubin Statistic \(\hat{R}\)

Run \( m \geq 2 \) chains of length \( n \) each. Define the between-chain variance \( B \) and within-chain variance \( W \):

Intuition: Between vs. Within

Not Converged Large B Converged Small B

Convergence vs. Mixing

Convergence Mixing
Definition Chain has reached the stationary distribution Chain explores the full support efficiently
Diagnostic \(\hat{R}\), Geweke test Autocorrelation, ESS
Failure looks like Chains at different levels Sticky, slow-moving trace
Fix More burn-in, better initial values Reparameterize, tune proposal

Effective Sample Size \(n_{\text{eff}}\)

Correlated MCMC draws contain less information than the same number of independent draws. The effective sample size adjusts for autocorrelation:

Autocorrelation Plot

1.0 0.8 0.6 0.4 0.2 0.0 Lag ACF Good mixing Poor mixing

Monte Carlo Standard Error

The Monte Carlo standard error (MCSE) quantifies the precision of your posterior estimate. For the posterior mean:

Rule of Thumb
MCSE should be < 5% of the posterior standard deviation to trust your estimate.
For Quantiles
MCSE for credible interval endpoints requires even larger \(n_{\text{eff}}\) than for the mean.

Diagnostic Checklist

1
Run multiple chains (\(m \geq 4\)) from dispersed starting values.
2
Inspect trace plots visually: look for the "hairy caterpillar" and chain overlap.
3
Check \(\hat{R}\) for every parameter: require \(\hat{R} < 1.01\).
4
Compute \(n_{\text{eff}}\): aim for at least 400 effective samples per parameter.
5
Check MCSE: ensure it is small relative to the posterior SD and your inferential needs.
6
If any check fails: increase iterations, reparameterize, or tune the sampler before trusting results.

Example: Computing \(\hat{R}\)

Suppose we run \(m = 2\) chains of \(n = 1000\) draws each for parameter \(\mu\). After burn-in:

Chain 1
\(\bar{\mu}_1 = 3.02\), \(s_1^2 = 0.48\)
Chain 2
\(\bar{\mu}_2 = 3.05\), \(s_2^2 = 0.51\)

Example: Computing \(n_{\text{eff}}\)

From the same 2 chains (\(mn = 2000\) total draws), we estimate the autocorrelation for \(\mu\):

Lag \(k\) 1 2 3 4 5+
\(\hat{\rho}_k\) 0.42 0.18 0.06 0.01 \(\approx 0\)

Example: A Problematic Chain

Iteration Chain 1 Chain 2 \(\hat{R} = 2.83\)

Common Mistakes

Running Only 1 Chain
\(\hat{R}\) requires multiple chains. A single chain can appear converged while stuck in one mode.
Using Old \(\hat{R} < 1.1\) Threshold
Modern guidance recommends \(\hat{R} < 1.01\). The 1.1 threshold misses many convergence failures.
Ignoring \(n_{\text{eff}}\)
Even with \(\hat{R} \approx 1\), tiny \(n_{\text{eff}}\) means posterior summaries have high Monte Carlo error.
Confusing MCSE with Posterior SD
MCSE is simulation error (shrinks with more draws). Posterior SD is actual parameter uncertainty (fixed by data).
Not Checking All Parameters
One parameter may converge while another does not. Always check diagnostics for every parameter.

Diagnostics Summary

Diagnostic What It Checks Threshold
Trace Plot Visual: mixing and stationarity Chains overlap, "caterpillar"
\(\hat{R}\) Between vs. within chain variance \(< 1.01\)
\(n_{\text{eff}}\) Information content of draws \(> 400\) per parameter
MCSE Simulation precision of estimate \(< 5\%\) of posterior SD
ACF Plot Autocorrelation decay rate Drops to \(0\) within \(\sim 10-20\) lags

Question 1 of 5

The Gelman-Rubin statistic \(\hat{R}\) compares which two quantities?

Question 2 of 5

A researcher runs 4 chains of 2000 draws each. The effective sample size for parameter \(\sigma\) is reported as \(n_{\text{eff}} = 120\). What should she conclude?

Question 3 of 5

Which of the following best describes what the Monte Carlo standard error (MCSE) measures?

Question 4 of 5

Two chains are run for a parameter \(\theta\). Chain 1 stabilizes around \(\bar{\theta}_1 = 5.2\) and Chain 2 around \(\bar{\theta}_2 = 12.8\), each with low within-chain variance. What does this indicate?

Question 5 of 5

If the autocorrelation at lag 1 is \(\hat{\rho}_1 = 0.95\) and decays slowly, which of the following is most likely true?