Skip to content

Commit c127edc

Browse files
committed
updated CmdStan and Ref-manual for rank-normalized split R-hat and ESS
1 parent 051a291 commit c127edc

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

src/bibtex/all.bib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,7 @@ @article{Magnusson+etal:2024:posteriordb
18671867
author={Magnusson, M{\aa}ns and Torgander, Jakob and B{\"u}rkner, Paul-Christian and Zhang, Lu and Carpenter, Bob and Vehtari, Aki},
18681868
journal={arXiv preprint arXiv:2407.04967},
18691869
year={2024}
1870+
}
18701871

18711872
@article{egozcue+etal:2003,
18721873
title={Isometric logratio transformations for compositional data analysis},

src/cmdstan-guide/stansummary.qmd

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ diagnostic statistics on the sampler chains, reported in the following order:
1212

1313
- Mean - sample mean
1414
- MCSE - Monte Carlo Standard Error, a measure of the amount of noise in the sample
15-
- StdDev - sample standard deviation
15+
- StdDev - sample standard deviation - the variance around the sample mean.
16+
- MAD - Median Absolute Deviation - the variance around the sample median.
1617
- Quantiles - default 5%, 50%, 95%
17-
- N_eff - effective sample size - the number of independent draws in the sample
18-
- N_eff/S - the number of independent draws per second
18+
- ESS_bulk
19+
- ESS_tail
1920
- R_hat - $\hat{R}$ statistic, a measure of chain equilibrium, must be within $0.05$ of $1.0$.
2021

2122
When reviewing the `stansummary` output, it is important to check the final three
2223
output columns first - these are the diagnostic statistics on chain convergence and
2324
number of independent draws in the sample.
24-
A $\hat{R}$ statistic of greater than $1.05$ indicates that the chain has not converged and
25+
A $\hat{R}$ statistic of greater than $1.01$ indicates that the chain has not converged and
2526
therefore the sample is not drawn from the posterior, thus the estimates of the mean and
2627
all other summary statistics are invalid.
2728

@@ -34,12 +35,16 @@ For more information, see the
3435
[Posterior Analysis](https://mc-stan.org/docs/reference-manual/analysis.html)
3536
chapter of the Stan Reference Manual which describes both the theory and practice of MCMC
3637
estimation techniques.
38+
39+
The statistics - Mean, StdDev, MAD, and Quantiles - are computed directly from all draws across all chains.
40+
The diagnostic statistics - MCSE, ESS_bulk, ESS_tail, and R_hat are computed from the rank-normalized,
41+
folded chains according to the definitions in @Vehtari+etal:2021:Rhat.
3742
The summary statistics and the algorithms used to compute them are described in sections
3843
[Notation for samples](https://mc-stan.org/docs/reference-manual/analysis.html#notation-for-samples-chains-and-draws)
3944
and
4045
[Effective Sample Size](https://mc-stan.org/docs/reference-manual/analysis.html#effective-sample-size.section).
4146

42-
## Building the stansummary command
47+
## Building the `stansummary` command
4348

4449
The CmdStan makefile task `build` compiles the `stansummary` utility
4550
into the `bin` directory.

src/reference-manual/analysis.qmd

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,27 @@ because the first half of each chain has not mixed with the second
190190
half.
191191

192192

193-
### Convergence is global {-}
193+
### Rank-normalization helps when there are heavy tails {-}
194+
195+
Split R-hat and the effective sample size (ESS) are well defined only if
196+
the marginal posteriors have finite mean and variance.
197+
Therefore, following @Vehtari+etal:2021:Rhat, we compute the rank-normalized
198+
paramter values and then feed them into the formulas for split R-hat and ESS.
199+
200+
Rank normalization proceeds as follows:
201+
202+
* First, replace each value $\theta^{(nm)}$ by its rank $r^{(nm)}$ within the pooled
203+
draws from all chains. Average rank for ties are used to conserve
204+
the number of unique values of discrete quantities.
205+
206+
* Second, transform ranks to normal scores using the inverse normal transformation
207+
and a fractional offset:
194208

209+
$$
210+
z_{(nm)} = \Phi^{-1} \left( \frac{r_{(nm)} - 3/8}{S - 1/4} \right)
211+
$$
212+
213+
### Convergence is global {-}
195214
A question that often arises is whether it is acceptable to monitor
196215
convergence of only a subset of the parameters or generated
197216
quantities. The short answer is "no," but this is elaborated

0 commit comments

Comments
 (0)