Get the shift matrix events@N that determines how
individuals are shifted between compartments when processing
enter, internal transfer and external
transfer events. Each row in the shift matrix corresponds to one
compartment in the model, and each column defines a transfer
pattern. The shift value of an event selects which column
to use, and the value \(N[p, q]\) indicates how many
compartments to move (or place, for enter events) individuals from
compartment \(p\). See SimInf_events for
details on the event processing.
Arguments
- model
The
SimInf_modelobject to extract the shift matrix from.
See also
shift_matrix<-
to set the shift matrix, and
select_matrix
to extract the select matrix. The vignette "Scheduled events"
for a tutorial on scheduled events, see
vignette("Scheduled events", package = "SimInf").
Examples
## Create an 'SIR' model.
model <- SIR(
u0 = data.frame(
S = 100,
I = 10,
R = 0),
tspan = 1:5,
beta = 0.16,
gamma = 0.077
)
## Extract the shift matrix from the model.
shift_matrix(model)
#> <0 x 0 matrix>
## Change the shift matrix so that susceptible individuals are
## moved to the 'R' compartment (compartment 1 + 2 = 3) when
## processing an event with 'shift' = 1.
shift_matrix(model) <- data.frame(
compartment = "S",
shift = 1,
value = 2
)
## Extract the updated shift matrix from the model.
shift_matrix(model)
#> 1
#> S 2
#> I 0
#> R 0