Professional Documents
Culture Documents
Figure 1: Scheme of the basic SIR model. Boxes represent compartments, and arrows indicate flux between
the compartments.
1
dR
= rI
dt
Using this model, we will consider a mild, short-lived epidemic, e.g. influenza, in a closed population. Closed
means that there is no immigration or emigration. Moreover, given the time scale of influenza epidemics, we
will not consider demographic turnover (birth or death), and all infections are assumed to end with recovery.
The size of the population (S + I + R) is therefore constant and equal to the initial population size, which
we denote with N . Let us now consider a population which is naive with respect to the disease we are
considering. What happens if a single infected individual is introduced into such a population? Is there going
to be an epidemic? How many people will be infected? We will answer these questions by implementing and
simulating the model in R.
2. Implementation in R
}
parms <- list(beta = 0.001, r = 0.1)
inits <- c(S = 499, I = 1, R = 0)
dt <- seq(0, 100, by = 0.1)
## time S I R
## 1 0.0 499.0000 1.000000 0.00000000
## 2 0.1 498.9491 1.040706 0.01020255
## 3 0.2 498.8961 1.083061 0.02082004
## 4 0.3 498.8410 1.127133 0.03186937
## 5 0.4 498.7836 1.172993 0.04336852
## 6 0.5 498.7240 1.220712 0.05533550
and I use the base R function matplot to plot the output. If you know ggplot or other packages, you can
use those for plotting instead.
matplot(sir.out$time, sir.out[2:4], type = "l", col = c("red", "blue", "black"),
lty = c("solid", "dashed", "dotted"))
2
500
400
300
sir.out[2:4]
200
100
0
0 20 40 60 80 100
sir.out$time
Run the model with the preset parameters. Now take some time to think about the interpretation of the
simulation. What is the population size with these settings? What is the time frame of the simulation? Is it
possible to tell? What defines the time scale? Would you expect to get such a smooth curve in a real life
epidemic?
Explore the model: play around with initial conditions and parameters and see what happens in the simulations
. Observe the effect of each parameter and the possible courses of simulated epidemics. Is it possible to
simulate a sustained endemic disease in this model?
βS
R0 =
r
Note that this result R0 = βSr derived above, applies only to the basic Kermack-McKendrick model, with
alternative SIR models having different formulas for dI/dt and hence for R_0. Check this formula by
simulating the model for a couple of different sets of parameters. Fix N , and vary β and/or r. Choose your
values such as to have combinations with R0 > 1 and R0 < 1. Run the model for each parameter combination
and see what happens.
3
4. Modifications to the model
Make modifications to the model diagram above. What parameters do you need to add for each? Try to
identify your assumptions as you make each modification. Write down the modified equations of the model.
For one of the modified models you create, write the code to numerically solve the model. How does your
modification change the dynamics?
A. Loss of Immunity
The “Recovered” state is not permanent. After some time, the recovered individuals return to being
susceptible.
B. Open population
Modify the model diagram and equations so as to include births and deaths.
Literature Cited
Kermack, W O, and A G McKendrick. 1927. “A Contribution to the Mathematical Theory of Epidemics.”
Proceedings of the Royal Society of London. Series A, Containing Papers of a Mathematical and Physical
Character 115 (772): 700–721.