IBMPopSim (version 0.3.0)

popsim: Simulation of a model.

Description

This function simulates the random evolution of an IBM.

Usage

popsim(
  model,
  population,
  events_bounds,
  parameters = NULL,
  age_max = Inf,
  time,
  multithreading = FALSE,
  num_threads = NULL,
  clean_step = NULL,
  clean_ratio = 0.1,
  seed = NULL
)

Arguments

model

Model resulting from a call to the function mk_model.

population

Data frame representing the initial population.

events_bounds

Named vector of events bounds, with names corresponding to events names.

parameters

List of model parameters.

age_max

Maximum age of individuals in the population (Inf by default).

time

Final time (Numeric). If time is a vector or vector of simulation discretized times.

multithreading

Logical for multithread activation, FALSE by default. Should be only activated for IBM simulation with no interactions.

num_threads

(Optional) Number of threads used for multithreading. Set by default to the number of concurrent threads supported by the available hardware implementation.

clean_step

(Optional) Optional parameter for improving simulation time. Time step for removing dead (or exited) individuals from the population. By default, equal to age_max.

clean_ratio

(Optional) Optional parameter for improving simulation time. 0.1 by default.

seed

(Optional) Random generator seed, random by default.

Value

popsim returns a list of composed of

arguments

Simulation inputs (initial population, parameters value, multithreading...)

logs

Simulation logs (algorithm duration, accepted/rejected events...).

population

If time is of length 1, population is a data frame composed of all individuals who lived in the population of [0,time]. If time is a vector, population is a list of population data frames.

See Also

mk_model.

Examples

Run this code
# NOT RUN {
init_size <- 100000
pop <- data.frame(birth = rep(0, init_size), death = NA)

birth = mk_event_poisson(type = 'birth', intensity = 'lambda')
death = mk_event_poisson(type = 'death', intensity = 'mu')
params = list('lambda' = 100, 'mu' = 100)
birth_death <- mk_model(events = list(birth, death),
                       parameters = params)
                       
sim_out <- popsim(model = birth_death, 
                 population = pop, 
                 events_bounds = c('birth' = params$lambda, 'death' = params$mu),
                 parameters = params, 
                 time = 10)
                       
# }

Run the code above in your browser using DataCamp Workspace