| mk_event_interaction | R Documentation |
Creates an event whose intensity depends on an individual and interactions with the population. When the event occurs, something happens to an individual I in the population. The intensity of the event can depend on time, the characteristics of I and other individuals in the population, and can be written as
d(I,t,pop) = \sum_{J \in pop} U(I,J,t),
where U is called the interaction function.
The created event must be used with mk_model.
mk_event_interaction(
type,
name,
interaction_code,
kernel_code = "",
interaction_type = "random"
)
type |
Must be one of |
name |
(Optional) If not specified, the name given to the event is its type. |
interaction_code |
String containing some C++ code describing the interaction function. See details. |
kernel_code |
String containing some C++ code describing the event action. Optional for |
interaction_type |
(Optional) Either |
The type argument is one of the following
'birth'By default, a new individual newI is created, with the same characteristics of the parent I and birth date equal to the current time. Optional code can be precised in kernel_code.
'death'By default, the individual I dies. Optional code can be precised in kernel_code.
'entry'A new individual newI is added to the population, and its characteristics have to be defined by the user in the entry kernel_code.
'exit'An individual I exits from the population. Optional code can be precised in kernel_code.
'swap'The user can change the characteristics of the selected individual I. This requires kernel_code.
'custom'None of the above types, the user defines kernel_code that can act on the selected individual I and on the population pop.
The interaction_code argument is a string containing some C++ code describing the event interaction function $U$ at time t. The interaction 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), J (another individual if interaction_type is 'random'), 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.
An S3 object of class event of type interaction.
mk_model, mk_event_poisson, mk_event_inhomogeneous_poisson, mk_event_individual.
death_interaction_code<- " result = max(J.size -I.size,0);"
event <- mk_event_interaction(type="death",
interaction_code = death_interaction_code)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.