Skip to contents

Unnest the predicted values of a given statistic from the simulated data

Usage

extract_prediction(data, stat)

Arguments

data

Data with posterior simulations performed via predict.demografr_abc_sims

stat

Which tree-sequence summary statistic to extract? If NULL, all summary statistics will be returned.

Value

Data frame object containing columns with values of parameters sampled from the posterior, then a column "summary" containing a name of a summary statistic computed for each combination of parameters, column "stat" containing the exact summary statistic computed (useful in case multiple values of the summary statistic computed by a tree-sequence function), and a column "value" containing its value.

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")
} # }