SIR | R Documentation |
Create an SIR model to be used by the simulation framework.
SIR(u0, tspan, events = NULL, beta = NULL, gamma = NULL)
u0 |
A |
tspan |
A vector (length >= 1) of increasing time points
where the state of each node is to be returned. Can be either
an |
events |
a |
beta |
A numeric vector with the transmission rate from
susceptible to infected where each node can have a different
beta value. The vector must have length 1 or |
gamma |
A numeric vector with the recovery rate from infected
to recovered where each node can have a different gamma
value. The vector must have length 1 or |
The SIR model contains three compartments; number of susceptible (S), number of infectious (I), and number of recovered (R). Moreover, it has two state transitions,
S \stackrel{\beta S I / N}{\longrightarrow} I
I \stackrel{\gamma I}{\longrightarrow} R
where \beta
is the transmission rate, \gamma
is the
recovery rate, and N=S+I+R
.
The argument u0
must be a data.frame
with one row for
each node with the following columns:
The number of sucsceptible in each node
The number of infected in each node
The number of recovered in each node
A SimInf_model
of class SIR
## Create an SIR model object.
model <- SIR(u0 = data.frame(S = 99, I = 1, R = 0),
tspan = 1:100,
beta = 0.16,
gamma = 0.077)
## Run the SIR model and plot the result.
set.seed(22)
result <- run(model)
plot(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.