mk_model {IBMPopSim}R Documentation

Creates a model for IBMPopSim.

Description

This function creates an Individual Based Model describing the population, events which can occur in the population, and the model parameters.

Usage

mk_model(
  characteristics = NULL,
  events,
  parameters = NULL,
  with_compilation = TRUE
)

Arguments

characteristics

List containing names and types of characteristics of individuals in the population. See get_characteristics.

events

List of events in the model. See mk_event_poisson, mk_event_inhomogeneous_poisson, mk_event_individual, and mk_event_interaction.

parameters

Model parameters. A list of parameters of the model.

with_compilation

(Optional) Logical parameter, TRUE by default. If FALSE the sourceCpp function is not called.

Details

It builds the C++ model code and produces the function popsim_cpp which will be used for simulating the model. The function used to simulate a population from a model is popsim.

Value

model List containing the built model :

See Also

popsim, mk_event_poisson, mk_event_individual, mk_event_interaction.

Examples


params <- list("p_male"= 0.51,
              "birth_rate" = stepfun(c(15,40),c(0,0.05,0)),
              "death_rate" = gompertz(0.008,0.02))

death_event <- mk_event_individual(type = "death",
                                  intensity_code = "result = death_rate(age(I,t));")

birth_event <- mk_event_individual(type = 'birth',
                                  intensity_code = "if (I.male) result = 0;
                                    else result=birth_rate(age(I,t));",
                                  kernel_code = "newI.male = CUnif(0, 1) < p_male;")

model <- mk_model(characteristics = get_characteristics(population(EW_pop_14$sample)),
                 events = list(death_event,birth_event),
                 parameters = params)

summary(model)



[Package IBMPopSim version 1.0.0 Index]