Description Usage Arguments Details Value References See Also Examples
View source: R/SIRSinusoidalBirth.R
Solves a SIR model with sinusoidal forcing of the birth rate.
1 |
pars |
|
init |
|
time |
time sequence for which output is wanted; the first value of times must be the initial time. |
... |
further arguments passed to ode function. |
This is the R version of program 5.3 from page 184 of "Modeling Infectious Disease in humans and animals" by Keeling & Rohani. To create bifurcations, alpha1
must be a vector. For bifurcations, if max(time) < 3650), time is defined as c(0:3650). Here, different to the original Python code, we wrote equations for the R population as R = 1 - S - I.
list
. The first element, *$model
, is the model function. The second element is a list
with the the *$pars
argument. The third and fourth elements are the vectors (*$init
, *$time
, containing the init
and time
arguments of the function. The fifth element *$results
is a data.frame
with up to as many rows as elements in time. First column contains the time. Second, third and fourth columns contain the proportion of susceptibles, infectious and recovered.
Keeling, Matt J., and Pejman Rohani. Modeling infectious diseases in humans and animals. Princeton University Press, 2008.
ode.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# Parameters and initial conditions (bifurcation plot of infectious)
parameters <- list(beta = 17 / 13, alpha0 = 1 / (50 * 365),
alpha1 = 0.25, w = 2 * pi / 365 ,
mu = 1 / (50 * 365), gamma = 1 / 13)
parameters2 <- list(beta = 17 / 13, alpha0 = 1 / (50 * 365),
alpha1 = seq(0, 0.99, 0.01), w = 2 * pi / 365 ,
mu = 1 / (50 * 365), gamma = 1 / 13)
initials <- c(S = 1 / 17, I = 1e-4, R = 1 - (1 / 17 + 1e-4))
# Solve and plot.
sir.sinusoidal.birth <- SIRSinusoidalBirth(pars = parameters,
init = initials,
time = 0:(20 * 365))
PlotMods(sir.sinusoidal.birth)
# Bifurcations
# Uncomment the following lines (running it takes more than a few seconds):
# bifurcation <- SIRSinusoidalBirth(pars = parameters2,
# init = initials,
# time = 0:(20 * 365))
# PlotMods(bifur, bifur = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.