Folded draw and Blom rank fraction for a rank-normalised R-hat

Prepares one draw for the rank-normalised diagnostic of Vehtari and colleagues. zeta is the folded draw, the absolute deviation of the draw from the median of all draws, which turns a difference in the scale of the chains into a difference in location. f_r is the fraction with the offset that the authors take from Blom, for a value of rank r among the S pooled draws. The normal score is the inverse standard normal of f_r, which the site calculator does not hold, so the line stops at f_r and the Excel row takes the inverse. Normal scores of theta, kept in the positions of their draws and put through HE-FM-CON-001 in place of the draws, give the rank-normalised value, and normal scores of zeta, ranked among all the folded draws, give the folded value. Ranks keep the statistic defined when the posterior has no finite mean or variance.

Signature

zeta = abs(theta - theta_med); f_r = (r - 3 / 8) / (S + 1 / 4)
Inputs
InputsDefinitionUnit
thetaValue of one retained draw of the scalar estimandunits of the estimand
theta_medMedian of the retained draws of the estimand pooled over all chainsunits of the estimand
rRank of the value being scored within the pooled values, at least 1 and at most S, with average ranks for ties, so it can end in .5rank
SNumber of retained draws from all chains, m times ndraws
Output
zetaAbsolute deviation of the draw from the median of all draws, zero or aboveunits of the estimand
f_rr minus 3/8, divided by S plus 1/4, above zero and below 1, whose inverse standard normal is the normal scoreproportion

Function

Convergence checks on MCMC draws by split chains, rank normal scores and Monte Carlo error

Maps stored simulation output to the checks that show whether a Bayesian result has settled. For one scalar estimand it returns the split-chain potential scale reduction factor R_hat from split-chain means and variances (HE-FM-CON-001, with HE-CF-CON-001 for stored draws), the folded draw and rank fraction behind the rank-normalised version (HE-FM-CON-002), the conservative reported value with its use rule (HE-FM-CON-003) and the ratio of Monte Carlo error to posterior standard deviation (HE-FM-CON-004). The precision of independent probabilistic runs is live and is not restated. HE-FN-PSA-001 sets out the Monte Carlo standard error of a mean as the form of HE-FM-ANTV-002 with one observation per draw, HE-CF-PSA-001 computes it, the standard error of a share of runs has the form of SE_p in HE-FM-BINOM-004, an interval around the mean is HE-FM-AN-001, and the draws needed for a target standard error are HE-FM-ABM-003 and HE-FM-ABM-004. The article's sizing example applies these records, its 14,400 runs being HE-FM-ABM-003 with s_run 12,000 and e_target 100, and its 6,147 runs the same record with e_target 300 / 1.96, rounded up. The effective sample size has its own concept page and enters here as an input. Notation follows the Convergence article.

Try this function

Implementations

  • Excel

    Folded draw, Blom fraction and normal score from a named range of draws

    With the draw in DrawValue and all retained draws in PooledDraws, the formulas fill DrawMedian, FoldedDraw, DrawRank, TotalDraws, BlomFraction and NormalScore. For the folded score, put the folded values in a range and run the rank, count, fraction and score formulas on that range. COUNT ignores blanks and text, so a gap lowers S. NORM.S.INV returns #NUM! at a fraction of 0 or 1, which the offset prevents for ranks at least 1 and at most S (derived). RANK.AVG returns #N/A when DrawValue is not in the range.

    =MEDIAN(PooledDraws); =ABS(DrawValue-DrawMedian); =RANK.AVG(DrawValue,PooledDraws,1); =COUNT(PooledDraws); =(DrawRank-3/8)/(TotalDraws+1/4); =NORM.S.INV(BlomFraction)

Assumptions

  • Ranks taken over the pooled draws with average ranks for ties

    Vehtari and colleagues replace each value by its rank within the pooled draws from all chains and use average ranks for ties, which conserves the number of unique values of a discrete quantity. Differences between chains survive only because the ranks are pooled.

  • Folded draws taken about the median and ranked again

    The folded draw is the absolute deviation from the median, as in equation 15 of Vehtari and colleagues, read here as the median of the pooled draws. The folded values are then ranked among themselves before scoring, so r differs from the rank of theta.

Worked examples

  • Lowest of 2,000 pooled draws

    An illustrative lowest draw of minus 0.70 among 2,000 draws with a median of minus 0.45 folds to 0.25. Its rank of 1 gives a fraction of 0.000312, whose normal score is about minus 3.42.

    theta = -0.70; theta_med = -0.45; zeta = 0.25; r = 1; S = 2000; f_r = 0.000312
  • Middle of 2,000 pooled draws

    An illustrative draw at the median folds to 0, and the average rank of 1,000.5 gives a fraction of exactly 0.5 and a normal score of 0, a limiting case that checks an implementation.

    theta = -0.45; theta_med = -0.45; zeta = 0; r = 1000.5; S = 2000; f_r = 0.5
  • Highest of 2,000 pooled draws

    An illustrative highest draw of minus 0.20 also folds to 0.25, the same distance from the median as the lowest draw. Its fraction of 0.999688 is one minus that of the lowest draw (derived), so the two normal scores are mirror images.

    theta = -0.20; theta_med = -0.45; zeta = 0.25; r = 2000; S = 2000; f_r = 0.999688

Common errors

  • Ranking within each chain in place of over the pooled draws

    Ranks taken inside each chain give every chain the same set of scores, which removes differences in location. On the illustrative table in HE-CF-CON-001 with the second chain out of line, split-chain R_hat on such scores is 0.8826 against 1.6984 with pooled ranks, so the failed run appears to pass (computed here).

  • Using rank over count without the offset

    A plain r / S equals 1 at the highest rank, where NORM.S.INV returns #NUM!, and at the lowest of 2,000 draws it gives a score of minus 3.2905 in place of minus 3.4206 (derived).

  • Keeping the rank of theta for the folded draw

    The folded statistic scores the ranks of zeta among all the folded draws. The rank of theta orders draws by value, so the lowest and highest draws in the worked examples receive opposite scores although both fold to 0.25, and the scale of the chains is not tested (derived).

Sources

  • Vehtari and colleagues on rank normalisation and folding

    Vehtari A, Gelman A, Simpson D, Carpenter B, Bürkner PC. Rank-normalization, folding, and localization: an improved R-hat for assessing convergence of MCMC. arXiv:1903.08008v5. Published as Bayesian Analysis. 2021;16(2):667-718, doi:10.1214/20-BA1221 (published version not seen). Preprint section 4.1 sets out the replacement of each value by its rank within the pooled draws from all chains, average ranks for ties and equation 14, the inverse normal transformation of r minus 3/8 over S plus 1/4, citing Blom 1958 for the fractional offset, and states that the rank-normalised statistic uses the equations of section 3.1. Preprint section 4.2 gives equation 15, the absolute deviation from the median, and calls the rank-normalised statistic on those values folded-split-R.

    View source →

Canonical Identity

Stable URI · Machine-readable · Resolvable · CC BY 4.0

This formula is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).

Author: Dr Darrin Baines · Publisher: Intelligent Parameters Ltd · Identifier: https://healtheconomics.wiki/formula/folded-draw-and-blom-rank-fraction-for-a-rank-normalised-r-hat