Learn R Programming

mcmcOutput (version 0.1.3)

postPriorOverlap: 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"), ...)

Value

Returns the overlap, the area lying under the lower of the two density curves.

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 d- prefix, eg. dbeta.

priorPars

a named list of parameters to be passed to prior when it is a function ; see the examples. Ignored if prior is a numeric vector.

breaks

controls the histogram break points or the number of bars; see hist.

hcols

a vector of four colours for the histograms: posterior, prior, overlap, and borders. See the Color Specification section of par

...

other graphical parameters.

Author

Mike Meredith

Examples

Run this code
# 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))

Run the code above in your browser using DataLab