Bivariate Posterior Contour
Computes coordinates of a highest density contour containing a given probability volume given a sample from a continuous bivariate distribution, and optionally plots. The default method assumes an elliptical shape, but one can optionally use a kernel density estimator.
Code adapted from embbook::HPDregionplot
. See http://www.sumsar.net/blog/2014/11/how-to-summarize-a-2d-posterior-using-a-highest-density-ellipse/.
pdensityContour( x, y, method = c("ellipse", "kernel"), prob = 0.95, otherprob = c(0.01, 0.1, 0.25, 0.5, 0.75, 0.9), h = c(1.3 * MASS::bandwidth.nrd(x), 1.3 * MASS::bandwidth.nrd(y)), n = 70, pl = FALSE )
x |
a numeric vector |
y |
a numeric vector the same length of x |
method |
defaults to |
prob |
main probability coverage (the only one for |
otherprob |
vector of other probability coverages for |
h |
vector of bandwidths for x and y. See |
n |
number of grid points in each direction, defaulting to normal reference bandwidth (see |
pl |
set to |
a 2-column matrix with x and y coordinates unless pl=TRUE
in which case a ggplot2
graphic is returned
Ben Bolker and Frank Harrell
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.