postPriorOverlap {mcmcOutput} | R Documentation |
Overlap between posterior and prior probability distributions.
Description
Calculates and displays the overlap between a posterior distribution (as a vector of values, typically draws from an MCMC process) and a prior distribution (as a vector of values or as a function).
Usage
postPriorOverlap(x, prior, priorPars, breaks=NULL,
hcols=c("skyblue", "yellow", "green", "white"), ...)
Arguments
x |
a vector of values drawn from the target distribution. |
prior |
either a vector of values drawn from the prior distribution or the name for the density function of the distribution; standard R functions for this have a |
priorPars |
a named list of parameters to be passed to |
breaks |
controls the histogram break points or the number of bars; see |
hcols |
a vector of four colours for the histograms: posterior, prior, overlap, and borders. See the Color Specification section of |
... |
other graphical parameters. |
Value
Returns the overlap, the area lying under the lower of the two density curves.
Author(s)
Mike Meredith
Examples
# Generate some data
foo <- rbeta(1e4, 5, 7)
# check overlap with a Beta(0.2, 0.2) prior:
postPriorOverlap(foo, dbeta, list(shape1=0.2, shape2=0.2))
# check overlap with a Uniform(0, 1) prior:
postPriorOverlap(foo, runif(1e6))