Compute quantiles of a sample and return them in a format consistent with other summary functions in the posterior package.

quantile2(x, probs = c(0.05, 0.95), names = TRUE, na.rm = FALSE, ...)

Arguments

x

(matrix) Draws for a single variable (iterations x chains). See extract_variable_matrix().

probs

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

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.

na.rm

(logical) Should NA and NaN values be removed from x prior to computing quantiles? The default is FALSE.

...

Further arguments passed to stats::quantile().

Examples

mu <- extract_variable_matrix(example_draws(), "mu") quantile2(mu)
#> q5 q95 #> -0.8536202 9.3873124