R/simulate_Characteristics_of_ID_ode.R
simulate_Characteristics_of_ID_ode.Rd
A compartmental model with several different compartments: Susceptibles (S), Infected and Pre-symptomatic (P), Infected and Asymptomatic (A), Infected and Symptomatic (I), Recovered and Immune (R) and Dead (D)
simulate_Characteristics_of_ID_ode(
S = 1000,
P = 1,
A = 0,
I = 0,
R = 0,
D = 0,
bP = 0,
bA = 0,
bI = 0.001,
gP = 0.1,
gA = 0.1,
gI = 0.1,
f = 0,
d = 0,
tstart = 0,
tfinal = 200,
dt = 0.1
)
: starting value for Susceptible : numeric
: starting value for Presymptomatic : numeric
: starting value for Asymptomatic : numeric
: starting value for Symptomatic : numeric
: starting value for Recovered : numeric
: starting value for Dead : numeric
: rate of transmission from P to S : numeric
: rate of transmission from A to S : numeric
: rate of transmission from I to S : numeric
: rate at which a person leaves the P compartment : numeric
: rate at which a person leaves the A compartment : numeric
: rate at which a person leaves the I compartment : numeric
: fraction of asymptomatic infections : numeric
: fraction of symptomatic hosts that die : numeric
: Start time of simulation : numeric
: Final time of simulation : numeric
: Time step : 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 tracks the dynamics of susceptible, presymptomatic, asymptomatic, symptomatic, recovered, and dead individuals. Susceptible (S) individuals can become infected by presymptomatic (P), asymptomatic (A), or infected (I) hosts. All infected individuals enter the presymptomatic stage first, from which they can become symptomatic or asymptomatic. Asymptomatic hosts recover within some specified duration of time, while infected hosts either recover or die, thus entering either R or D. Recovered individuals are immune to reinfection. This model is part of the DSAIDE R package, more information can be found there.
This code was generated by the modelbuilder R package. The model is implemented as a set of ordinary differential equations using the deSolve package. The following R packages need to be loaded for the function to work: deSolve.
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-29
2021-07-19
# To run the simulation with default parameters:
result <- simulate_Characteristics_of_ID_ode()
# To choose values other than the standard one, specify them like this:
result <- simulate_Characteristics_of_ID_ode(S = 2000,P = 2,A = 0,I = 0,R = 0,D = 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: 2000"