Learn R Programming

coala (version 0.7.2)

create_abc_sumstat: 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)

Value

A data.frame that can be used as sumstat

argument of abc.

Arguments

sim_results

The simulation results as returned from simulate.

model

The model used for the simulations.

See Also

For generating abc's parameter format: create_abc_param

Examples

Run this code
# 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)

Run the code above in your browser using DataLab