A basic SIR model with 3 compartments and infection and recovery processes
Usage
simulate_reproductivenumber1_ode(S = 1000, I = 1, R = 0, b = 0.002,
g = 1, tstart = 0, tfinal = 100, dt = 0.1)
Arguments
S
: starting value for Susceptible : numeric
I
: starting value for Infected : numeric
R
: starting value for Recovered : numeric
b
: infection rate : numeric
g
: recovery rate : numeric
tstart
: Start time of simulation : numeric
tfinal
: Final time of simulation : numeric
dt
: Time step : numeric
Value
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.
Warning
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.
Details
The model includes susceptible, infected, and recovered compartments.
The two processes that are modeled are infection and recovery.
The simulation also monitors the number of infected and when they drop below 1, they are set to 0.