View source: R/postPriorOverlap.R
postPriorOverlap | R Documentation |
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).
postPriorOverlap(x, prior, priorPars, breaks=NULL, hcols=c("skyblue", "yellow", "green", "white"), ...)
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. |
Returns the overlap, the area lying under the lower of the two density curves.
Mike Meredith
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.