This model allows for the simulation of an ID with 2 types of hosts
simulate_heterogeneity_ode( S1 = 1000, I1 = 1, S2 = 1000, I2 = 0, b11 = 0.01, b12 = 0, b21 = 0, b22 = 0, g1 = 1, g2 = 1, w1 = 0, w2 = 0, tmax = 120 )
: initial number of susceptible type 1 hosts : numeric
: initial number of infected type 1 hosts : numeric
: initial number of susceptible type 2 hosts : numeric
: initial number of infected type 2 hosts : numeric
: rate of transmission from infected type 1 host to susceptible type 1 host : numeric
: rate of transmission from infected type 1 host to susceptible type 2 host : numeric
: rate of transmission from infected type 2 host to susceptible type 1 host : numeric
: rate of transmission from infected type 2 host to susceptible type 2 host : numeric
: the rate at which infected type 1 hosts recover : numeric
: the rate at which infected type 2 hosts recover : numeric
: the rate at which type 1 host immunity wanes : numeric
: the rate at which type 2 host immunity wanes : numeric
: maximum simulation time, units of months : numeric
This function returns the simulation result as obtained from a call to the deSolve ode solver.
A compartmental ID model with several states/compartments is simulated as a set of ordinary differential equations. The function returns the output from the odesolver as a matrix, with one column per compartment/variable. The first column is time.
This function does not perform any error checking. So if you try to do something nonsensical (e.g. any negative values or fractions > 1), the code will likely abort with an error message.
See e.g. Keeling and Rohani 2008 for SIR models and the documentation for the deSolve package for details on ODE solvers
The UI of the Shiny app 'Host Heterogeneity', which is part of this package, contains more details on the model.
# To run the simulation with default parameters just call the function: result <- simulate_heterogeneity_ode() # To choose parameter values other than the standard one, specify them like such: result <- simulate_heterogeneity_ode(S1 = 100, S2 = 1e3, b11 = 0.7, tmax = 100) # You should then use the simulation result returned from the function, like this: plot(result$ts[,"time"],result$ts[,"S1"],xlab='Time',ylab='Number Susceptible 1',type='l')