create_abc_sumstat: Convert Simulation Results to abc's Summary Statistic Format

View source: R/interface_abc.R

create_abc_sumstatR Documentation

Convert Simulation Results to abc's Summary Statistic Format

Description

This function creates an object compatible with the sumstat argument of the abc function from coala's simulation results. It converts all summary statistics that are in the simulation results and expects that each of them is a numeric vector. Use transformation functions to convert none vector-valued statistics (e.g. sumstat_jsfs, sumstat_omega or sumstat_trees) into a vector.

Usage

create_abc_sumstat(sim_results, model)

Arguments

sim_results

The simulation results as returned from simulate.

model

The model used for the simulations.

Value

A data.frame that can be used as sumstat argument of abc.

See Also

For generating abc's parameter format: create_abc_param

Examples

# Using the SFS:
model <- coal_model(10, 1) +
  feat_mutation(par_prior("theta", rnorm(1, 5, .5))) +
  sumstat_sfs()
sim_results <- simulate(model, nsim = 2)
abc_sumstat <- create_abc_sumstat(sim_results, model)
print(abc_sumstat)

# Using the JSFS and converting it into a vector:
model <- coal_model(c(10, 10), 1) +
  feat_mutation(par_prior("theta", rnorm(1, 5, .5))) +
  feat_migration(par_prior("m", rnorm(1, .5, .1)), symmetri = TRUE) +
  sumstat_jsfs(transformation = function(jsfs) {
    c(sum(jsfs[1, ]), sum(jsfs[, 1]), sum(jsfs[-1, -1]))
  })
sim_results <- simulate(model, nsim = 2)
abc_sumstat <- create_abc_sumstat(sim_results, model)
print(abc_sumstat)

coala documentation built on Jan. 5, 2023, 5:11 p.m.