Learn R Programming

bfp (version 0.0-48)

empiricalHpd: Construct an empirical HPD interval from samples

Description

Construct an empirical highest posterior density (HPD) interval from samples which have been drawn from the distribution of a quantity of interest.

Usage

empiricalHpd(theta, level)

Value

A vector with the estimated lower and upper bounds of the HPD interval.

Arguments

theta

the vector of samples

level

the credible level

Author

Daniel Saban\'es Bov\'e

Examples

Run this code
## draw standard normal variates
test <- rnorm(n=1000)

## estimate the 95% HPD interval with these samples:
empiricalHpd(theta=test, level=0.95)

## compare with true HPD:
qnorm(p=c(0.025, 0.975))

Run the code above in your browser using DataLab