Simulation of a stochastic SEIR type model with the following compartments: Susceptibles (S), Infected and pre-symptomatic/exposed (E), Infected and Symptomatic (I), Recovered and Immune (R)

simulate_seir_stochastic(
S = 1000,
I = 10,
bE = 0,
bI = 0.001,
gE = 0.5,
gI = 0.5,
w = 0,
m = 0,
n = 0,
tmax = 100,
rngseed = 100
)

## Arguments

S : initial number of susceptible hosts : numeric : initial number of infected, symptomatic hosts : numeric : level/rate of infectiousness for hosts in the E compartment : numeric : level/rate of infectiousness for hosts in the I compartment : numeric : rate at which a person leaves the E compartment : numeric : rate at which a person leaves the I compartment : numeric : rate at which recovered lose immunity and return to susceptible : numeric : the rate at which new individuals enter the model (are born) : numeric : the rate of natural death (the inverse is the average lifespan) : numeric : maximum simulation time : numeric : seed for random number generator to allow reproducibility : numeric

## Value

The function returns a list. The list has one element, a data frame ts which contains the time series of the simulated model, with one column per compartment/variable. The first column is time.

## Details

A compartmental ID model with several states/compartments is simulated. Initial conditions for the E and R variables are 0. Units of time depend on the time units chosen for model parameters. The simulation runs as a stochastic model using the adaptive-tau algorithm as implemented by ssa.adaptivetau() in the adpativetau package. See the manual of this package for more details.

## Warning

This function does not perform any error checking. So if you try to do something nonsensical (e.g. specify negative parameter values or fractions > 1), the code will likely abort with an error message.

# To run the simulation with default parameters, just call the function:
plot(result$ts[,'time'],result$ts[,'S'],xlab='Time',ylab='Number Susceptible',type='l')print(paste('Max number of infected: ',max(result\$ts[,'I'])))#> [1] "Max number of infected:  739"