Simulation of a stochastic SIR type model with the following compartments: Susceptibles (S), Infected and Infectious (I), Recovered and Immune (R)

simulate_sirdemographic_stochastic(
  S = 1000,
  I = 10,
  R = 0,
  b = 0.001,
  g = 0.5,
  m = 0,
  n = 0,
  tmax = 100,
  rngseed = 100
)

Arguments

S

: initial number of susceptible hosts : numeric

I

: initial number of infected, symptomatic hosts : numeric

R

: initial number of recovered hosts : numeric

b

: level/rate of infectiousness for hosts in the I compartment : numeric

g

: rate at which a person leaves the I compartment : numeric

m

: the rate at which new individuals enter the model (are born) : numeric

n

: the rate of natural death (the inverse is the average lifespan) : numeric

tmax

: maximum simulation time : numeric

rngseed

: 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 SIR model is simulated. 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. The function returns a list, with the time series of the simulated disease as list element ts, with one column per compartment/variable. The first column is time.

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.

See also

See the Shiny app documentation corresponding to this simulator function for more details on this model. See the manual for the adaptivetau package for details on the stochastic algorithm.

Examples

# To run the simulation with default parameters, just call the function: result <- simulate_sirdemographic_stochastic() # To choose parameter values other than the standard one, specify them like this: result <- simulate_sirdemographic_stochastic(S = 2000, tmax = 200, b = 0.01) # You can display or further process the result, like this: 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: 1779"