Uploaded by kosay-h

The role of explicit solutions in the analysis of epidemic models

Faculty of Technology
Department of Mathematics
The role of explicit solutions
in the analysis of epidemic
models
Project thesis in applied mathematics, 15 hp
Supervisor: Roger Pettersson
Examiner: Torsten Lindström
Date: 2021-08-20
Level: Bachelor’s Degree
Contents
1
Introduction
3
2
Background
3
3
Deterministic and stochastic models
3
4
Model assumptions
4
5
The SIR Model
5.1 Transformation of SIR ODE into a one-dimensional integral equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Numerical solution of the SIR ODE by using Euler’s method . . .
5.3 The number of infected individuals during the epidemic . . . . . .
5.3.1 The Lambert function . . . . . . . . . . . . . . . . . . .
5.4 The influence of parameters . . . . . . . . . . . . . . . . . . . . .
5.4.1 Different k values . . . . . . . . . . . . . . . . . . . . . .
5.4.2 Different i(0) values . . . . . . . . . . . . . . . . . . . .
5
7
15
17
17
19
19
21
6
The SIS Model
22
6.1 The SIS Model assumptions . . . . . . . . . . . . . . . . . . . . 22
6.2 Deterministic SIS model . . . . . . . . . . . . . . . . . . . . . . 23
7
SEIR Model
25
7.1 The SEIR model . . . . . . . . . . . . . . . . . . . . . . . . . . 26
7.2 Numerical solution by using R . . . . . . . . . . . . . . . . . . . 27
8
A modified SIR model
28
8.1 Numerical solution . . . . . . . . . . . . . . . . . . . . . . . . . 30
8.2 The number of susceptible individuals at the epidemic end . . . . 30
9
Conclusion
32
A Appendix
A.1 The SIR model . . . . . . . . . . . . . . . . . . . . . . .
A.1.1 The SIR model plot . . . . . . . . . . . . . . . . .
A.1.2 The contact number influence . . . . . . . . . . .
A.1.3 The initial infected individuals value i(0) influence
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
A
A
A
B
C
A.2 The SIS model . . . . . . .
A.2.1 The SIS model plot .
A.3 The SEIR model . . . . . .
A.3.1 The SEIR model plot
.
.
.
.
2
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
C
C
F
F
1 Introduction
In this thesis, we will study basic mathematical epidemic models SIR, SIS, and
SEIR. Then we will construct a modified model as a combination of SIR and
SIS models. First, we will find the explicit solutions for the SIS model. and
show no exact solution for the SIR model. Also, find the parametric solution for
the SIR model and find a numerical solution by using Euler’s method. Then we
find an approximate explicit form of the epidemic curve. Also, we will study
parametric influences on the SIR and SIS models. Finally, we will suggest some
recommendations to decrease the epidemic’s spread.
2 Background
Since the beginning of history, epidemics have affected human beings. In the
middle of the fourteenth century, the Black Death killed at least one-third of Europe’s population [1]. The Spanish flu (1918-1919) caused more than 50,000,000
deaths. A pioneering study of infectious disease was John Graunt’s work in 1662
[2]. Daniel Bernoulli (1760) contributed to the mathematical modelling of smallpox mortality, and the epidemics modelling improved after the disease transmission process was more understood. This new knowledge helped scholars to study
epidemic outbreaks and get immunity.
3 Deterministic and stochastic models
We can define mathematical modelling as a system description by equations and
variables to establish relationships between those variables and the governing parameters [3]. Epidemic mathematical modelling is an essential tool to convert
infection spread into a mathematical expression and make it easier to understand
the evolution of an epidemic. There are deterministic and stochastic modelling.
A deterministic model always produces the same scenarios and gives the same
parameters with the same initial values. We use deterministic models to analyze
epidemics; it is easier to explain the change and effect of changing factors than
stochastic models. A stochastic model is a tool to analyze data with changing
probabilities [4].
Both stochastic and deterministic models are helpful and practical tools for studying epidemic outbreaks and identifying strategies to prevent epidemic spread. In
3
general, deterministic models are easier than stochastic models to explain what
happens, especially when dealing with a large population. In our study, we will
use a deterministic model only and we will not discuss stochastic models.
4 Model assumptions
The thesis will handle models by ordinary differential equations. To understand
the models, we will explain some parameters and terms before discussing the
models. To study individuals in a community, we will divide the population into
groups based on their health status and the ability to infect other individuals:
• S(t) is the number of susceptible individuals at time t,
• I(t) is the number of infectious individuals at time t,
• R(t) is the number of removed (and immune) or deceased individuals at
time t,
• N is the community size, and it is fixed. We assume N is big enough to
accept the S(t), I(t), and R(t) are differentiable functions.
The sum of factors equals the community size N = S(t) + I(t) + R(t). By
+ I(t)
+ R(t)
. We will use
dividing both sides of the equation by N we get 1 = S(t)
N
N
N
I(t)
R(t)
S(t)
fractions where s(t) = N , i(t) = N , r(t) = N are fractions for susceptible,
infected, removed respectively.
We assume that the infection depends on contact between infected and susceptible
individuals. The infection does not depend on personality factors (age, gender,
and race) [5]. Also, the model is homogenous mixing in the community, and the
population size is fixed (no immigration nor new births). When an individual dies
because of the infection, the individual will belong to the removed individuals.
We will use the following parameters:
1. Infection transmissibility p is the probability of infection when a susceptible
individual contacts an infected individual [6],
2. An effective contact is a contact between a susceptible and an infected individual, in which the susceptible individual becomes infected,
3. The total contact number k is the mean number of contacts, effective or not
effective, for an infected individual per unit of time, and it is a constant,
4. Let λ = kp > 0. Since not all contacts cause infections, and the transmissi-
4
bility is p, on average, each infected individual infects new λs(t) individuals
per time unit.
5. γ is the rate of newly removed individuals per infected individuals per time
unit. It means mathematically:
R(t + ∆t) − R(t)
.
∆t→0
I(t)∆t
γ = lim
(4.1)
If the conditions do not change (by a treatment or another reason), we can
assume γ > 0 is a constant,
6. The expected duration of infection d is the mean number of time units for
an infected individual to become removed. If an infected individual needs
1
d time unit to become removed, then γ = > 0,
d
λ
7. The basic reproduction number R0 = is the mean number of individuals
γ
infected directly by one infected individual where all other individuals are
initially susceptibles [7]. The infected individual infects in mean R0 other
individuals before being removed. We note that R0 is dimensionless and not
a rate parameter. It can be expressed as a product of the total contact rate k
by transmissibility p by the mean duration of infections d. Since λ = kp,
and d = 1/γ we get.
R0 = kpd =
λ
.
γ
(4.2)
5 The SIR Model
Kermack and McKendrick developed a pioneering epidemic model in 1927 [8].
The model assumes that a susceptible individual can be infected, and then the infected individual will be removed.
F IGURE 1: state diagram of the SIR model
5
We want to find s′ (t), the derivative of s(t). First, we want to find the sign of
s′ (t). We assumed the community’s size N is fixed and big. There are no new
susceptible individuals; only susceptible individuals become infected , so s(t) is
decreasing and s′ (t) < 0.
If each infected individual interacts with k individuals, and the transmissibility is
p, then each infected individual infects k p s(t) = λ s(t). The number of newly
infected individuals per time unit is λs(t)I(t). The change in S(t) per time t is
the derivative of S(t) respect to t:
S ′ (t) =
d S(t)
= −λ s(t)I(t).
dt
By dividing both sides by N and we get:
s′ (t) =
d s(t)
= −λ s(t)i(t).
dt
In the same discussion, the derivative of R(t) with respect to t is the change in
R(t) at time t. It equals newly removed individuals at time t.
R′ (t) = lim
∆t→0
R(t + ∆t) − R(t)
.
∆t
If we multiply numerator and denominator by I(t) ̸= 0,
lim
∆t→0
R(t + ∆t) − R(t)
R(t + ∆t) − R(t)
= lim
I(t),
∆t→0
∆t
∆t I(t)
and divide both sides by N ,
lim
∆t→0
r(t + ∆t) − r(t)
R(t + ∆t) − R(t)
= lim
i(t).
∆t→0
∆t
∆t I(t)
Substitute γ from equation (4.1), in equation (5.3).
r′ (t) = γ i(t).
6
(5.3)
We have s(t) + i(t) + r(t) = 1 =⇒ s′ (t) + i′ (t) + r′ (t) = 0. By substituting the
values of s′ (t), and r′ (t) we get −λs(t)i(t) + i′ (t) + γi(t) = 0, then we get i′ (t)
expression as i′ (t) = λs(t) i(t) − γi(t).
We get the ODE system for the SIR model,
s′ (t) = −λs(t)i(t),
(5.4)
i′ (t) = λs(t)i(t) − γi(t),
(5.5)
r′ (t) = γ i(t).
(5.6)
By taking out the common factor i(t) in the equation (5.5) we re-write is as:
i′ (t) = i(t)(λs(t) − γ).
Observe that since R0 =
(5.7)
λ
we can express infection equation (5.7) as,
γ
i′ (t) = γ i(t) (R0 s(t) − 1)
(5.8)
From equation (5.8) if R0 > 1, the epidemic will spread. But when R0 < 1 this
means there is no major epidemic [9].
The epidemic model contains three equations for functions s(t), i(t), and r(t)
with their initial values. Assume, for instance, that epidemic starts with i(0) =
ϵ infected individuals, and the rest of the population are susceptible individuals
s(0) = 1 − ϵ.
The fraction of susceptible individuals monotonically decreases, while the fraction
of removed individuals monotonically increases. The equations (5.4) and (5.6)
describe the change in s(t), and r(t) respectively.
5.1 Transformation of SIR ODE into a one-dimensional integral
equation
The SIR ordinary differential equations system comprises three equations with
three variables, s(t), i(t), and r(t). We want to solve the system by transforming
the system with three variables into one variable.
7
The first step is canceling i(t) from equation i′ (t) = −λs(t)i(t), and write i′ (t)
as an expression of s(t), s′′ (t), and s′ (t). The second step is cancelig i(t) from
equation s′ (t) = λs(t)i(t) − γi(t), and write i′ (t) as an expression of s′ (t), and
s(t). From the first and second steps, we get a second-order nonlinear ordinary
equation for s(t).
From equation (5.4) we have,
s′ (t) = −λ s(t) i(t) ⇒ −λ i(t) =
s′ (t)
,
s(t)
(5.9)
i.e.
−λ i(t) = (ln s(t))′ .
(5.10)
By integrating both sides, we get:
Z
ln s(t) = ln s(0) − λ
t
i(ζ)dζ.
(5.11)
i(ζ) dζ .
(5.12)
0
From the equation (5.11) we can express s(t) as:
Z
s(t) = s(0) exp −λ
t
0
By differentiating both sides of the equation s′ (t) = −λs(t)i(t) with respect to
the time t, we find
s′′ (t) = −λs′ (t)i(t) − λs(t)i′ (t),
i.e.
λs(t)i′ (t) = −s′′ (t) − λs′ (t)i(t),
By substituting the value of −λi(t) =
s′ (t)
from equation (5.9) we get,
s(t)
8
s′ (t)
(s′ (t))2
′′
λs(t)i (t) = −s (t) + λs (t)
= −s (t) +
,
λs(t)
s(t)
′
i.e.
′′
′
"
′ 2 #
′′
1
s
(t)
s (t)
i′ (t) = −
−
.
λ s(t)
s(t)
(5.13)
We get the first value of i′ (t) as an expression of s(t), s′ (t), and s′′ (t).
The second step is finding i′ (t) as an expression of s(t), and s′ (t). From equation
s′ (t)
(5.5), we substitute −s′ (t) = λs(t)i(t), and i(t) = −
. We get:
s(t)
i′ (t) = λs(t)i(t) − γi(t) ⇒ i′ (t) = −s′ (t) +
γs′ (t)
.
λs(t)
(5.14)
From equations (5.14), and (5.13) we get:
"
′ 2 #
′
′′
s (t)
γ
s
(t)
1
s
(t)
−s′ (t) +
=
−
.
λ s(t)
λ s(t)
s(t)
(5.15)
By multiplying both sides by λ, we get the following second-order differential
equation:
s′′ (t)
−
s(t)
s′ (t)
s(t)
2
− λs′ (t) + γ
s′ (t)
= 0.
s(t)
(5.16)
′
(t)
We want to write s(t) as an expression of r(t). By inserting i(t) = − λ1 ss(t)
into
equation (5.6) we get
r′ (t) = γi(t) = −
We use R0 =
λ
in the equation (5.17):
γ
9
γ s′ (t)
.
λ s(t)
(5.17)
r′ (t) = −
1 s′ (t)
1
=−
(ln s(t))′ ,
R0 s(t)
R0
(5.18)
In equation (5.18), we take the integral of both sides and we get:
s(t) = C1 e−R0 r(t) ,
(5.19)
where C1 is a constant. From the initial conditions t = 0,
s(0) = C1 = 1 − ϵ.
(5.20)
Re-writing s(t) as an expression of r(t),
s(t) = (1 − ϵ) exp (−R0 r(t)).
(5.21)
We can find s′ (t) by differentiating equation (5.21) with respect to time t,
s′ (t) = −R0 (1 − ϵ)r′ (t) exp (−R0 r(t)),
(5.22)
Now, the differentiation of Equation (5.18) with respect to t leads to the secondorder differential equation:
"
′ 2 #
′′
1
s (t)
s
(t)
r′′ (t) = −
−
,
R0 s(t)
s(t)
(5.23)
By multiplying both sides by −R0 we get:
"
s′′ (t)
−
s(t)
s′ (t)
s(t)
2 #
= −R0 r′′ (t).
(5.24)
The previous equation can be written in form −R0 r′′ (t) = f (s(t), s′ (t), s′′ (t)).
This is a non-linear second-order ordinary equation. We have expressions for
r′′ (t), s(t) and s′ (t) from equations (5.24), (5.21), and (5.22) respectively. Insert
these values into equation (5.16), to get the second-order ordinary equation.
10
−R0 r′′ (t) + λR0 (1 − ϵ)r′ (t) exp (−R0 r(t)) − γR0 r′ (t) = 0.
(5.25)
Divide both sides by −R0 , to get
r′′ (t) − λ(1 − ϵ)r′ (t) exp (−R0 r(t)) + γr′ (t) = 0.
(5.26)
To solve equation (5.26), we make the substituting u = e−R0 r(t) . From the initial
values we have r(0) = 0 ⇒ u(0) = 1. We need to get value of s′ (t), and s′′ (t) in
terms of u,
u(t) = exp (−R0 r(t)) ⇒ r(t) = −
1
ln u(t)
R0
(5.27)
Differentiate both sides of the equation (5.27) with respect to t:
r′ (t) = −
1 u′ (t)
.
R0 u(t)
(5.28)
We differentiate both sides of the equation (5.28) with respect to t again to get
r′′ (t),
"
′ 2 #
u (t)
1 u′′ (t)
−
r (t) = −
.
R0 u(t)
u(t)
(5.29)
u′ (t) = −R0 r′ (t) e−R0 r(t) = −R0 r′ (t) u(t)
(5.30)
′′
We want to get u′ (t),
By using r(t), r′ (t), and r′′ (t) from equations (5.27), (5.28), and (5.29) in equation
(5.26) we get:
"
′ 2 #
u (t)
1 u′ (t)
1 u′ (t)
1 u′′ (t)
+ λ(1 − ϵ)
−
−
u(t) − γ
=0 .
R0 u(t)
u(t)
R0 u(t)
R0 u(t)
11
By multiplying previous equation with −R0 u(t)2 we get:
2
u′′ (t)u(t) − (u′ (t)) − λ(1 − ϵ)u′ (t) u2 (t) + γu′ (t) u(t) = 0.
(5.31)
In the final we get,
2
u′′ (t) u(t) − (u′ (t)) + (γ − λ(1 − ϵ) u(t) ) u′ (t) u(t) = 0
(5.32)
Convert the equation (5.32) into a Bernoulli-type differential equation. Let ϕ =
dt/du(t) ,
u′′ (t)u(t) =
d(1/ϕ)
d(u′ (t))
u(t) =
u(t).
dt
dt
From the substitution u = exp (−R0 r(t)), we know du(t) ̸= 0, so we can multiply
d u(t)
by
and get,
d u(t)
u′′ (t)u(t) =
d(1/ϕ) du(t)
d(1/ϕ) d u(t)
u(t) =
u(t).
d t d u(t)
d u(t) d t
But ϕ = d t/d u(t),
u′′ (t)u(t) = −
1 dϕ 1
1 dϕ
u(t) = − 3
u(t).
2
ϕ d u(t) ϕ
ϕ d u(t)
Inserting this substitution in equation (5.32):
1 dϕ
− 3
u(t) −
ϕ d u(t)
Multiply both sides by
2
1
1
+ (γ − λ(1 − ϵ) u(t)) u(t) = 0.
ϕ
ϕ
(5.33)
ϕ3
:
u(t)
dϕ
1
+
ϕ = (γ − λ(1 − ϵ)u(t)) ϕ2 .
d u(t) u(t)
12
(5.34)
The equation (5.34) is a Bernoulli differential equation. Multiply equation (5.34)
by ϕ−2
ϕ−2
dϕ
1 −1
+
ϕ = γ − λ(1 − ϵ)u(t)
d u(t) u(t)
(5.35)
Let ν = ϕ−1 ⇒ ν ′ = −ϕ′ ϕ−2 . Use this substitution in equation (5.35):
−ν ′ +
1
ν = γ − λ(1 − ϵ)u(t)
u(t)
(5.36)
Multiply both sides by (-1)
ν′ −
1
ν = −(γ − λ(1 − ϵ)u(t))
u(t)
(5.37)
R
1
du),
To solve this equation, we need an integrating factor µ(u(t)) = exp ( −
u(t)
µ(u(t)) = exp (ln(u−1 (t))) =
1
.
u(t)
By multiplying both sides in equation (5.37) by integral factor µ =
1
γ
1 ′
ν − 2 ν = −(
− λ(1 − ϵ)).
u(t)
u (t)
u(t)
The left side of the equation (5.39) is the derivative of (
(
1
ν)′ .
u(t)
1
γ
ν)′ = −
+ λ(1 − ϵ).
u(t)
u(t)
By integrating both sides with respect to u(t) we get:
1
ν = −γ ln u(t) + λ (1 − ϵ) u(t) + C2
u(t)
13
(5.38)
1
.
u(t)
(5.39)
i.e.
ν = u(t)(C2 − γ ln u(t) + λ (1 − ϵ) u(t))
But ϕ =
1
dt
=
, so the solution for this equation is:
ν
du(t)
ϕ=
dt
1
=
d u(t)
u(t)(C2 − γ ln u(t) + λ (1 − ϵ) u(t))
(5.40)
where C2 is constant. We have u(t) = exp (−R0 r(t)). For initial value t = 0, we
get r(0) = 0, so u(0) = 1.
u′ (t) = −R0 r′ (t) exp (−R0 r(t)). For t = 0, we have, r′ (0) = γi(0) = γϵ.
u′ (0) = −R0 γϵ.
Substitute this value in equation (5.40),
−
1
1
=
R0 γϵ
1(C2 − γ ln (1) + λ (1 − ϵ) (1))
i.e.
−
1
1
=
.
R0 γϵ
C2 + λ (1 − ϵ) )
The integration constant C2 = −R0 γϵ − λ(1 − ϵ). From equation (5.40) we can
get the value of t as:
Z
u(t)
t − t0 =
u(t0 )
dζ
.
ζ (C2 − γ ln ζ + λ (1 − ϵ) ζ)
(5.41)
We may choose t0 = 0 without loss of generality. In conclusion, the exact solution
for the SIR model can be written as parametric equations for t.
We can represent s(t), i(t), and r(t) in the forms:
1. s(t) = s(0) u(t),
14
2. r(t) = −
1
ln u(t),
R0
3. i(t) = 1 − s(t) − r(t),
where for given t, u(t) is the solution to (5.41).
5.2 Numerical solution of the SIR ODE by using Euler’s method
The main goal for this section is to use Euler’s method to solve the SIR ordinary
differential equations numerically and compare solutions with Kermack and McKendrick solution. Euler’s method is an approximate solution to the initial-value
problem by finding a series of points, (tn , yn ), where each step ∆t = tn − tn−1 is
constant.
yn+1 = yn + mn ∆t.
(5.42)
We can use this method with initial values (s(0), i(0), r(0)) to solve the equations
(5.4), (5.5), and (5.6) approximately [10]. By approximating equation (5.42) we
get:
sn+1 = sn − λsn in ∆t,
(5.43)
in+1 = in + λsn in − γ in ∆t,
(5.44)
rn+1 = rn + γin ∆t.
(5.45)
We can use deSolve library, in R programming language, to solve ODEs. For
example, s(0) = 0.9999, i(0) = 0.0001, and r(0) = 0 and λ = 1.8, and γ = 0.5.
We use deSolve library to solve the ODE system.
15
F IGURE 2: a plot for numerical solution for the SIR model with initial values s(0) = 0.9999,
i(0) = 0.0001, and r(0) = 0, with parameters λ = 1.8, and γ = 0.5
In Kermack and McKendrick’s work, they used the Maclaurin series to express
s(t) = s(0)e−R0 r(t) as a power series of r(t). From equation (5.6) we can write
r′ (t) = γi(t) = γ(1 − s(t) − r(t)). First, we assume R0 r(t) < 1, and then we
write s(t) as a power series of s(0)R0 r(t). We approximate s(t) as
s(t) = s(0) − s(0)R0 r(t) + s2 (0)
R02 2
r (t).
2
(5.46)
By substituting s(t) approximation values from equation (5.46) in r′ (t) = γ(1 −
s(t) − r(t)) we get,
R02 2
r (t) = γ 1 − s(0) + s(0)R0 r(t) − s(0) r (t) − r(t) .
2
′
i.e.
R02 2
r (t) = γ 1 − s(0) + (s(0)R0 − 1)r(t) − s(0) r (t) .
2
′
The equation (5.47) has a solution [8], and its solution is
16
(5.47)
√
q
1
√
R0 s(0) − 1 + q tanh
γt − ϕ ,
r(t) = 2
R0 s(0)
2
(5.48)
where
ϕ = tanh−1
R0 s(0) − 1
,
√
q
and
√
1
q = (R0 s(0) − 1)2 − 2s(0)i(0)R02 2
,
and we get the other solutions s(t) = s(0)e−R0 r(t) , and i(t) = 1 − s(t) − r(t).
5.3 The number of infected individuals during the epidemic
The epidemic will end when there is no infection fraction i(t) = 0, and there are
only susceptible and removed fractions. Mathematically, the epidemic will end as
t → ∞. We have s(t) + i(t) + r(t) = 1. We then get s(∞) + 0 + r(∞) = 1,
which implies s(∞) = 1 − r(∞).
We have from equation (5.21), s(t) = (1 − ϵ) exp (−R0 r(∞)). By substituting
this value in s(∞) = 1 − r(∞) we get:
1 − r(∞) = (1 − ϵ) exp (−R0 r(∞)).
(5.49)
We can numerically find r(∞) that solves equation (5.49) or by using the Lambert
function.
5.3.1 The Lambert function
The Lambert function is also known as the omega function or product logarithm
[11]. The Lambert W function answers the equation y = W (y) eW (y) [12]. That
means for a given y, the value W (y), is such that y = W (y)eW (y) . The equation
relating to the Lambert function involves three cases.
• if −1/e < y, there is one real solution,
• if −1/e ≤ y < 0, there are two solutions, y = W0 (y), and y = W−1 (y),
17
• if 0 < y , there is one solution.
We only deal with real numbers, so we will not study the Lambert function with
complex numbers in our model. Figure 3 is a plot for Lambert function with real
values −1/e ≤ y [13].
F IGURE 3: Real values of the Lambert W (y) function. The solid curve is the branch for
(W0 (y)), and the dashed curve is the branch for W−1 (y).
There are basic properties of the Lambert function,
W (x)
,
x(1 + W (x))
2. W (x) + W (y) = W xy(
1. W ′ (x) =
1
1
+
) ,
W (x) W (y)
P∞ −nn−1 n
x = x − x2 + 23 x3 − 83 x4
n=1
n!
Wang shows in his work about the Lambert function, that we can solve the equation a x + b+c ed x = 0 (with ad ̸= 0) expressed in terms of the Lambert function
[14]. The solution for this equation is:
3. W (x) =
b 1
x=− − W
a d
c d e−bd/a
a
(5.50)
In our situation for which 1 − r(∞) = (1 − ϵ) e−R0 r(∞) , obviously,
r(∞) − 1 + (1 − ϵ) e−R0 r(∞) = 0
18
(5.51)
In this case a = 1 , b = −1, c = 1 − ϵ, and d = −R0 . We get the solution
r(∞) = 1 +
W (−(1 − ϵ) R0 e−R0 )
R0
(5.52)
From equation (5.52), we can get s(∞), and it refers to survivor individuals, who
have not been infected during the epidemic. We can compare two epidemic outbreaks using the s(∞) value. A low value of s(∞) means the epidemic outbreak
is large,
s(∞) = −
W (−(1 − ϵ) R0 e−R0 )
.
R0
(5.53)
5.4 The influence of parameters
5.4.1 Different k values
We consider the dynamics for different values of k, for instance, k = 2, and
k = 10, respectively, and other parameters are fixed. Assume γ = 0.25, s(0) =
0.9999, i(0) = ϵ = 0.0001, and , p = 0.9.
(a) The graph for k = 2.
(b) The graph for k = 10.
F IGURE 4: In figure (a), the total contact number k = 2, and in figure (b) the total contact
number k = 10, with the same other initial values.
We can reduce the total contact number by decreasing the contact between people,
like working remotely, meeting through the internet instead of physical meetings,
and closing schools and universities during the epidemic.
19
1.8
= 7.2. When k = 10
For the first case λ = pk = 0.9 · 2 = 1.8, and R0 =
0.25
9
then λ = 0.9 · 10 = 9 and R0 =
= 36.
0.25
For instance, the Lambert function W can be calculated by Mathematica for instance which then gives the following results. For total contact number k = 2
then,
W (−7.2(1 − 10−4 )e−7.2 )
s(∞) = −
= 0.000750556,
(5.54)
7.2
while if k = 10 the
s(∞) = −
W (−9(1 − 10−4 )e−9 )
= 0.0001235.
9
(5.55)
If the total contact number increases from k = 2 to k = 10, the fraction of noninfected individuals will decrease from 0.000750556 to 0.0001235. This proves
the importance of keeping distance between individuals and closing public meeting places (like schools). In figure 5, we notice that increasing contact between
individuals causes more infected individuals. When k = 0, this means there is no
contact between individuals and the epidemic will not spread. The epidemic will
0.95k
pk
=
> 1, so k > 0.9/0.95 = 0.947. We notice there
take off if R0 =
γ
0.9
is a slight change in never-infected individuals when 0 < k ≤ 0.947, but when
k > 0.947, we find the change in never-infected individuals becomes bigger.
F IGURE 5: Relation between the contact number k > 0 and the fraction of never infected individuals s(∞) with parameters p = 0.95, γ = 0.9, and s(0) = 0.9999.
20
5.4.2 Different i(0) values
We consider the dynamics for different values of i(0) is varying, for instance
i(0) = 10−6 , and i(0) = 10−4 respectively and the other parameters are fixed.
Assume γ = 1, and λ = 5.4.
(a) The graph for i(0) = 10−6 .
(b) The graph for i(0) = 10−4 .
F IGURE 6: In figure (a), the epidemic starts with i(0) = 10−6 infected individuals, and in figure
(b) epidemic starts with i(0) = 10−4 , and R0 = 5.4.
By using the value of R0 = 5.4/1 = 5.4 in equation (5.53) we get for i(0) = 10−4
s(∞) = −
W (−5.4(1 − 10−4 ) e−5.4 )
= 0.0046304768,
5.4
(5.56)
and for i(0) = 10−6
W (−5.4(1 − 10−6 ) e−5.4 )
= 0.0046309470.
(5.57)
5.4
The epidemic outbreak depends on i(0), and the smaller value of i(0) causes a
smaller epidemic outbreak 4.702 · 10−7 .
s(∞) = −
21
F IGURE 7: Relation between the initial infection i(0) and log of the fraction of never infected
individuals s(∞) with parameters R0 = 5.4.
In figure 7 the value of i(0) changed between 0.001 to 0.999. We can not use
i(0) = 0, because this means there is no epidemic. We notice increasing i(0) will
reduce s(∞).
6 The SIS Model
The SIS model is an epidemic model that assumes the susceptible individual becomes infected and returns to the susceptible group. The individual does not have
permanent immunity against reinfection and reverts to the class of susceptible individuals [15]. Cold and influenza are examples of the SIS model. For example,
if a person has cough influenza in the winter, he recovers from the flu. Still, he
can get second flu in the same winter.
6.1 The SIS Model assumptions
The model is a modified version of the SIR model where the infected individual
does not confer any long-lasting immunity. We assume the population size is
fixed.
22
F IGURE 8: Diagram of SIS model without death and birth.
• s(t) is the fraction of susceptible individuals at time t,
• i(t) is the fraction of infectious individuals at time t,
6.2 Deterministic SIS model
This model assumes homogenous mixing in the community. The population is
fixed and equals N . Let s(t) = S(t)/N , and i(t) = I(t)/N . The population contains the fraction s(t) of susceptible individuals, and the fraction i(t) of infectious
individuals. The infection rate is λ = kp as before.
The change of the fraction of newly infected individuals per time unit is then
λi(t)s(t). The infected individuals become susceptibles per time unit is γ. Hence,
ds(t)
= −λs(t)i(t) + γi(t)
dt
(6.58)
di(t)
= λs(t)i(t) − γi(t).
dt
(6.59)
Since i(t) + s(t) = 1, we can substitute s(t) by 1 − i(t) in equation (6.59):
di(t)
= λ(1 − i(t))i(t) − γi(t) = (λ − γ)i(t) − λ i2 (t).
dt
(6.60)
There are two trivial solutions. The first trivial solution is i(t) = 0, and s(t) = 1.
We refuse this solution because there is no epidemic if i(t) = 0. The second trivial
23
γ
λ−γ
and s(t) = . From conditition 0 ≤ s(t) < 1 we find
solution is i(t) =
λ
λ
there is a solution if γ < λ.
If γ = λ, the equation (6.60) becomes i′ (t) = −λi2 (t), and the solution is i(t) =
1
. From the initial values we get,
λt + C
i(t) =
i(0)
,
i(0)λt + 1
(6.61)
and s(t) = 1 − i(t). We can write s(t) as:
s(t) =
i(0)λt + s(0)
.
i(0)λt + 1
(6.62)
When γ ̸= λ then the equation (6.60) is a first-order Bernoulli ODE where we
recall the general form for Bernoulli ODE is:
dy
= P (x)y + f (x)y n
dx
(6.63)
Let u = u(t) = i1−2 (t) = i−1 (t) ⇒ u′ = −i−2 (t) i′ (t) and i′ (t) = −u′ i2 (t) =
−u′ u−2 . By by substituting u = i−1 in equation (6.60).
−u′ u−2 = (λ − γ) u−1 − λ u−2
(6.64)
Multiply both sides by −u2 ,
u′ = −(λ − γ)u + λ
i.e.
du
du
= −(λ − γ) u + λ ⇒ dt =
.
dt
−(λ − γ)u + λ
Substitute ν by ν = −(λ − γ)u + λ. Then du = −
in equation (6.65),
dt = −
1
dν
.
(λ − γ) ν
24
(6.65)
dν
. By using this substitute
λ−γ
By integrating both sides:
−
1
ln(−(λ − γ)u + λ) = t + C1 .
λ−γ
To find C1 value for t = 0, we have u = i−1 (0) = ϵ−1 we get C1 =
Rewrite the last equation as
(6.66)
1
γ−λ
ln
γ − (1 − ϵ)λ
.
ϵ
ln((γ − λ)u + λ) = (γ − λ) (t + C1 ) .
i.e.
ln((γ − λ)u + λ) = (γ − λ)t + (γ − λ)C1 .
(6.67)
Let C2 = (γ − λ)C1 , and apply the exponential function. If γ ̸= λ we can obtain:
u=
exp (t(γ − λ)) exp (C2 ) − λ
.
γ−λ
But u = i−1 (t), and C = exp (C2 ) = exp ((γ − λ)C1 )
i(t) =
γ−λ
.
C exp ((γ − λ)t) − λ
From the initial value, i(0) = ϵ, this gives C =
(6.68)
γ−λ
+ λ. Hence, for γ ̸= λ we
i(0)
get
−1
γ−λ
i(t) = (γ − λ) (
+ λ) exp ((γ − λ)t) − λ
i(0)
(6.69)
and s(t) = 1 − i(t).
7 SEIR Model
In many infectious diseases, the infected individual can not transmit the infection
during a period because the pathogen is in the infected individual in low numbers.
We call this period the exposed period [16]. We denote e(t) as the fraction of
exposed individuals at time t.
25
F IGURE 9: Plot for the SIS model.
F IGURE 10: Diagram of SEIR model without death and birth
As before we assume a fixed community size N and homogeneous mixing. The
parameters λ and γ as we defined them before. We define β as the rate of latent
individuals becoming infectious.
7.1 The SEIR model
If susceptible individuals contact with infected individuals, the pathogen would
transfer from infected individuals to susceptible individuals, which become exposed individuals. The change in the fraction of susceptible individuals per time
unit is the derivative of s(t), and it equals:
ds(t)
= −λs(t) i(t).
dt
26
(7.70)
Some susceptible individuals become exposed individuals. In contrast, some exposed individuals become infected, so the change in exposed individuals per time
contains new exposed individuals minus the newly infected individuals. The rate
of newly exposed individuals per time unit is λs(t)i(t). The rate of newly infected
individuals per time unit is βe(t), where β is the rate of newly infected individuals
per exposed individual per time unit. The change of fraction of exposed per time
unit is the derivative of e(t), and it equals:
de(t)
= λs(t) i(t) − βe(t).
dt
(7.71)
While newly exposed individuals become infected, other infected individuals become removed individuals.
di(t)
= βe(t) − γ i(t),
dt
(7.72)
Finally, the change in removed individuals per time unit is:
dr(t)
= γ i(t)
dt
(7.73)
This model, SEIR, is formulated as a system of nonlinear ordinary differential
equations (7.70)-(7.73), and they do not have analytical solution [17]. The initial
conditions at t = 0 is (s(0), e(0), i(0), 0), and s(t) + e(t) + i(t) + r(t) = 1.
F IGURE 11: Diagram of SEIR model without death and birth
7.2 Numerical solution by using R
For the SEIR model, we can use the deSolve library in R to find a numerical solution for this model. For example, in a community where the total population size
N = 25000 + 7 = 25007, we solve the model numerically and plot the functions.
In figure 12 we have the initial values β = 0.7, γ = 0.2 and furthermore.
27
• s(0) = 9990/25007 susceptible individuals,
• e(0) = 9/25007 exposed individuals,
• i(0) = 1 infected individual,
• r(0) = 0 removed individuals,
• λ = 0.7, β = 0.5, and γ = 0.2.
F IGURE 12: Numerical solution for the SEIR model with parameters N = 10000, s(0) =
9990
9
1
, e(0) =
, i(0) =
, r(0) = 0, λ = 0.7, β = 0.5, and γ = 0.2.
25007
25007
25007
8 A modified SIR model
There is an influence of many factors on immunity. Immunity may be affected
by age, sex, and other factors [18]. Sometimes there are genetic mutations, and
scholars need to study the epidemic deeply to know important factors that affect
immunity.
In the previous models, immunity does not depend on personality factors. In
this model, we assume long-term immunity (or permanent immunity) depends on
personal factors, and some individuals can get permanent immunity. In contrast,
others can not get long-term immunity (or permanent immunity). This model is a
combination of SIS and SIR models.
28
F IGURE 13: Diagram of SIS and SIR model without death and birth.
This model assumes homogenous mixing in the community, the population is
fixed and equals N . Let s(t) = S(t)/N , i(t) = I(t)/N , and r(t) = R(t)/N ,
where the fraction s(t), i(t), and r(t) as before. The parameters λ, and β are
infection rate, and removed rate respectively. Infected individuals which become
susceptibles per time unit is γ as before.
The susceptible individuals increase when a part of infected individuals become
newly susceptible by γi(t). While it decreases when a part of susceptible individuals become newly infected by λs(t)i(t). The derivative s′ (t) is the change in
susceptible individual per time unit,
ds(t)
= −λs(t)i(t) + γi(t).
dt
(8.74)
The removed inviduals increase with a removed rate β parameter, so r′ (t) is the
change in removed individuals per time unit,
dr(t)
= βi(t).
dt
(8.75)
To find the change in i(t), we have s′ (t) + i′ (t) + r′ (t) = 0, because s(t) + i(t) +
r(t) = 1 is a constant, and from equations (8.74), and (8.75) we get,
−λs(t)i(t) + γi(t) + i′ (t) + βi(t) = 0
29
i.e.
di(t)
= λs(t)i(t) − γi(t) − βi(t).
dt
(8.76)
8.1 Numerical solution
We use deSolve library to solve ODE systems. To compare between SIR and the
modified SIR, assume a newly mutated virus causes an epidemic breakout. The
first model with SIR, and the second model with a modified SIR model. Suppose
a fixed closed community where S(0) = 500000, I(0) = 1, and R(0) = 0 and
furthermore,
• In the SIR model, infection ratio λ = 0.8, and the removed ratio is γ = 0.3,
• In the modified SIR, infection ratio λ = 0.8, removed ratio is β = 0.1, and
γ = 0.2.
(a) The SIR model with parameters λ = 0.8,
and γ = 0.3.
(b) The modified SIR model with
parameters λ = 0.8, β = 0.1, and
γ = 0.2.
F IGURE 14: A model for an epidemic with initial values S = 500000, and I(0) = 1. In graph
(a), we use the SIR model and we assume the individual will not be infected again.
In graph (b), we use a modified model. A part of the infected individuals become
susceptible, and the rest infected individuals become removed.
From the library deSolve we find after 70 time units in the first model, SIR, we
find s(70) = 0.08782710, i(70) = 3.206409 · 10−05 , and r(70) = 0.9121408, In
the modified SIR, we find s(70) = 0.2520501, i(70) = 0.01016830, and r(70) =
0.7377816.
8.2 The number of susceptible individuals at the epidemic end
Removed individuals will increase until the epidemic’s end (i(t) = 0). We will
find s(∞) as we did in the SIR model. In the previous SIR model, susceptible
30
individuals never have been infected, while in modified SIR, individuals can be
infected and then become susceptible at the epidemic’s end.
By dividing equation (8.74) by equation (8.75) we get
ds(t)
1
(−λs(t) + γ) =
.
β
dr(t)
This implies
dr(t)
ds(t)
=
.
β
−λs(t) + γ
By multiplying both sides by −λ and then taking the integration of both sides, we
get
λ
− r(t) + C1 = ln(−λs(t) + γ).
(8.77)
β
i.e.
1
s(t) = −
λ
λ
C2 exp (− r(t)) − γ .
β
(8.78)
To find C2 from initial value t = 0 we get C2 = −λs(0) + γ. Use the C2 value in
equation (8.78) to get
1
s(t) = −
λ
λ
(−λs(0) + γ) exp (− r(t)) − γ .
β
(8.79)
In the epidemic end, i(∞) = 0, and s(∞) + 0 + r(∞) = 1 ⇒ r(∞) = 1 − s(∞).
Substituting s(t) in the equation (8.79), we get
1
1 − r(∞) = −
λ
λ
(−λs(0) + γ) exp (− (r(∞))) − γ .
β
(8.80)
γ
−λs(0) + γ
λ
− 1, c = −
, and d = − . Now we rewrite
λ
λ
β
dz
equation (8.80) as z +b+ce = 0. From Wang work [14] we get the final solution


γ−λ
(γ − s(0)λ) exp (
)
γ β 
β
,
(8.81)
r(t) = 1 − + W 

λ λ 
β
Let z = r(∞), b =
31
i.e.

γ−λ
(γ − s(0)λ) exp (
)
γ β 
β

.
s(t) = − W 

λ λ
β

(8.82)
Where W (z) is a Lambert function. Back to the example in section (8.1), we get
s(t) = 0.251887, but in the SIR we get s(∞) = 0.2630721. We calculate the
result by using Matematica.
9 Conclusion
We studied some epidemic models SIR, SIS, and SEIR. We found there is a parametric solution for SIR model and the solution obtained by u
1. s(t) = s(0) u(t),
2. r(t) = −
1
ln u(t),
R0
3. i(t) = 1 − s(t) − r(t),
where u(t) is a solution for equation (9.83)
Z
u(t)
t − t0 =
u(t0 )
dζ
.
ζ (C2 − γ ln ζ + λ (1 − ϵ) ζ)
(9.83)
There is an approximate explicit solution by using the Taylor series for s(t), and
that error is less than an error in the beginning then it increases until a time T ,
when the error from approximate explicit becomes greater than the error from
numerical solution (Euler’s method). There are no explicit solutions for SEIR.
There is an analytical solution for the SIS model,
−1,
γ−λ
i(t) = (γ − λ) (
+ λ) exp ((γ − λ)t) − λ
,
ϵ
(9.84)
and s(t) = 1 − i(t) for λ ̸= γ. We modified SIR for new infectious variants.
We studied the effect of initial values and find that reducing contact number k
will reduce the infection during the epidemic. Reducing k, will reduce R0 , and
the noninfected individuals in the epidemic end. There is an effect for i(0) on
32
epidemic breakout but the authorities can not control this number as easily as a
contact number.
In the end, we suggest reducing the effecting contact number k by using some
methods. The first method to reduce infection spreads is to stop activities until
they find a treatment, but it has a bad effect on the economy (as China did with
the zero corona policy). The second method uses a herd immunity method. Herd
immunity is letting a large number of persons in the community become removed.
These numbers must belong to nonthreatened people (like young people in the
coronavirus because they are less affected by coronavirus than old people). As a
result, the effective contact number will reduce and the epidemic will decrease.
33
References
[1] K. A. Glatter and P. Finkelman, “History of the plague: An ancient pandemic for the age of covid-19,” The American Journal of Medicine, vol. 134,
no. 2, pp. 176–181, 2021.
[2] F. Brauer, “Mathematical epidemiology: Past, present, and future,” Infectious Disease Modelling, vol. 2, no. 2, 113–127, 2017. [Online]. Available:
https://doi.org/10.1016/j.idm.2017.02.001.
[3] Renard, Philippe, Alcolea, Andres and Gingsbourger, D, “Stochastic versus
deterministic approaches,” in Environmental Modelling: Finding Simplicity
in Complexity, Second Edition, Wiley Online Library, 2013, 133–149.
[4] R. R. Bush and F. Mosteller, “A stochastic model with applications to learning,” The Annals of Mathematical Statistics, vol. 24, no. 4, pp. 559–585,
1953, ISSN: 00034851. [Online]. Available: http : / / www . jstor .
org/stable/2236781 (visited on 09/10/2022).
[5] T. Johnson and B. McQuarrie, “Mathematical modeling of diseases: Susceptibleinfected-recovered (sir) model,” University of Minnesota, Morris, Math,
vol. 4901, 2009.
[6] J. H. Jones, “Notes on R0 ,” California: Department of Anthropological Sciences, vol. 323, pp. 1–19, 2007.
[7] Fraser, C and Donnelly, CA and Cauchemez, S and Hanage, WP, “Van 2.
Kerkhove MD, Hollingsworth TD, et al. Pandemic potential of a strain of
influenza A (H1N1): early findings,” Science, vol. 324, no. 5934, 1557–61,
2009.
[8] K. Ogilvy, A. G. McKendrick, “A contribution to the mathematical theory
of epidemics,” Royal Society, vol. 115, no. 772, 700–721, 1927. [Online].
Available: https://doi.org/10.1098/rspa.1927.0118.
[9] T. Britton, “Stochastic epidemic models: A survey,” Mathematical biosciences, vol. 225, no. 1, pp. 24–35, 2010.
[10] Hossain, Md Tareque and Miah, Md Musa and Hossain, Md Babul and
others, “Numerical study of kermack-mckendrik SIR model to predict the
outbreak of ebola virus diseases using euler and fourth order runge-kutta
methods,” American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS), vol. 37, no. 1, 1–21, 2017.
[11] Weisstein, Eric W, Lambert W-Function. [Online]. Available: https://
mathworld.wolfram.com/LambertW-Function.html.
[12] J. Lehtonen, “The lambert w function in ecological and evolutionary models,” Methods in Ecology and Evolution, vol. 7, no. 9, pp. 1110–1118, 2016.
34
DOI :
[13]
[14]
[15]
[16]
[17]
[18]
https://doi.org/10.1111/2041- 210X.12568. eprint:
https://besjournals.onlinelibrary.wiley.com/doi/
pdf/10.1111/2041- 210X.12568. [Online]. Available: https:
//besjournals.onlinelibrary.wiley.com/doi/abs/10.
1111/2041-210X.12568.
J. Lehtonen, “The lambert w function in ecological and evolutionary models,” Methods in Ecology and Evolution, vol. 7, no. 9, pp. 1110–1118, 2016.
Wang, Frank, “Application of the Lambert W function to the SIR epidemic
model,” The College Mathematics Journal, vol. 41, no. 2, 156–159, 2010.
Naim, Mouhcine and Lahmidi, Fouad, “Analysis of a deterministic and a
stochastic SIS epidemic model with double epidemic hypothesis and specific functional response,” Discrete Dynamics in Nature and Society, vol. 2020,
2020.
P. Van den Driessche, “Reproduction numbers of infectious disease models,” Infectious Disease Modelling, vol. 2, no. 3, pp. 288–303, 2017.
S. J. Weinstein, M. S. Holland, K. E. Rogers, and N. S. Barlow, “Analytic
solution of the seir epidemic model via asymptotic approximant,” Physica
D: nonlinear phenomena, vol. 411, p. 132 633, 2020.
A. Ruggieri, S. Anticoli, A. D’Ambrosio, L. Giordani, and M. Viora, “The
influence of sex and gender on immunity, infection and vaccination,” Annali
dell’Istituto superiore di sanita, vol. 52, no. 2, pp. 198–204, 2016.
35
A Appendix
A.1 The SIR model
A.1.1 The SIR model plot
R code to plot SIR model with parameters k = 2, p = 0.9, γ = 0.25, s(0) =
0.9999, and i(0) = 0.0001. The code from Amazon Web Services amazonaws.com, with slight modification.
# Load deSolve package
library(deSolve)
# Create an SIR function
sir <- function(time, state, parameters) {
with(as.list(c(state, parameters)), {
dS <- -beta * S * I
dI <- beta * S * I - gamma * I
dR <gamma * I
return(list(c(dS, dI, dR)))
})
}
# Set parameters
# Proportion in each compartment:
# Susceptible 0.9999,
# Infected 0.0001,
# Recovered 0.0
init
<- c(S = 0.9999, I = 0.0001, R = 0.0)
# beta: infection parameter; gamma: recovery parameter
p =0.9
k= 2
gamma = 0.25
beta = p * k
parameters <- c(beta , gamma)
# Time frame
times_constant_k
<- seq(0, 10, by = 0.0001)
A
# Solve using ode (General Solver for Ordinary Differential Equations)
out_constant_k <- ode(y = init, times = times_constant_k, func = sir,
parms = parameters)
# change to data frame
out_constant_k <- as.data.frame(out_constant_k)
## Delete time variable
out_constant_k$time <- NULL
# Plot
matplot(x = times_constant_k, y = out_constant_k, type = "l",
xlab = "Time", ylab = ’Susceptible and Recovered’,
main = ’SIR Model with k = 2’,
lwd = 1, lty = 1, bty = "l", col = 2:4)
# Add legend
legend(40, 0.7, c("Susceptible", "Infected", "Recovered"), pch = 1,
col = 2:4, bty = "n")
A.1.2 The contact number influence
R code to plot relation between k and s(∞) figure 5.
## Load pracma package to calculate Lambert function
library(pracma)
p = 0.9
gamma <- 0.9
Y <- 1
X <- 1
s0 <- 1-1e-4
j = seq(0, 8 , by = 0.1)
for (k in j) {
beta <- k*p
R0 = beta / gamma
S <- -(lambertWp(-s0 * R0 * exp(-R0)))/R0
Y <- c(Y,S)
X <- c(X, k)
}
X <- X[-1]
Y <- Y[-1]
B
plot(X, Y, type = "l", ylab = "Fraction of never infected individuals",
xlab = "Contact number")
A.1.3 The initial infected individuals value i(0) influence
R code to plot relation between i(0) and s(∞) figure 6.
# Load pracma package to calculate Lambert function
library(pracma)
beta <- 5.4
gamma <- 1
X <- 0
Y <- 1
R0 = beta / gamma
j <- seq(0.001, 0.999, by = 0.0001) # sequence of i(0)
for (h in j) {
S <- -(lambertWp(-(1-h) * R0 * exp(-R0)))/R0
Y <- c(Y,S)
X <- c(X, h)
}
X <- X[-1]
Y <- Y[-1]
Ylog <- log10(Y)
plot(X, Ylog, type = "l", cex = 0.8, pch= 16,
ylab = ’Log of fraction of never infected individuals’,
xlab = ’Initial value of infected fraction’)
A.2 The SIS model
A.2.1 The SIS model plot
R code to generate figure 9 for the SIS model. The code from Amazon Web
Services amazon- aws.com, with slight modification.
library(deSolve)
sis_model = function (current_timepoint,
state_values, parameters){
# create state variables (local variables)
S = state_values [1]
# susceptibles
I = state_values [2]
# infectious
C
with (
as.list (parameters),
# variable names within
# parameters can be used
{
# compute derivatives
dS = (-beta * S * I) + (gamma * I)
dI = ( beta * S * I) - (gamma * I)
# combine results
results = c (dS, dI)
list (results)
}
)
}
contact_rate = 10
# number of contacts per day
transmission_probability = 0.07
# transmission probability
infectious_period = 5
# infectious period
beta_value = contact_rate * transmission_probability
gamma_value = 1 / infectious_period
Ro = beta_value / gamma_value
parameter_list = c (beta = beta_value, gamma = gamma_value)
X = 25000
Y = 7
# susceptible hosts
# infectious hosts
N = X + Y
initial_values = c (S = X/N, I = Y/N)
timepoints = seq (0, 70, by=1)
output = lsoda (initial_values, timepoints,
sis_model, parameter_list)
# susceptible hosts over time
D
plot (S ~ time, data = output, type=’l’,
ylim = c(0,1), col = ’green’,
ylab = ’’, main = ’’)
# remain on same frame
par (new = TRUE)
# infectious hosts over time
plot (I ~ time, data = output, type=’l’,
main = ’Graph for S(0)=25000, and I(0) = 7’,
ylim = c(0,1), col = ’red’,
ylab = ’Percent’, axes = FALSE)
# Add legend
legend(40, 0.7, c("Infected","Susceptible"), pch = 1,
col = 2:4, bty = "n")
# Compare
gamma_value = 1 / infectious_period
Ro1 = beta_value / gamma_value
parameter_list = c (beta = beta_value, gamma = gamma_value)
X = 24900
Y = 107
# susceptible hosts
# infectious hosts
N = X + Y
initial_values = c (S = X/N, I = Y/N)
timepoints = seq (0, 70, by=1)
output = lsoda (initial_values, timepoints, sis_model, parameter_list)
# susceptible hosts over time
plot (S ~ time, data = output, type=’l’, ylim = c(0,1)
E
, col = ’green’, ylab = ’’, main = ’’)
# remain on same frame
par (new = TRUE)
# infectious hosts over time
plot (I ~ time, data = output,
type=’l’, main = "Graph for S(0)=24900, and I(0) = 107",
ylim = c(0,1), col = ’red’, ylab = ’Percent’, axes = FALSE)
## Add legend
legend(40, 0.7, c("Infected","Susceptible"), pch = 1,
col = 2:4, bty = "n")
A.3 The SEIR model
A.3.1 The SEIR model plot
R code to generate figure 12 for SEIR model. The code from Amazon Web Services, with slight modification.
## Load deSolve package
library(deSolve)
seir_model = function (current_timepoint, state_values, parameters)
{
# create state variables (local variables)
S = state_values [1]
# susceptibles
E = state_values [2]
# exposed
I = state_values [3]
# infectious
R = state_values [4]
# removed
with (
as.list (parameters),
# variable names within
# parameters can be used
{
# compute derivatives
dS = (-beta * S * I)
dE = (beta * S * I) - (delta * E)
dI = (delta * E) - (gamma * I)
dR = (gamma * I)
# combine results
results = c (dS, dE, dI, dR)
F
list (results)
}
)
}
contact_rate = 10
transmission_probability = 0.07
infectious_period = 5
latent_period = 2
#
#
#
#
number of contacts per day
transmission probability
infectious period
latent period
beta_value = contact_rate * transmission_probability
gamma_value = 1 / infectious_period
delta_value = 1 / latent_period
Ro = beta_value / gamma_value
parameter_list = c (beta = beta_value,
gamma = gamma_value,
delta = delta_value)
W
X
Y
Z
=
=
=
=
9990
1
0
9
#
#
#
#
susceptible hosts
infectious hosts
removed hosts
exposed hosts
N = W + X + Y + Z
initial_values = c (S = W/N, E = X/N, I = Y/N, R = Z/N)
timepoints = seq (0, 80, by=1)
output = lsoda (initial_values, timepoints, seir_model, parameter_list)
# susceptible hosts over time
plot (S ~ time, data = output,
type=’l’, ylim = c(0,1), col = ’black’,
ylab = ’S, E, I, R’, main = ’SEIR epidemic’)
# remain on the same frame
par (new = TRUE)
G
# exposed hosts over time
plot (E ~ time, data = output,
type=’l’, ylim = c(0,1), col = ’blue’,
ylab = ’’, axes = FALSE)
# remain on the same frame
par (new = TRUE)
# infectious hosts over time
plot (I ~ time, data = output, type=’l’,
ylim = c(0,1), col = ’red’,
ylab = ’’, axes = FALSE)
# remain on the same frame
par (new = TRUE)
# removed hosts over time
plot (R ~ time, data = output, type=’l’,
ylim = c(0,1), col = ’green’,
ylab = ’’, axes = FALSE)
## Add legend
legend(60, 1, c("Susceptible", "Exposed",
"removed", "Infected"),
pch = 1, col = 1:5, bty = "n")
H