Description Usage Arguments Details See Also Examples
Compute the highest density posterior region from a (possibly multi-modal) sample of points.
1 | hpd_mult(x, dens, prob = 0.95, tol, interactive = FALSE)
|
x |
vector of samples from some distribution |
dens |
a density object based on x, defaults to density(x) |
prob |
numeric in (0, 1) the probability that the interval should be |
tol |
numeric, smaller means longer compute time, but more accurate results |
interactive |
logical, defaults to FALSE. If TRUE, a fun plot is shown and the function's process of choosing the region is displayed. The user hits enter to proceed through. |
Since hpd_mult relies on a density object, it is possible to be returned a result that is outside the bounds of the data (i.e., an hpd for a beta random variable that has a left end point below 0).
A random horizontal line is repeatedly generated and the points along the line that cross dens$y are calculated. These points make up a proposed hpd region whose area is computed. Given this area, a new horizontal line is generated until the area is close to prob (within tol).
get.hpd
1 2 3 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.