
Plot the results of a posterior predictive check for a given summary statistic
Source:R/plot_prediction.R
plot_prediction.Rd
Plot the results of a posterior predictive check for a given summary statistic
Arguments
- data
Data frame with predictions generated from ABC posteriors, as generated by the
predict
function- stat
Which tree-sequence summary statistic to extract? If
NULL
, all summary statistics will be visualized.- file
Output path to a PDF figure to be saved
- facets
Should each summary statistic be plotted on its own facet (default is
TRUE
)?- ...
Optional argument which will be passed to
ggsave
Value
If file = NULL
, a ggplot2 object (or a list of such objects, if
multiple summary statistics are visualized), otherwise nothing is returned and the
plots are instead saved to a file.
Examples
if (FALSE) { # \dontrun{
# read statistics computed from posterior sample simulations
pred <- readRDS(url(paste0(
"https://raw.githubusercontent.com/bodkan/demografr/",
"refs/heads/main/inst/examples/downstream_predX.rds"
)))
# note the columns `diversity`, `divergence`, and `f4`
pred
# extract_prediction() is a convenience function which unpacks the given
# summary statistic in a normal data frame column (here `diversity`)
extract_prediction(pred, "diversity")
# we can also plot the posterior predictive distributions for all statistics
plot_prediction(pred, "diversity")
} # }