Compute effective sample size estimates for quantile estimates of a single variable.

ess_quantile(x, probs = c(0.05, 0.95), ...)

# S3 method for default
ess_quantile(x, probs = c(0.05, 0.95), names = TRUE, ...)

# S3 method for rvar
ess_quantile(x, probs = c(0.05, 0.95), names = TRUE, ...)

ess_median(x, ...)

# S3 method for default
ess_mean(x, ...)

## Arguments

x

(multiple options) One of:

• A matrix of draws for a single variable (iterations x chains). See extract_variable_matrix().

• An rvar.

probs

(numeric vector) Probabilities in [0, 1].

...

Arguments passed to individual methods (if applicable).

names

(logical) Should the result have a names attribute? The default is TRUE, but use FALSE for improved speed if there are many values in probs.

## Value

If the input is an array, returns a numeric vector with one element per quantile. If any of the draws is non-finite, that is, NA, NaN, Inf, or -Inf, the returned output will be a vector of (numeric) NA values. Also, if all draws of a variable are the same (constant), the returned output will be a vector of (numeric) NA

values as well. The reason for the latter is that, for constant draws, we cannot distinguish between variables that are supposed to be constant (e.g., a diagonal element of a correlation matrix is always 1) or variables that just happened to be constant because of a failure of convergence or other problems in the sampling process.

If the input is an rvar and length(probs) == 1, returns an array of the same dimensions as the rvar, where each element is equal to the value that would be returned by passing the draws array for that element of the rvar to this function. If length(probs) > 1, the first dimension of the result indexes the input probabilities; i.e. the result has dimension c(length(probs), dim(x)).

## References

Aki Vehtari, Andrew Gelman, Daniel Simpson, Bob Carpenter, and Paul-Christian Bürkner (2021). Rank-normalization, folding, and localization: An improved R-hat for assessing convergence of MCMC (with discussion). Bayesian Data Analysis. 16(2), 667-–718. doi:10.1214/20-BA1221

## See also

Other diagnostics: ess_basic(), ess_bulk(), ess_sd(), ess_tail(), mcse_mean(), mcse_quantile(), mcse_sd(), rhat_basic(), rhat(), rstar()

## Examples

mu <- extract_variable_matrix(example_draws(), "mu")
ess_quantile(mu, probs = c(0.1, 0.9))
#>  ess_q10  ess_q90
#> 300.6674 325.0324

d <- as_draws_rvars(example_draws("multi_normal"))
ess_quantile(d\$mu, probs = c(0.1, 0.9))
#>             [,1]     [,2]     [,3]
#> ess_q10 383.4835 468.2163 340.6056
#> ess_q90 389.0418 419.6722 271.5482