Learn R Programming

psycho (version 0.4.91)

HDI: Highest Density Intervals (HDI).

Description

Compute the Highest Density Intervals (HDI) of a distribution.

Usage

HDI(x, prob = 0.95)

Arguments

x

A vector of values from a probability distribution (e.g., posterior probabilities from MCMC sampling).

prob

Scalar between 0 and 1, indicating the mass within the credible interval that is to be estimated.

Examples

Run this code
# NOT RUN {
library(psycho)

distribution <- rnorm(1000, 0, 1)
HDI_values <- HDI(distribution)
print(HDI_values)
plot(HDI_values)
summary(HDI_values)

x <- matrix(rexp(200), 100)
HDI_values <- HDI(x)
# }

Run the code above in your browser using DataLab