Why MCMC Diagnostics Matter
Posterior summaries are often computed from draws produced by a Markov chain Monte Carlo algorithm. Those draws are not generally independent: a chain may move slowly through the posterior, remain for a long time in one region, or fail to explore a region that matters. A long list of draws is therefore not, by itself, evidence that a posterior mean, interval, or other summary is reliable.
Diagnostics address two related questions. Convergence diagnostics look for evidence that chains have reached and explored the intended posterior distribution. Precision diagnostics assess how much Monte Carlo error remains in a reported summary. Neither question is answered by a single number: plots, multiple chains, numerical diagnostics, and knowledge of the model and sampler should be considered together.
Trace Plots and Multiple Chains
A trace plot places successive sampled values of a parameter on the vertical axis and iteration on the horizontal axis. Inspect one plot per chain, using a common vertical scale. A well-behaved trace often looks like a dense, irregular band, with chains overlapping and moving across the range of posterior values. A trend, long flat stretches, abrupt shifts, or chains occupying distinct ranges can signal nonstationarity, slow mixing, or failure to explore different parts of the posterior.
Run several chains from deliberately dispersed initial values. If they all start near the same point, their agreement is less informative: they may all have missed the same region. Warm-up draws, which are used to adapt or stabilize the sampler, are typically excluded from posterior summaries and diagnostics of the retained draws. A trace plot is useful but not conclusive: chains can look similar while missing a distant mode or other poorly explored feature.
Worked Example: Reading Traces Across Chains
Suppose four hypothetical chains estimate a regression slope measured in outcome units per additional year of education. After warm-up, their traces all fluctuate across roughly \(-0.1\) to \(0.9\), with no persistent trend. Each chain repeatedly visits both the lower and upper parts of that range, and their traces overlap. This is encouraging evidence that the chains are exploring a common distribution.
Now suppose instead that chains 1 and 2 remain mostly between \(0.5\) and \(0.9\), while chains 3 and 4 remain mostly between \(-0.1\) and \(0.3\). The separation is a warning, even if each individual trace looks stable. It may indicate poor mixing or distinct posterior regions that the chains have not traversed. The appropriate conclusion is not to average the four chains and proceed: investigate the model and sampling, and assess whether the chains have explored the same posterior distribution.
The slope's units remain outcome units per year throughout this assessment. A visually attractive trace does not establish convergence, and the apparent lack of a trend is only one piece of diagnostic evidence.
Rank-Normalized Split R-hat
The split \(\hat{R}\) diagnostic compares variation within chains with variation between chains. Splitting each chain in half helps reveal changes between its early and late portions. Rank normalization makes the diagnostic more robust to heavy tails and differences in scale; a folded version also checks whether chains differ in spread. The reported rank-normalized split \(\hat{R}\) is the larger of the rank-based and folded rank-based values.
In outline, pool the retained draws, replace their values by ranks, and transform those ranks to approximately standard normal scores. For the folded version, first use the absolute deviations from the pooled median, then rank and transform those values. For either transformed data set, split each of the \(m\) original chains, each with \(N\) retained draws, into two chains of length \(N/2\). With \(2m\) split chains of length \(n'\), calculate the within-chain variance \(W\) and between-chain variance \(B\): \(W\) is the average of the split-chain sample variances, while \(B\) is \(n'\) times the sample variance of the split-chain means.
When chains have similar means and spreads, the between-chain variation is not substantially larger than the within-chain variation, and \(\hat{R}\) is near 1. A value near 1 is necessary evidence of agreement, not proof that all important parts of the posterior have been explored. A commonly used guideline is to seek rank-normalized split \(\hat{R}<1.01\) for parameters and quantities of interest. Treat this as a diagnostic threshold, not a universal guarantee.
Worked Example: Calculating a Split R-hat Component
Suppose four hypothetical chains each retain 1,000 draws. Splitting them produces eight chains of \(n'=500\) draws. For the rank-normalized draws, suppose the diagnostic calculation gives \(W=0.0400\) and \(B=0.0540\), in squared standard-normal-score units. The variance estimate is
Thus the rank-based component is
Suppose the independently calculated folded rank-based component is \(1.008\). The reported rank-normalized split \(\hat{R}\), the larger of the two, is therefore \(1.008\), below the common \(1.01\) guideline. This result is reassuring for this diagnostic, but it does not replace inspection of traces or checks of effective sample size and sampler behavior.
Effective Sample Size and Monte Carlo Standard Error
Autocorrelation reduces the information in a chain relative to the same number of independent draws. For a scalar quantity \(g(\theta)\), let \(\rho_t\) denote the lag-\(t\) autocorrelation of its sampled values. The integrated autocorrelation time is approximately \(1+2\sum_{t=1}^{\infty}\rho_t\), with the sum estimated using a stable truncation procedure in practice. If \(M\) draws are pooled across chains, the effective sample size (ESS) for that quantity is approximately \(M\) divided by its integrated autocorrelation time. ESS is an information-equivalent count, not a count of independent observations actually obtained.
ESS depends on the quantity being summarized. A parameter's mean, a tail probability, and a posterior quantile can have different effective sample sizes. Bulk ESS is aimed at the central part of a distribution; tail ESS assesses information in the tails. For a posterior mean with posterior standard deviation \(s_{\mathrm{post}}\), the Monte Carlo standard error (MCSE) is approximately \(s_{\mathrm{post}}/\sqrt{N_{\mathrm{eff}}}\). It describes simulation error in estimating the posterior mean, not uncertainty about the parameter itself.
Worked Example: Autocorrelation, ESS, and MCSE
Consider four hypothetical chains with 1,000 retained draws each, so \(M=4{,}000\). For a regression coefficient, suppose the lag autocorrelations are approximately \(\rho_t=0.5^t\). Since \(\sum_{t=1}^{\infty}0.5^t=1\), the integrated autocorrelation time is \(1+2(1)=3\), giving
Suppose the posterior standard deviation of this coefficient is \(0.120\) outcome units per year of education. The estimated Monte Carlo standard error of its posterior mean is
The posterior standard deviation describes posterior uncertainty in the coefficient; the MCSE describes numerical error in estimating its mean from the simulation. They answer different questions. If a conclusion depends on distinguishing a posterior mean from zero by only a few thousandths of an outcome unit per year, this MCSE may matter; if it is much smaller than the relevant reporting precision, additional draws may not change the reported mean materially.
For an estimated posterior probability or quantile, the mean-based MCSE formula above is not the appropriate formula. Use an MCSE estimate designed for that summary, along with its corresponding tail or quantile ESS. A large bulk ESS alone does not guarantee a precise estimate of a rare tail probability.
Hamiltonian Monte Carlo and Divergences
Hamiltonian Monte Carlo (HMC) uses numerical integration to propose movement through a posterior. A divergent transition indicates that the numerical trajectory could not accurately follow the intended Hamiltonian path under the chosen integration step size and trajectory. It is a warning that some posterior geometry may be inadequately explored, often in regions of high curvature or strong parameter dependence. A small count of divergences is not automatically harmless: their locations and the model's geometry matter, and any post-warm-up divergences warrant investigation.
Inspect where divergent transitions occur, including in plots of parameter pairs or transformed parameters when available. A pattern concentrated in a particular region can identify where exploration is unreliable. Increasing the target acceptance rate can reduce the integration step size and sometimes resolve divergences, but it is not a universal fix. Reconsidering parameterization or scaling may be needed. Also look for chains that move slowly, remain in separate regions, or show unusually persistent autocorrelation. A low \(\hat{R}\) does not override these warnings.
Worked Example: A Long Run With Poor Mixing
Suppose four hypothetical HMC chains each retain 2,000 draws of a regression coefficient, for \(M=8{,}000\). Their traces have long stretches in separate ranges, the rank-normalized split \(\hat{R}\) is \(1.04\), and the sampler reports 28 divergent transitions after warm-up. The coefficient's posterior standard deviation is \(0.50\) outcome units per year. These diagnostics do not support treating the pooled draws as a reliable representation of the posterior.
To see why draw count alone is misleading, suppose the estimated autocorrelation sum is \(9.5\). Then the integrated autocorrelation time is \(1+2(9.5)=20\), and
Treat even that MCSE as provisional: poor chain agreement and divergences mean the retained simulation may not adequately represent the target posterior, so a precision calculation cannot repair the convergence problem. Investigate the divergent regions and chain separation, consider a better-scaled or reparameterized model, and rerun and reassess the chains before reporting posterior summaries.
A Practical Diagnostic Sequence
Check multiple dispersed chains for trends, separation, sticking, and movement across plausible posterior regions.
Check rank-normalized split \(\hat{R}\), including its folded component, for every important parameter and derived quantity.
Check bulk or tail ESS as appropriate, and calculate an MCSE suited to each reported summary.
Examine divergences and other signs of poor mixing, address likely causes, and repeat the diagnostic assessment after changes.
The relevant ESS target depends on the required precision and the summaries being reported. A common practical guideline is at least 400 effective draws for a quantity of interest, but this is not a guarantee of adequate precision for every tail probability, quantile, or decision. Compare MCSE with the precision needed for the substantive conclusion.
Common Mistake
Wrong reasoning: “There are thousands of post-warm-up draws, so the posterior mean must be accurate.” This treats correlated draws as independent and ignores whether the chains explored the same target distribution. Correction: assess chain agreement and exploration with traces, split \(\hat{R}\), and sampler diagnostics; assess the numerical precision of each summary with an appropriate ESS and MCSE. When chains have not mixed or HMC has unresolved divergences, do not treat a small computed MCSE as evidence that the posterior summary is trustworthy.
Check Your Understanding
Answer each question using the diagnostic ideas in this tutorial.
- Why can agreement between chains that all started from nearly identical initial values be less informative than agreement between dispersed chains?
- What does a rank-normalized split \(\hat{R}\) near 1 indicate, and what does it not establish?
- If a chain's autocorrelations are larger, what generally happens to its ESS for a fixed number of draws?
- Explain the difference between posterior standard deviation and the MCSE of a posterior mean.
- Why should post-warm-up HMC divergences prompt investigation even when the total number of retained draws is large?