Learn R Programming

SimInf (version 11.1.0)

events: Extract the scheduled events from a SimInf_model object

Description

Retrieve the SimInf_events object containing the schedule of discrete events (e.g., births, deaths, movements) associated with a SimInf_model. This object holds the timing, location, and type of each event, as well as the matrices defining how events affect the model state.

Usage

events(object, ...)

# S4 method for SimInf_model events(object, ...)

Value

A SimInf_events object containing the event schedule and associated matrices (E and

N).

Arguments

object

A SimInf_model object.

...

Additional arguments (currently ignored).

See Also

SimInf_events for details on the structure of the returned event object (slots E (select matrix), N (shift matrix), event, etc.). events_SIR, events_SEIR, events_SISe3 for examples of pre-defined event datasets. mparse for defining custom models with event schedules. run for executing the simulation with the scheduled events. Vignette "Scheduled events" for a comprehensive tutorial on defining event data, using the select (E) and shift (N) matrices, and simulating complex demographic and movement processes.

Examples

Run this code
## Create an SIR model with scheduled events.
model <- SIR(
  u0     = u0_SIR(),
  tspan  = 1:(4 * 365),
  events = events_SIR(),
  beta   = 0.16,
  gamma  = 0.077
)

## Extract the events and display a summary.
ev <- events(model)
summary(ev)

## Plot the event schedule over time.
plot(ev)

Run the code above in your browser using DataLab