Why Compare Multiple Chains?
Several chains can produce plausible-looking traces while exploring different parts of a target distribution. Comparing only their running means or autocorrelations may not reveal persistent disagreement in location or scale. Rank-normalized R-hat is a diagnostic that compares variation within chains with variation among chains, after splitting each chain and transforming pooled ranks to normal scores. The split helps reveal changes between the early and late portions of a run; the rank transformation makes the diagnostic less sensitive to the scale and tails of the original parameter.
Suppose \(M\) chains each provide \(N\) scalar draws \(X_{m,1},\ldots,X_{m,N}\), where \(m=1,\ldots,M\). Regard these draws as the output of \(M\) MCMC runs on a common probability space \((\Omega,\mathcal{F},\mathbb{P})\). The formulas below are applied to the recorded draws; they do not assume those draws are independent. For simplicity, take \(N\) even and divide each chain into its first and last \(N/2\) draws. This produces \(m=2M\) split chains, each of length \(n=N/2\). The letter \(m\) below denotes the number of split chains, not the number of original chains.
To rank-normalize, pool the \(S=mn\) draws from the split chains and assign each draw its pooled rank \(r\). For ties, use the average of the ranks the tied observations would occupy. Convert the rank to the score \(z=\Phi^{-1}((r-3/8)/(S+1/4))\), where \(\Phi\) is the standard normal distribution function. Then compute \(\hat R\) from the scores, not the original draws. This is the rank-normalized split R-hat.
A second calculation targets scale differences. Find the median of all pooled draws and replace each draw by its absolute deviation from that median. Rank-normalize these deviations using the same plotting-position formula, then calculate split R-hat again. This gives the folded rank-normalized R-hat. The reported rank-normalized R-hat is the larger of the ordinary rank-normalized and folded values. The folding is useful because chains can have similar centers but noticeably different spreads.
What the R-hat Formula Compares
Proof. Starting from the definition, divide the expression for \(\widehat{\operatorname{Var}}^{+}\) by \(W\), which is permitted because \(W>0\). This gives \(\hat R^2=(n-1)/n+B/(nW)\). Since \((n-1)/n=1-1/n\), rearranging gives \(\hat R^2=1+(B/W-1)/n\). Because \(\hat R\) is the nonnegative square root, comparing it with \(1\) is equivalent to comparing \(\hat R^2\) with \(1\). The displayed identity then gives the stated conditions. \(\square\)
The identity describes the calculation, not a convergence theorem. A value near one says that the estimated between-chain and within-chain variation are similar for these transformed draws. It does not establish that the chains have reached stationarity, explored every relevant region, or accurately estimated a desired quantity. A numerical cutoff is a screening convention, not proof.
Proof. Let \(g\) be strictly increasing. For any two pooled draws \(x\) and \(y\), \(x<y\) implies \(g(x)<g(y)\), and \(x>y\) implies \(g(x)>g(y)\). Therefore every pairwise ordering, and thus every pooled rank, is unchanged by applying \(g\). The score assigned to a rank depends only on that rank and on \(S\); it is consequently unchanged as well. The split-chain means, variances, and R-hat computed from those scores are then unchanged. \(\square\)
This rank invariance applies to the ordinary rank-normalized calculation. Folding is a separate operation on absolute deviations from the pooled median; its purpose is to compare spread as well as location, so it should not be interpreted as merely applying an increasing transformation to the original draws.
Worked Example: Splitting and Computing Ordinary R-hat
Consider two recorded chains, each of length four: chain 1 is \(0,0,0,4\), and chain 2 is \(2,2,2,6\). Split each into halves. The four split chains are \((0,0)\), \((0,4)\), \((2,2)\), and \((2,6)\), each with \(n=2\).
Their means are \(0,2,2,4\), so the overall mean of the four split-chain means is \(\bar X_{\cdot}=(0+2+2+4)/4=2\). The sample variances are \(0,8,0,8\): for a pair \(a,b\), the sample variance is \(((a-(a+b)/2)^2+(b-(a+b)/2)^2)/(2-1)=(a-b)^2/2\). In particular, each nonconstant pair has variance \(4^2/2=8\). Hence \(W=(0+8+0+8)/4=4\).
The squared deviations of the four means from \(2\) are \(4,0,0,4\), whose sum is \(8\). Thus \(B=2(8)/(4-1)=16/3\). Substitution gives \(\widehat{\operatorname{Var}}^{+}=(1/2)4+(1/2)(16/3)=14/3\), and \(\hat R=\sqrt{(14/3)/4}=\sqrt{7/6}\), approximately \(1.080\).
Check: The four means average to \(2\), the sample variances average to \(4\), and substituting \(W=4\) and \(B=16/3\) into the defining formula gives \(\widehat{\operatorname{Var}}^{+}=14/3\), as used above. The value above one reflects greater estimated between-chain variation than within-chain variation at this split and sample size.
Rank Normalization in a Small Example
Worked Example: Rank-Normalized Split R-hat
Take two original chains of length four: chain 1 is \(1,2,7,8\), and chain 2 is \(3,4,5,6\). Splitting gives \((1,2),(7,8),(3,4),(5,6)\). The pooled ranks are \(1\) through \(8\), with no ties. For \(S=8\), the plotting positions for ranks \(1,2,3,4\) are \(0.625/8.25\), \(1.625/8.25\), \(2.625/8.25\), and \(3.625/8.25\); the remaining four positions are their reflections about \(1/2\). Applying \(\Phi^{-1}\) gives approximate scores \(-1.436,-0.852,-0.473,-0.152,0.152,0.473,0.852,1.436\).
In split-chain order, the four score pairs are \((-1.436,-0.852)\), \((0.852,1.436)\), \((-0.473,-0.152)\), and \((0.152,0.473)\). Their means are \(-1.144,1.144,-0.3125,0.3125\), with overall mean \(0\). The within-chain sample variances are \((0.584)^2/2=0.170528\), \(0.170528\), \((0.321)^2/2=0.0515205\), and \(0.0515205\). Thus \(W=(0.170528+0.170528+0.0515205+0.0515205)/4=0.11102425\).
The sum of squared chain means is \(2(1.144^2)+2(0.3125^2)=2(1.308736)+2(0.09765625)=2.8127845\). Therefore \(B=(2/3)(2.8127845)=1.8751897\) to the shown precision. Then \(\widehat{\operatorname{Var}}^{+}=(1/2)(0.11102425)+(1/2)(1.8751897)\approx0.9931070\), and the rank-normalized split R-hat is approximately \(\sqrt{0.9931070/0.11102425}\approx2.991\).
Check: The four rank-score chain means sum to zero, as required for their overall mean of zero. Substituting the displayed \(W\) and \(B\) into the variance formula gives approximately \(0.9931070\); dividing by \(W\) gives approximately \(8.945\), whose square root is approximately \(2.991\). The large value reflects that the first and second halves of the original chains occupy separated portions of the pooled rank order.
Folding to Detect Scale Disagreement
Worked Example: Folded R-hat with Different Chain Scales
Suppose the folded rank-normalized scores for four split chains of length two are \((1.097,0.308)\), \((1.097,0.308)\), \((-1.097,-0.308)\), and \((-1.097,-0.308)\). These are already the scores after taking deviations from the pooled median, ranking those deviations, and transforming the ranks. They provide a compact calculation of the folded statistic.
Each pair has mean \(0.7025\) or \(-0.7025\), since \((1.097+0.308)/2=0.7025\). The four means have overall mean zero. Each pair's difference is \(1.097-0.308=0.789\), so its sample variance is \(0.789^2/2=0.622521/2=0.3112605\). Consequently \(W=0.3112605\).
The sum of squared chain means is \(4(0.7025^2)=4(0.49350625)=1.974025\), so \(B=(2/3)(1.974025)=1.3160167\) to seven decimal places. The pooled estimate is \(\widehat{\operatorname{Var}}^{+}=(0.3112605+1.3160167)/2\approx0.8136386\). Therefore \(\hat R_{\mathrm{folded}}=\sqrt{0.8136386/0.3112605}\approx1.6168\).
Check: The within-chain variance recomputed from the pair difference is \(0.789^2/2=0.3112605\). The between-chain calculation uses the four means at the same threshold: \(2[4(0.7025^2)/3]\approx1.3160167\). Substitution gives the stated pooled estimate and folded R-hat. A folded value above one signals scale disagreement in these transformed draws, even if a location-based comparison alone looks reassuring.
Interpretation and Common Pitfalls
For a scalar parameter, compute the ordinary rank-normalized statistic and the folded statistic, then report their maximum. For a vector parameter, apply the diagnostics to each scalar component of interest; a reassuring value for one component says nothing by itself about another. Rank normalization can reduce sensitivity to extreme magnitudes, while folding asks whether chains differ in their distance from a common center. Neither calculation repairs poor exploration or substitutes for inspecting traces and other diagnostics.
Common mistake: a small numerical difference in an intermediate calculation can materially change the final statistic. In the folded example, incorrectly using \(0.7025^2=0.493\) and then rounding too early can produce an inaccurate \(B\). Recompute from the displayed value: \(0.7025^2=0.49350625\), so \(2[4(0.7025^2)/3]=2(1.974025/3)=1.3160167\), not \(1.3174\). Using \(W=0.3112605\), the pooled estimate is \((0.3112605+1.3160167)/2\approx0.8136386\), and the folded statistic is approximately \(1.6168\). The correction is not to infer convergence from the revised value, but to calculate accurately and interpret the diagnostic cautiously.
Another pitfall is to treat a conventional cutoff, such as a value close to one, as a mathematical guarantee. The statistic is computed from finite output and summarizes particular comparisons of within-chain and between-chain variation. It cannot prove that the target distribution was reached or that all relevant regions were explored. Conversely, a high value is a reason to investigate the chains, not by itself an explanation of what went wrong. When all within-chain variances are zero, \(W=0\), so the ratio in the definition is undefined; do not report a finite R-hat by dividing by zero. Ties are handled through average ranks, and the same pooled ranks must be used for all split chains.
Check Your Understanding
Use the definitions and show the intermediate calculations in each answer.
- Why are the first and second halves of each original chain treated as separate chains in split R-hat?
- For eight pooled draws, write the plotting position assigned to rank \(r=3\) before applying \(\Phi^{-1}\).
- If \(n=4\), \(W=2\), and \(B=5\), compute \(\widehat{\operatorname{Var}}^{+}\) and \(\hat R\).
- Explain what a folded R-hat can reveal that a location comparison may miss.
- Give one reason that an R-hat near one is not proof of convergence.