View source: R/simulationSIRS.R
simulationSIRS | R Documentation |
A function to run the simulation of disease spread in a network using the SIRS (Susceptible-Infected-Recovered-Susceptible) model.
simulationSIRS(A, pspread, tSim, I, tImin, tImax, R, tRmin, tRmax, Control)
A |
An adjacency |
pspread |
Probability of disease spread from an infected to a susceptible node |
tSim |
Simulation time |
I |
Vector of infected nodes (initial condition) |
tImin |
Minimum time a node remains infected |
tImax |
Maximum time a node remains infected |
R |
Vector of recovered nodes (initial condition) |
tRmin |
Minimum time a node remains immune |
tRmax |
Maximum time a node remains immune |
Control |
Vector of nodes under a control strategy |
This function runs the simulation of disease spread in a network
using the SIRS model. For each time step, the vectors of infected, susceptible
and recovered nodes are updated, considering that
there is a probability pspread
of disease spread.
Infected nodes remain infected during a time randomly sampled
between tImin
and tImax
. Recovered nodes remain immune
during a time randomly sampled between tRmin
and tRmax
. Nodes under a control strategy (Control
)
are not susceptible to infection.
A list of
M_Sim_I |
a matrix of infected nodes for each time step. |
M_Sim_R |
a matrix of recovered nodes for each time step. |
[1] Ossada R, Grisi-Filho JHH, Ferreira F, Amaku M (2013). "Modeling the Dynamics of Infectious Diseases in Different Scale-Free Networks with the Same Degree Distribution." Advanced Studies in Theoretical Physics, 7, 759-771. doi: 10.12988/astp.2013.3674
[2] Ossada R (2015). "Modelagem de Medidas de Controle em Redes de Movimentacao de Animais." PhD Thesis. Sao Paulo, School of Veterinary Medicine, University of Sao Paulo. doi: 10.11606/T.10.2015.tde-06112015-111048
# Generate an arbitrary 200 by 200 adjacency matrix with zeros and ones # Remove loops A <- matrix(rbinom(200 * 200, 1, 0.1), ncol = 200, nrow = 200) diag(A) <- 0 # Setting the parameters pspread <- 0.1 tImin <- 5 tImax <- 8 tRmin <- 1 tRmax <- 10 tSim <- 100 # Setting the initial conditions for infected, recovered and controlled nodes num_infected <- 2 # initial number of infected nodes I <- rep(x = 0, times = nrow(A)) I[1:num_infected] <- 1 I <- sample(I) R <- rep(x = 0, times = nrow(A)) Control <- rep(x = 0, times = nrow(A)) # Run the simulation sim <- simulationSIRS(A = A, pspread = pspread, tSim = tSim, I = I, tImin = tImin, tImax = tImax, R = R, tRmin = tRmin, tRmax = tRmax, Control = Control) # Plot the prevalence over time plot(colMeans(sim[[1]]>0), xlab = "Time", ylab = "Prevalence")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.