SimInf_modelThe core class for storing the state, parameters, and results of a stochastic simulation in SimInf. This class holds the model definition (transition graphs, matrices), initial conditions, scheduled events, and the simulation output.
GDependency Graph (sparse matrix, class
dgCMatrix). Indicates which transition rates need to
be updated after a state transition occurs. A non-zero entry
G[i, j] means that transition rate i must be
recalculated if transition j occurs. This optimizes
performance by avoiding unnecessary updates. Dimensions:
\(N_t \times N_t\), where \(N_t\) is the number of
transitions.
SState Transition Matrix (sparse matrix, class
dgCMatrix). Defines the change in the state vector for
each transition. Executing transition j adds the
column S[, j] to the state vector of the affected node.
Dimensions: \(N_c \times N_t\), where \(N_c\) is the
number of compartments.
UDiscrete State Result Matrix (integer matrix).
Contains the number of individuals in each compartment for
every node at each time point in tspan.
U[, j]: State at time tspan[j].
Rows are ordered by node, then by compartment:
Rows 1:Nc: Node 1.
Rows (Nc+1):(2*Nc): Node 2.
... and so on.
Dimensions: \(N_n \times N_c \times \text{length(tspan)}\). Note: If the model was run with sparse output, this slot is empty.
U_sparseSparse Discrete State Result (sparse
matrix, class dgCMatrix). Contains the simulation
results if the model was configured for sparse output. The
layout is identical to U, but stored as a sparse matrix
to save memory. Note: Only one of U or
U_sparse will contain data.
VContinuous State Result Matrix (numeric matrix). Contains the values of continuous state variables (e.g., environmental pathogen load) for every node at each time point. Dimensions: \(N_n \times N_{ld} \times \text{length(tspan)}\), where \(N_{ld}\) is the number of local data variables (continuous states). Note: If sparse output was used, this slot is empty.
V_sparseSparse Continuous State Result (sparse
matrix, class dgCMatrix). Contains the continuous
state results if sparse output was enabled. Layout identical
to V. Note: Only one of V or
V_sparse will contain data.
ldataLocal Data Matrix (numeric matrix).
Parameters specific to each node (e.g., node-specific
transmission rates). Column ldata[, j] contains the
local data vector for node j. Passed to transition
rate functions and post-step functions. Dimensions:
\(N_{ld} \times N_n\).
gdataGlobal Data Vector (numeric vector). Parameters common to all nodes (e.g., global recovery rate). Passed to transition rate functions and post-step functions.
tspanTime Span (numeric vector). Increasing time points where the state of each node is recorded.
u0Initial State Matrix (integer matrix). Initial number of individuals in each compartment for every node. Dimensions: \(N_c \times N_n\).
v0Initial Continuous State Matrix (numeric matrix). Initial values for continuous state variables for every node. Dimensions: \(N_{ld} \times N_n\).
eventsScheduled Events
(SimInf_events). Object containing the
schedule of discrete events (e.g., movements, births).
replicatesNumber of Replicates (integer). Number of parallel replicates simulated for this model (used in filtering algorithms).
C_codeC Source Code (character vector). Optional
C code defining the model's transition rates. If non-empty,
this code is written to a temporary file, compiled, and loaded
when run() is called. Typically generated by
mparse.
SimInf_model (constructor) for creating
model objects. SIR, SEIR,
SIS, SISe for compartment model
constructors that automatically set up the required slots.
mparse for creating custom models using a simple
string syntax. run for executing the
simulation. trajectory,
prevalence, and
plot for extracting
and visualizing results. SimInf_events
for details on the event schedule structure.