HPDinterval: Highest Posterior Density intervals

Description Usage Arguments Details Value Author(s) Examples

View source: R/HPDinterval.R

Description

Create Highest Posterior Density (HPD) intervals for the parameters in an MCMC sample.

Usage

1
2
3
4
5
HPDinterval(obj, prob = 0.95, ...)
## S3 method for class 'mcmc'
HPDinterval(obj, prob = 0.95, ...)
## S3 method for class 'mcmc.list'
HPDinterval(obj, prob = 0.95, ...)

Arguments

obj

The object containing the MCMC sample - usually of class "mcmc" or "mcmc.list"

.

prob

A numeric scalar in the interval (0,1) giving the target probability content of the intervals. The nominal probability content of the intervals is the multiple of 1/nrow(obj) nearest to prob.

...

Optional additional arguments for methods. None are used at present.

Details

For each parameter the interval is constructed from the empirical cdf of the sample as the shortest interval for which the difference in the ecdf values of the endpoints is the nominal probability. Assuming that the distribution is not severely multimodal, this is the HPD interval.

Value

For an "mcmc" object, a matrix with columns "lower" and "upper" and rows corresponding to the parameters. The attribute "Probability" is the nominal probability content of the intervals. A list of such matrices is returned for an "mcmc.list" object.

Author(s)

Douglas Bates

Examples

1
2

Example output

$line1
         lower   upper
alpha 2.125550 3.87634
beta  0.306433 1.51562
sigma 0.326157 1.81988
attr(,"Probability")
[1] 0.95

$line2
         lower   upper
alpha 2.036040 3.97947
beta  0.150777 1.51109
sigma 0.353713 2.24906
attr(,"Probability")
[1] 0.95

coda documentation built on May 30, 2017, 1:48 a.m.

Related to HPDinterval in coda...