This is a core function for ABC inference using demografr. It generates simulation replicates and computes summary statistic for the next step of an inference procedure, which is the ABC estimation itself.
simulate_abc(
model,
priors,
functions,
observed,
iterations,
sequence_length,
recombination_rate,
mutation_rate = 0,
data = NULL,
format = c("ts", "files"),
file = NULL,
packages = NULL,
attempts = 1000,
engine = NULL,
model_args = NULL,
engine_args = NULL
)
Either a slendr model generating function (in which case engine
must
be either "msprime" or "slim", i.e. one of the two of slendr's simulation back ends),
or a path to a custom user-defined SLiM or msprime script (in which case engine
must be "custom").
A list of prior distributions to use for sampling of model parameters
A named list of summary statistic functions to apply on simulated tree sequences
A named list of observed summary statistics
How many simulation replicates to run?
Amount of sequence to simulate using slendr (in numbers of basepairs)
Recombination rate to use for the simulation
Mutation rate to use for the simulation
If not NULL
, a path where to save the data frame with simulated grid results
A character vector with package names used by user-defined summary statistic
functions. Only relevant when parallelization is set up using future::plan()
to make
sure that the parallelized tree-sequence summary statistic functions have all of their
packages available.
Maximum number of attempts to generate prior values for a valid demographic model (default is 1000)
Which simulation engine to use? Values "msprime" and "slim" will use one of
the built-in slendr simulation back ends. Which engine will be used is determined
by the nature of the model
. If engine = NULL
, then spatial slendr models will
by default use the "slim" back end, non-spatial models will use the "msprime" back end, and
custom user-defined model scripts will use the "custom" engine. Setting this argument
explicitly will change the back ends (where appropriate). Setting this argument for custom
simulation script has no effect.
Optional (non-prior) arguments for the slendr model generating function. Setting this argument for custom simulation script has no effect.
Optional arguments for the slendr simulation back end. Setting this argument for custom simulation script has no effect.
A list object of the class demografr_abc_sims
containing the results
of ABC simulations, sampled parameters, priors, and tree-sequence summary statistics