mk_model

0th

Percentile

Creates a model for IBMPopSim.

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_id = FALSE,
  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_id

(Optional) Logical argument, FALSE by default. If TRUE, each individuals is given a unique id, which allows the identification of individual life histories in the presence of swap events.

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 :

  • individual_type: Names and types (R and C++) of characteristics.

  • parameters_types: Names and types (R and C++) of model parameters.

  • events: List of events.

  • cpp_code: Output of C++ compilation.

See Also

popsim, mk_event_poisson, mk_event_individual, mk_event_interaction.

Aliases
  • mk_model
Examples
# NOT RUN {
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_df),
                 events = list(death_event,birth_event),
                 parameters = params)

summary(model)
# }
# NOT RUN {
# }
Documentation reproduced from package IBMPopSim, version 0.3.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.