Calculates and displays the overlap between a posterior distribution (as a vector of samples, typically from an MCMC process) and a prior distribution (as a vector of samples or as a function). Unidentifiable parameters will have high overlap: Gimenez et al (2009) suggest that overlap greater than 35% indicates weak identifiability.
postPriorOverlap(paramSampleVec, prior, ..., yaxt="n", ylab="",
xlab="Parameter", main="", cex.lab=1.5, cex=1.4,
xlim=range(paramSampleVec), breaks=NULL,
mainColor="skyblue", priorColor="yellow", overlapColor="green")
a vector of samples drawn from the target distribution.
either a vector of samples 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
. Arguments required by the function must be specified by their (abbreviated) names in the …
argument; see the examples.
named parameters to be passed to prior
when it is a function.
a character which specifies the y axis type; the default, "n", suppresses plotting.
text to use as the label of the y axis.
text to use as the label of the x axis.
the magnification to be used for x and y labels relative to the current setting of cex
a numerical value giving the amount by which plotting text and symbols should be magnified relative to the default
a vector of length 2 giving the limits for the x axis.
text to use as the main title of the plot
controls the histogram break points or the number of bars; see hist
.
an optional color name such as "skyblue"
or a RGB specification such as "#87CEEB"
that controls the color of the histogram representing the posterior.
an optional color name such as "yellow"
or a RGB specification such as "#FFFF00"
that controls the color of prior, both if it is data and when it is a function.
an optional color name such as "green"
or a RGB specification such as "#00FF00"
that controls the color of the overlap area.
Returns the overlap, the area lying under the lower of the two density curves.
Gimenez, Morgan and Brooks (2009) Weak identifiability in models for mark-recapture-recovery data. pp.1055-1068 in Thomson, Cooch and Conroy (eds) Modeling demographic processes in marked populations Springer
# NOT RUN {
# Generate some data
tst <- rbeta(1e6, 5, 7)
# check overlap with a Beta(0.2, 0.2) prior:
postPriorOverlap(tst, dbeta, shape1=0.2, shape2=0.2)
# check overlap with a Uniform(0, 1) prior:
postPriorOverlap(tst, runif(1e6))
# }
Run the code above in your browser using DataLab