quantile_hdi: Compute quantiles of a probability distrbution based on...

View source: R/helper_funcs.R

quantile_hdiR Documentation

Compute quantiles of a probability distrbution based on highest density intervals (HDIs)

Description

quantile_hdi computes any number of highest density quantiles from a sample of representative values, estimated as shortest credible intervals. If quantile contains 0, 0.5, or 1, will return the minimum, median, and maximum respectively.

Usage

quantile_hdi(var, quantile, moment = "mean", ...)

Arguments

var

A vector of representative values from a probability distribution (e.g., MCMC samples).

quantile

A vector of quantiles to return.

moment

A string indicating the first moment to return ("mean" or "median") if quantile contains 0.5.

...

Internal arguments.

Value

A sorted vector with all specified quantiles.

Examples

p_density <- rnorm(100, 2, 0.5)
quantile_hdi(p_density, c(0, 0.025, 0.5, 0.0975, 1))

qdercon/pstpipeline documentation built on June 1, 2025, 1:11 p.m.