Skip to contents

Computes the rank-normalized bulk and tail effective sample size (ESS) of Vehtari, Gelman, Simpson, Carpenter & Buerkner (2021, Bayesian Analysis) for each column of a matrix of posterior draws. ess_bulk measures the effective number of independent draws available for estimating the posterior mean/median; ess_tail is the minimum of the 5th- and 95th-percentile indicator ESS, relevant for tail-quantile / credible-interval precision. Autocovariance is computed via fft (Geyer's initial monotone sequence estimator of the integrated autocorrelation time).

Usage

ess(draws)

Arguments

draws

A matrix of posterior draws (rows = iterations, columns = parameters) for a single chain, or a list of such matrices (one per chain, identical dimensions).

Value

A numeric matrix, one row per parameter, two columns ("bulk", "tail"); NA for parameters with zero variance or a non-finite result.

Examples

set.seed(42)
draws <- matrix(rnorm(2000), ncol = 2,
                dimnames = list(NULL, c("a", "b")))
ess(draws)
#>       bulk     tail
#> a 998.1982 907.0437
#> b 867.8419 929.8368