Create an SEIR model to be used by the simulation framework.
SEIR(u0, tspan, events = NULL, beta = NULL, epsilon = NULL, gamma = NULL)A SimInf_model of class SEIR
A data.frame with the initial state in each node,
i.e., the number of individuals in each compartment in each
node when the simulation starts (see ‘Details’). The
parameter u0 can also be an object that can be coerced
to a data.frame, e.g., a named numeric vector will be
coerced to a one row data.frame.
A vector (length >= 1) of increasing time points
where the state of each node is to be returned. Can be either
an integer or a Date vector.
If integer: Represents the specific time points
(e.g., days, hours) at which to record the state.
If Date: Coerced to a numeric vector
representing the day of the year (1–366) relative
to the first date in the vector. The original Date
objects are preserved as names for the numeric vector,
facilitating time-series plotting.
a data.frame with the scheduled events, see
SimInf_model.
A numeric vector with the transmission rate from
susceptible to infected. Each node can have a different beta
value. The vector must have length 1 or nrow(u0). If
the vector has length 1 but the model contains more nodes, the
beta value is repeated for all nodes.
A numeric vector with the incubation rate from
exposed to infected. Each node can have a different value. The
vector must have length 1 or nrow(u0). If the vector
has length 1 but the model contains more nodes, the value is
repeated for all nodes.
A numeric vector with the recovery rate from infected
to recovered. Each node can have a different gamma value. The
vector must have length 1 or nrow(u0). If the vector
has length 1 but the model contains more nodes, the gamma
value is repeated for all nodes.
The SEIR model extends the standard SIR model by adding an Exposed (E) compartment for individuals who have been infected but are not yet infectious. This accounts for the latent period of the disease.
The model is defined by three state transitions: $$S \stackrel{\beta S I / N}{\longrightarrow} E$$ $$E \stackrel{\epsilon E}{\longrightarrow} I$$ $$I \stackrel{\gamma I}{\longrightarrow} R$$
where \(\beta\) is the transmission rate, \(\epsilon\) is the incubation rate (inverse of the latent period), \(\gamma\) is the recovery rate, and \(N = S + E + I + R\) is the total population size in each node. Here, \(S\), \(E\), \(I\), and \(R\) represent the number of susceptible, exposed, infected, and recovered individuals in that specific node.
The argument u0 must be a data.frame with one row for
each node with the following columns:
The number of susceptible individuals in each node
The number of exposed individuals in each node
The number of infected individuals in each node
The number of recovered individuals in each node
SEIR for the class definition.
SIR, SIS, SISe,
SISe3 and SISe_sp for other
predefined models. mparse for creating custom
models. run for running the simulation.
trajectory, prevalence and
plot for
post-processing and visualization.
## Create an SEIR model object.
model <- SEIR(
u0 = data.frame(S = 99, E = 0, I = 1, R = 0),
tspan = 1:100,
beta = 0.16,
epsilon = 0.25,
gamma = 0.077
)
## Run the SEIR model with a fixed seed for reproducibility.
result <- run(model, seed = 22)
## Plot the distribution of susceptible, exposed, infected and
## recovered individuals.
plot(result)
Run the code above in your browser using DataLab