mk_event_individual {IBMPopSim} | R Documentation |
Creating an event with intensity of class individual
Description
Creates an event with intensity of class individual (without interactions). When the event occurs, something happens to an individual I
in the population.
The created event must be used with mk_model
.
Usage
mk_event_individual(type, name, intensity_code, kernel_code = "")
Arguments
type |
Must be one of |
name |
(Optional) If not specified, the name given to the event is its type. |
intensity_code |
String containing some C++ code describing the intensity function. See details. |
kernel_code |
String containing some C++ code describing the event action. Optional for |
Details
The type
argument is one of the following
'birth'
By default, a new individual
newI
is created, with the same characteristics of the parentI
and birth date equal to the current time. Optional code can be precised inkernel_code
.'death'
By default, the individual
I
dies. Optional code can be precised inkernel_code
.'entry'
A new individual
newI
is added to the population, and its characteristics have to be defined by the user in the entrykernel_code
.'exit'
An individual
I
exits from the population. Optional code can be precised inkernel_code
.'swap'
The user can change the characteristics of the selected individual
I
. This requireskernel_code
.'custom'
None of the above types, the user defines
kernel_code
that can act on the selected individualI
and on the populationpop
.
The intensity_code
argument is a string containing some C++ code describing the event intensity for individual I
at time t
. The intensity value must be stored in the variable result
.
Some of available variables in the C++ code are: t
(the current time), I
(the current individual selected for the event), the name of the model parameters (some variables, or functions, see mk_model
).
See vignette('IBMPopSim_Cpp')
for more details.
The kernel_code
argument is a string containing some C++ code which describing the action of the event. Some of available variables in the C++ code are: t
(the current time), pop
(the current population), I
(the current individual selected for the event), newI
(the new individual if 'birth'
or 'entry'
event), the name of the model parameters (some variables, or functions, see mk_model
).
See vignette('IBMPopSim')
for more details.
Value
An S3 object of class event
of type individual.
See Also
mk_model
, mk_event_poisson
, mk_event_inhomogeneous_poisson
, and 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",
name = "my_death_event",
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;")