Compute quantiles of a sample and return them in a format consistent with other summary functions in the posterior package.
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].- na.rm
(logical) Should
NAandNaNvalues be removed fromxprior to computing quantiles? The default isFALSE.- ...
Arguments passed to individual methods (if applicable) and then on to
stats::quantile().- names
(logical) Should the result have a
namesattribute? The default isTRUE, but useFALSEfor improved speed if there are many values inprobs.
Value
A numeric vector of length length(probs). If names = TRUE, it has a
names attribute with names like "q5", "q95", etc, based on the values
of probs.
Examples
mu <- extract_variable_matrix(example_draws(), "mu")
quantile2(mu)
#> q5 q95
#> -0.8536202 9.3873124