If a sampling chain fluctuates up and down around some level with no obvious trend, can we conclude that it has explored the target distribution? In 1990, in a simulation of an Ising model, Andrew Gelman and Donald Rubin ran Gibbs sampling chains from different starting points, one chain from each. Viewed on its own, each trace looked as if it was settling down; put together, they showed two chains sitting in different regions. This example moved the question on from "does a single chain look stable?" to "do different chains give consistent results?" [1]
From a single trace to multiple chains
In Bayesian analysis, Markov chain Monte Carlo (MCMC) approximates the posterior distribution with a string of correlated draws. For a given parameter or other single numerical quantity, one can run several chains from different starting points, discard the warmup phase, and compare the draws retained from each chain. If exploration is adequate, the different chains should be describing the same target distribution; they need not take the same value at every step.
R-hat (written R̂) puts two scales side by side: how large the fluctuation is within one chain, and how large the overall fluctuation is once the differences between chains are taken into account. If every chain moves only within a narrow range internally while the centers of the chains lie far apart, the latter will be markedly larger than the former, and R̂ will be large too. [2]
Writing within-chain and between-chain differences as formulas
Start with a basic formula with no chain splitting and no rank transformation. Suppose there are m chains, each retaining n values; the mean of chain i is μᵢ, its sample variance is sᵢ², and the average of all the chain means is μ̄. The denominator of sᵢ² is n−1; the sample variance of the chain means below uses the denominator m−1. [2]
- Within-chain variance:
W = (s₁² + ⋯ + sₘ²) / m. - Between-chain quantity:
B = n × [(μ₁ − μ̄)² + ⋯ + (μₘ − μ̄)²] / (m − 1). - Combined variance estimate:
V⁺ = [(n − 1) / n] × W + B / n. - Basic ratio:
R̂ = √(V⁺ / W).
W is the average of the chains' sample variances; B is the sample variance of the chain means multiplied by n. V⁺ combines these two terms and is then compared with W. If the parameter has a unit, the units of W, B, and V⁺ are all the square of that unit; R̂, after the square root is taken, is unitless.
Working through two sets of numbers
The following are number sequences constructed for the calculation, not MCMC draws. Each set pairs A with another sequence; each sequence has 8 numbers.
| Sequence | 8 numbers | Mean | Sample variance |
|---|---|---|---|
| A | 0, 1, 0, 1, 0, 1, 0, 1 | 0.5 | 2/7 |
| B₁ | 4, 5, 4, 5, 4, 5, 4, 5 | 4.5 | 2/7 |
| B₂ | 0, 1, 2, 1, 0, 1, 2, 1 | 1 | 4/7 |
First compare A and B₁. Each of the two sequences alternates between two adjacent numbers, yet their means are 0.5 and 4.5 respectively. Substituting m = 2 and n = 8: W = 2/7; the grand mean of the two means is 2.5, and B = 8 × [(0.5 − 2.5)² + (4.5 − 2.5)²] = 64. So V⁺ = (7/8) × (2/7) + 64/8 = 8.25, and R̂ = √[8.25 / (2/7)] ≈ 5.374.
Now replace B₁ with B₂. The means of the two sequences become 0.5 and 1, W = 3/7, B = 1, V⁺ = (7/8) × (3/7) + 1/8 = 0.5, and the basic R̂ ≈ 1.080. Here the difference between the chain centers has shrunk, and W has changed as well; the fall in the ratio reflects the change in both parts together.
The first set shows the contradiction R-hat is meant to catch: each fluctuates little, yet they lie far apart. The second set's value is closer to 1, which only indicates that the difference seen by this basic ratio is smaller. Neither of these two numbers can be compared directly with the recommended threshold for Stan's improved R-hat.

Figure 1 | Two sets of artificially constructed sequences used to demonstrate between-chain and within-chain differences; the two panels show the separated sequences and the more overlapping sequences respectively. Computed with the basic formula without chain splitting, the ratios are about 5.374 and 1.080; these numbers are not actual MCMC draws, nor are they Stan's current improved R-hat.
Why splitting, ranking, and folding are still needed
Looking only at the chain means and variances of the raw values still misses some problems. The paper by Vehtari and colleagues gives counterexamples: the chain means may be close while one chain has a smaller variance and has not adequately explored the tails; under heavy-tailed distributions, the traditional comparison of variances can also lose its diagnostic power. [3]
Split R-hat treats the first half and the second half of each chain as separate sequences to be compared. In this way, when one chain drifts slowly from low to high and another drifts from high to low, the difference between the first and second halves may still be detected even if the averages of the whole chains look close. [2]
Besides splitting, the improved R-hat reported by Stan uses rank normalization and folding. One diagnostic rank-normalizes the raw draws, converting the pooled ranks into normal scores to lessen the influence of heavy tails; the other first takes the absolute difference between each raw draw and the median of the pooled sample to form folded values, and then applies rank normalization and splitting to the folded values in order to detect differences in scale. The larger of these two diagnostics is what is finally reported. [2][3]
Stan's diagnostics guide recommends running at least four chains by default and, for final inference, generally requires the reported R-hat to be below 1.01. That figure applies to the improved diagnostic described above; the 5.374 and 1.080 earlier are teaching calculations with the basic formula, not results reported by Stan. [4]
Putting R-hat back among the sampling diagnostics
An R-hat close to 1 means that this diagnostic has found no marked between-chain or split-chain differences; it cannot prove that the chains have traversed the target distribution. If all the chains are trapped in the same local region, they may resemble one another while jointly missing other places. Choosing dispersed starting points and checking multiple parameters and derived quantities of interest help to expose this kind of problem. [2][3]
When R-hat is found to be large, first locate the specific parameter and look at the trace plots or rank plots of the chains: are the chains separated from one another for long stretches, or is there still drift within chains? Check the sampler's other warnings at the same time. For example, Stan's divergent transitions may be related to posterior geometry that is hard to explore. Examine the model, the priors, and the parameterization in light of what is seen, then sample again and compare the diagnostic results. [4]
Even when R-hat is close to 1, one should also look at the effective sample size (ESS) and the Monte Carlo standard error (MCSE): the former reflects the effect of correlated draws on the amount of information, and the latter measures the simulation error of the target estimate. When the posterior mean or median is of interest, look at bulk-ESS; when interval endpoints are of interest, look at tail-ESS as well, and compare the MCSE of the relevant estimate with the precision required. [3][4]
References
-
Andrew Gelman. R-hat, August 1990. 2026-10-29.
-
Stan Development Team. Stan Reference Manual 2.38: Posterior Analysis. No date given.
-
Aki Vehtari, Andrew Gelman, Daniel Simpson, Bob Carpenter, Paul-Christian Bürkner. Rank-normalization, folding, and localization: An improved R-hat for assessing convergence of MCMC. 2021-06-22.
-
Stan Development Team. How to Diagnose and Resolve Convergence Problems. No date given.
-
Research Methods · Rituals can be imitated; understanding cannot be faked
-
Compiled and published by the Scholay one-stop academic platform. If anything here infringes your rights, please let us know and it will be taken down.
-
Also published on EnterScholar, a community for scholars in the age of intelligence