credibleInterval: Calculate credible interval from MCMC draws

View source: R/credibleInterval.R

credibleIntervalR Documentation

Calculate credible interval from MCMC draws

Description

This function calculates a credible interval of the specified width from a vector of MCMC draws.

Usage

credibleInterval(draws, width)

Arguments

draws

A numeric vector containing MCMC draws.

width

A numeric value between 0 and 1 specifying the desired width of the credible interval.

Details

The function calculates the lower and upper bounds of the credible interval using the quantile function based on the specified width.

Value

A named list containing three elements:

  • width: The specified width of the credible interval.

  • lower_bound: The lower bound of the credible interval.

  • upper_bound: The upper bound of the credible interval.

Examples

# Generate example draws
draws <- rnorm(1000)

# Calculate 95% credible interval
credibleInterval(draws, width = 0.95)


imt documentation built on Sept. 11, 2024, 5:41 p.m.