postPriorOverlap: Overlap between posterior and prior probability...

Description Usage Arguments Value Author(s) Examples

View source: R/postPriorOverlap.R

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

1
2
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 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.

Value

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

Author(s)

Mike Meredith

Examples

1
2
3
4
5
6
7
8
# 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))

mcmcOutput documentation built on July 2, 2020, 2:26 a.m.