A SEIRS model with 4 compartments
simulate_SEIRSd_model_stochastic(
S = 1000,
E = 1,
I = 1,
R = 0,
bE = 0,
bI = 0.001,
gE = 1,
gI = 1,
w = 1,
n = 0,
m = 0,
tfinal = 100,
rngseed = 123
)
: starting value for Susceptible : numeric
: starting value for Exposed : numeric
: starting value for Infected and Symptomatic : numeric
: starting value for Recovered : numeric
: infection by exposed : numeric
: infection by symptomatic : numeric
: progression rate : numeric
: recovery rate : numeric
: waning immunity : numeric
: births : numeric
: deaths : numeric
: Final time of simulation : numeric
: set random number seed for reproducibility : numeric
The function returns the output as a list.
The time-series from the simulation is returned as a dataframe saved as list element ts
.
The ts
dataframe has one column per compartment/variable. The first column is time.
The model includes susceptible, exposed/asymptomatic, infected/symptomatic, and recovered compartments. The processes that are modeled are infection, progression to infectiousness, recovery and waning immunity. Demographics through natural births and deaths are also included.
This code was generated by the modelbuilder R package. The model is implemented as a set of stochastic equations using the adaptivetau package. The following R packages need to be loaded for the function to work: adpativetau
This function does not perform any error checking. So if you try to do something nonsensical (e.g. have negative values for parameters), the code will likely abort with an error message.
2020-09-28
2021-07-19
# To run the simulation with default parameters:
result <- simulate_SEIRSd_model_stochastic()
# To choose values other than the standard one, specify them like this:
result <- simulate_SEIRSd_model_stochastic(S = 2000,E = 2,I = 2,R = 0)
# You can display or further process the result, like this:
plot(result$ts[,'time'],result$ts[,'S'],xlab='Time',ylab='Numbers',type='l')
print(paste('Max number of S: ',max(result$ts[,'S'])))
#> [1] "Max number of S: 2004"