This R package includes several popular epidemiological models, including SIS (wiki), SIR (wiki), and SEIR (wiki) using either a fully connected graph (similar to a compartmental model) or a user-defined network. Here are some examples:
SIR Model Using a Random Graph
This Susceptible-Infected-Recovered model features a population of 100,000 agents simulated in a small-world network. Each agent is connected to ten other agents. One percent of the population has the virus, with a 70% chance of transmission. Infected individuals recover at a 0.3 rate:
Code
library(epiworldR)## Creating a SIR modelsir <-ModelSIR(name ="COVID-19",prevalence = .01,transmission_rate = .7,recovery_rate = .3 ) |># Adding a Small world population agents_smallworld(n =100000, k =10, d =FALSE, p = .01) |># Running the model for 50 daysrun(ndays =50, seed =1912)
_________________________________________________________________________
|Running the model...
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done.
| done.
Code
sir
________________________________________________________________________________
Susceptible-Infected-Recovered (SIR)
It features 100000 agents, 1 virus(es), and 0 tool(s).
The model has 3 states.
The final distribution is: 822 Susceptible, 415 Infected, and 98763 Recovered.
_________________________________________________________________________
Running the model...
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done.
done.
Code
model_seirconn
________________________________________________________________________________
Susceptible-Exposed-Infected-Removed (SEIR) (connected)
It features 10000 agents, 1 virus(es), and 0 tool(s).
The model has 4 states.
The final distribution is: 91 Susceptible, 0 Exposed, 0 Infected, and 9909 Recovered.
Computing some key statistics: plotting and reproductive number (wiki)
Code
plot(model_seirconn)
Code
repnum <-get_reproductive_number(model_seirconn)plot(repnum, type ="b")
_________________________________________________________________________
|Running the model...
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done.
| done.
Code
plot(model_logit)
Code
## Females are supposed to be more likely to become infectedrn <-get_reproductive_number(model_logit)(table( X[, "Female"], (1:n %in% rn$source)) |>prop.table())[,2]
sir <-ModelSIR(name ="COVID-19",prevalence = .01,transmission_rate = .5,recovery_rate = .5 ) |># Adding a Small world population agents_smallworld(n =500, k =10, d =FALSE, p = .01) |># Running the model for 50 daysrun(ndays =50, seed =1912)
_________________________________________________________________________
|Running the model...
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done.
| done.