Generate multiple simulations and store them in a list
Source:R/generateSimulations.R
generateSimulations.RdThis function is useful when generating simulations with different parameters or simulating multiple instances to evaluate stochasticity therein.
Arguments
- model
Character: name of the model to use, must be one of "simulateConsumerResource", "simulateGLV", "simulateHubbellRates", and "simulateStochasticLogistic"
- params_list
List: a list containing all parameters used in the aforementionned called model
- param_iter
List of parameters to overwrite in different simulations. If NULL, then simulate different instances using the same set of parameters. (default:
param_iter = NULL)- n_instances
Integer: number of instances to generate (default:
n_instances = 1)- t_end
Numeric: end time of the simulation. If not identical with t_end in params_list, then it will overwrite t_end in each simulation (default:
t_end = 1000)
Examples
params <- list(
n_species = 10,
n_resources = 5,
E = randomE(
n_species = 10, n_resources = 5,
mean_consumption = 1, mean_production = 3
),
x0 = rep(0.001, 10),
resources = rep(1000, 5),
monod_constant = matrix(rbeta(10 * 5, 10, 10), nrow = 10, ncol = 5),
inflow_rate = .5,
outflow_rate = .5,
migration_p = 0,
stochastic = TRUE,
t_start = 0,
t_end = 20,
t_store = 100,
growth_rates = runif(10),
norm = FALSE
)
# Recommended standard way to generate a set of n simulations (n=2 here) from a given model
# simulations <- lapply(seq_len(2), function (i) {do.call(simulateConsumerResource, params)})