plotPriorPost | R Documentation |
Assorted functions for visualizing and summarizing the prior and posterior probability distributions associated with ABC analyses.
plotPrior(
priorFn = match.arg(arg = priorFn, choices = c("fixed", "uniform", "normal",
"lognormal", "gamma", "exponential"), several.ok = FALSE),
priorVariables,
plotQuants = TRUE,
plotLegend = TRUE
)
plotUnivariatePosteriorVsPrior(
posteriorCurve,
priorCurve,
label = "parameter",
trueValue = NULL,
...
)
getUnivariatePriorCurve(
priorFn,
priorVariables,
nPoints = 1e+05,
from = NULL,
to = NULL,
alpha = 0.8,
coda = FALSE,
verboseMultimodal = TRUE,
...
)
getUnivariatePosteriorCurve(
acceptedValues,
from = NULL,
to = NULL,
alpha = 0.8,
coda = FALSE,
verboseMultimodal = TRUE,
...
)
priorFn |
Prior Shape of the distribution; one of either "fixed", "uniform", "normal", "lognormal", "gamma", or "exponential". |
priorVariables |
Variables needed to describe the shape of the
distribution, dependent on
|
plotQuants |
If |
plotLegend |
If |
posteriorCurve |
Kernal density estimates for the
posterior distribution from |
priorCurve |
Kernal density estimates for the
prior distribution from |
label |
Horizontal X-axis label for the plot. |
trueValue |
True parameter value, if any such exists and is known (usually only true of simulations). |
... |
For |
nPoints |
Number of points to draw. |
from |
Lower bound, if any. By default this is |
to |
Upper bound, if any. By default this is |
alpha |
The threshold used for defining the highest density frequency cut-off. If the highest density interval is applied to a Bayesian MCMC posterior sample, then the interval is effectively calculated for this value as a posterior probability density. |
coda |
Default is |
verboseMultimodal |
If |
acceptedValues |
Vector of accepted particle values. |
Function plotPrior
visualizes the shape of various
prior probability distributions available in TreEvo ABC analyses,
while getUnivariatePriorCurve
returns density coordinates and
summary statistics from user-selected prior probability distribution.
Similarly, function getUnivariatePosteriorCurve
returns
density coordinates and summary statistics from the posterior distribution
of an ABC analysis.
Both getUnivariatePriorCurve
and
getUnivariatePosteriorCurve
also calculate the highest
density intervals for their respective parameters,
using the function highestDensityInterval
.
Function plotUnivariatePosteriorVsPrior
plots the
univariate density distributions from the prior and
posterior against each other for comparison, along with the
highest density intervals (HDI) for both.
The summaries calculated from getUnivariatePriorCurve
and getUnivariatePosteriorCurve
are used as the input
for plotUnivariatePosteriorVsPrior
, hence the relationship of
these functions to each other, and why they are listed together here.
plotPrior
and plotUnivariatePosteriorVsPrior
produce plots of the respective distributions (see above).
getUnivariatePriorCurve
returns a list of x and y density
coordinates, mean, and the highest density intervals (HDI) for
their respective distribution.
getUnivariatePosteriorCurve
does the same for a
posterior sample of parameter estimates, returning a
list of x and y density coordinates, mean, and the
highest posterior density intervals (HPD).
Brian O'Meara and Barb Banbury
Highest posterior densities are calculated via
highestDensityInterval
.
plotPosteriors
Plots multiple posteriors
against their priors and potential known values.
data(simRunExample)
# examples with plotPrior
plotPrior(
priorFn = "exponential",
priorVariables = c(10))
plotPrior(
priorFn = "normal",
priorVariables = c(1, 2))
plotPrior(
priorFn = "gamma",
priorVariables = c(2, .2),
plotQuants = FALSE,
plotLegend = FALSE)
# examples of getting density coordinates and
# summary statistics from distributions
priorKernal <- getUnivariatePriorCurve(
priorFn = "normal",
priorVariables = c(28, 2),
nPoints = 100000,
from = NULL,
to = NULL,
alpha = 0.95)
postKernal <- getUnivariatePosteriorCurve(
acceptedValues =
resultsBMExample[[1]]$particleDataFrame$starting_1,
from = NULL,
to = NULL,
alpha = 0.95)
priorKernal
postKernal
# let's compare this (supposed) prior
# against the posterior in a plot
plotUnivariatePosteriorVsPrior(
posteriorCurve = postKernal,
priorCurve = priorKernal,
label = "parameter",
trueValue = NULL)
# cool!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.