Beruflich Dokumente
Kultur Dokumente
Home
Content
Module Map
Glossary
Tools
Help
next
OVERVIEW
The previous session introduced techniques for setting up models describing the
transmission dynamics of infections using difference equations. These use discrete time
steps, such as 1 week, 2 days, etc. to make predictions.
This session discusses some limitations of difference equations and provides an
introduction to differential equations. These are similar to difference equations, but
describe events occurring continuously, rather than at specific time points. We also
introduce a specialist software package (Berkeley Madonna) which we will use to develop
mathematical models.
OBJECTIVES
By the end of this session you should:
Understand the relationship between difference and differential equations;
Understand some limitations of difference equations;
Be able to write the differential equations for simple models describing the
transmission dynamics of an infection;
Understand how differential equations are used to make predictions;
Understand the key input parameters which are used in differential equations;
Be familiar with how models can be set up in Berkeley Madonna.
This session comprises two parts and will take 2-5 hours to complete.
Part 1 (1-2 hours) describes how differential equations are written. Part 2 (1-3 hours)
consists of an exercise in Berkeley Madonna, during which you will set up a model
describing the transmission of measles.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
During the last session we discussed the following model of the transmission dynamics of
measles (an immunising infection) in a closed population .
Figure 1. General structure of a model describing the transmission dynamics of an immunising infection in a
closed population.
Rt+1 = Rt + rI t
where
S t , E t , I t and Rt are the numbers of susceptible, pre-infectious, infectious and
immune (recovered) individuals respectively at time t;
t is the risk that a susceptible individual is newly infected between time t and t+1;
is the proportion of pre-infectious individuals who become infectious between time
t and t+1, and
r is the proportion of infectious individuals who recover (become immune) between
time t and t+1.
The number of individuals in each category at time t+1 can be calculated using the
expression:
the number present in the category at time t
the number who exit the category between time t and t+1
+
the number who enter the category between time t and
t+1.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
These equations were successfully used in MD01 to predict the development of a measles
epidemic. Once births into and deaths out of the population had been included, the model
predicted that regular cycles in the numbers of susceptible and immune individuals would
occur. However, these predictions depend on the size of the time step that is used, as
shown in the outputs of the following exercise.
Click here
Home
Content
Module Map
Glossary
Tools
Help
2.2
prev
next
You should have noticed that model predictions obtained using a 0.5 day time step were
similar to those obtained using a 1 day time step, as shown in Figure 2. However, with a 5
day time step, the model predicted that the numbers of susceptible and immune persons
would not cycle at all over time. To explain these findings, we will now look closely at
model predictions for the time period when the model first starts to predict nonsense
results, which turns out to be between the 50th and 55th day.
Figure 2: Predictions of the number of susceptible and immune individuals obtained with the model using different
time steps.
Home
Content
Module Map
Glossary
Tools
Help
2.2
2.3
prev
next
Susceptible Infectious
50
9.45
24,044
4.22
51
9.14
22,381
3.80
52
9.26
20,735
3.56
53
9.61
19,131
3.41
54
10.11
17,586
3.30
55
10.72
16,114
3.21
We see that on day 50, there are 9.45 susceptible individuals and 24,044 infectious
individuals. Since = 1.86 x 10-5 per day, the number of individuals that are newly infected
by the end of day 50 is 9.45 x 24,044 x 1.86 x 10-5 = 4.22.
By the 55th day, the situation hasn't changed substantially, with 10.72 susceptible
individuals, 16,114 infectious individuals and 3.21 newly infected individuals by the end of
the day.
In this case, the total number of individuals who are newly infected between days 50 and
55 was 18.29 (4.22 + 3.8 + 3.56 + 3.41 + 3.30).
Home
Content
Module Map
Glossary
Tools
Help
2.2
2.3
2.4
prev
next
Susceptible
Infectious
50
50,387
11,530
53,948
55
-3,551
24,265
-8,002
Home
Content
Module Map
Glossary
Tools
Help
2.2
2.3
2.4
2.5
prev
next
Home
Content
Module Map
Glossary
Tools
Help
2.2
2.3
2.4
2.5
2.6
prev
next
Susceptible
Infectious
50.0
13.02
20,402
2.47
50.5
12.51
19,644
2.28
51.0
12.19
18,896
2.14
51.5
12.00
18,161
2.02
52.0
11.94
17,440
1.93
52.5
11.96
16,735
1.86
53.0
12.06
16,046
1.80
53.5
12.22
15,375
1.74
54.0
12.43
14,723
1.70
54.5
12.69
14,089
1.66
55.0
12.98
13,474
1.62
In this instance, 21.22 (= 2.47 + 2.28 + ... + 1.66) individuals are estimated to become
newly infected between days 50 and 55.
In fact, the most precise description of the transmission dynamics of an infection is
obtained using the smallest possible time steps, or, extending this idea further, using time
steps that become vanishingly small. This is equivalent to modelling time flowing
continuously rather than in discrete time steps.
See section 3.2 and Panel 3.1 of the recommended course text 1 for a further discussion
of issues relating to time steps.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
Home
Content
Module Map
Glossary
Tools
Help
prev
next
Home
Content
Module Map
Glossary
Tools
Help
3.2
prev
next
Home
Content
Module Map
Glossary
Tools
Help
3.2
3.3
prev
next
Figure 3. Comparison between the notation used for difference and differential equations. The expressions above
each arrow represent the number of individuals who move from one compartment to the next per unit time.
Home
Content
Module Map
Glossary
Tools
Help
3.2
3.3
3.4
prev
next
The following table summarises the key terms that are used in difference and differential
equations describing the transmission dynamics of an immunising infection.
Difference equations
Differential equations
St
dS(t)
dt
Et
dE(t)
dt
It
dl(t)
dt
Rt
dR(t)
dt
(t)
Home
Content
Module Map
Glossary
Tools
Help
prev
next
The differential equations for the rate of change in the number of individuals in a given
compartment can be obtained either using an intuitive approach, i.e. by considering the
definition of the rate of change in a given quantity, or by using a more formal mathematical
approach.
We first describe the intuitive approach using a model of the transmission dynamics of an
immunising infection (an SEIR model), such as measles, mumps, or rubella, as an
example.
We begin by recalling that differential equations describe the rate of change in a given
quantity relative to something else.
The rate of change in the number of individuals in a given category per unit time is
provided by the difference between the number of individuals entering the category per unit
time and the number of individuals leaving the category per unit time, i.e.:
the number who enter the category per unit time
Home
Content
Module Map
Glossary
Tools
Help
prev
next
From the above diagram we see that as no one enters the susceptible category. The rate
of change in the number of susceptible individuals at time t is given by the expression:
dS(t)
=
dt
As mentioned in MD01 , the number of susceptible individuals who are newly infected
per unit time is given by the product of the force of infection, (t), and the number of
susceptible individuals at time t (i.e. (t)S(t)). The rate of change in the number of
susceptible individuals would therefore be written as:
dS(t)
= (t)S(t)
dt
If we assume that individuals contact each other randomly, then (t) can be replaced by
I(t), where is the rate at which two specific individuals come into effective contact per
unit time and I(t) is the number of infectious individuals at time t (see also MD01 ).
Home
Content
Module Map
Glossary
Tools
Help
4.2
prev
next
Considering the pre-infectious individuals in the above diagram, we can see that newly
infected individuals enter the pre-infectious compartment from the susceptible
compartment, while individuals who have just become infectious exit the pre-infectious
compartment.
The rate of change in the number of pre-infectious individuals over time is given by the
expression:
the number of susceptible
dE(t)
= + individuals who are newly infected
dt
per unit time
The number of pre-infectious individuals who become infectious per unit time is given by
the expression fE(t), where f is the rate at which pre-infectious individuals become
infectious. The expression for the rate of change in the number of pre-infectious individuals
at time t is therefore given by the following:
dE(t)
=+ (t)S(t)- fE(t)
dt
Home
Content
Module Map
Glossary
Tools
Help
4.2
4.3
prev
next
Considering the infectious category, individuals become infectious from the pre-infectious
stage and exit the infectious stage when they recover, as follows:
Individuals enter the immune ("recovered") category from the infectious compartment, as
follows:
Home
Content
Module Map
Glossary
Tools
Help
4.2
4.3
4.4
prev
next
Click the show button to see the original model diagram again.
Show
EXERCISE
Q1.3 Select the missing terms (provided in the drop down menu) to complete the
expressions correctly for the rate of change for the number of infectious and immune
individuals
Choose...
Choose...
Choose...
Choose...
=
Answer
Choose...
Choose...
. Not all terms will be used and each term can only be used once.
Home
Content
Module Map
Glossary
Tools
Help
4.2
4.3
4.4
4.5
prev
next
Click the show button to see the original model diagram again.
Show
EXERCISE
Q1.4 Use your answer to the last question to select the correct notation for the
differential equations describing the rate of change in the number of infectious and immune
individuals (
a) fE(t) - rI(t)
=
b) + rI(t) + fE(t)
c) -rI(t) + fE(t)
c) + rI(t)
d) (t)S(t) + rI(t)
d) + fE(t)
a) - rI(t)
Home
Content
Module Map
Glossary
Tools
Help
4.2
4.3
4.4
4.5
4.6
prev
next
We can now summarise the differential equations for our model of the transmission
dynamics of an immunising infection as follows:
dS(t)
= (t)S(t)
dt
dE(t)
=(t)S(t) - fE(t)
dt
dl(t)
=fE(t) -rl(t)
dt
dR(t)
=rl(t)
dt
You may notice that these equations share strong similarities with those for our difference
equations model, as summarised in Table 1.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
dS(t)
dt
Answer
dC(t)
dt
Answer
dD(t)
dt
Answer
dR(t)
dt
Answer
Home
Content
Module Map
Glossary
Tools
Help
prev
next
We will now illustrate how the differential equations for a model can be obtainedusing
another approach that considers the mathematical definition of the rate of change.
We begin by noting that if we plot how a quantity changes over time, the rate of change in
that quantity at a given time is simply the gradient at that point on the plot. Considering
Figure 4, which shows the number of susceptible individuals over time t (written as S(t)),
the gradient at point C (which has co-ordinates (t, S(t))) is the slope of the line which just
touches the curve at point C.
Figure 4: Illustration of the rate of change of the number of susceptible individuals, S(t), over time.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
Consider another point A a short horizontal distance "t" away from C, with co-ordinates
(t+t, S(t+ t)) . If we draw a line between points A and C on Figure 5 (as indicated by the
orange dashed line), then the slope of this line equals the ratio between the lengths of the
). The slope of line AC, as it is currently drawn, would
lines AB and BC (i.e.
overestimate the gradient at point C.
However, if we were to move point A
closer to point C, reducing t, then the
slope of line AC would eventually equal
the gradient at point C.
This leads to the mathematical definition
of the rate of change in the number of
susceptible individuals, namely as the
value of the expression
as t
becomes infinitesimally small (or tends to
zero).
This is written as:
We will now use this expression to derive an equation for the rate of change in the number
of susceptible individuals.
Note
Home
Content
Module Map
Glossary
Tools
Help
6.2
prev
next
The rate of change in the number of susceptibles over time can be derived using a similar
logic to that which was used previously to derive the difference equations for the number of
susceptible individuals at time t+1.
Applying the logic that we used when writing down the difference equations for the number
of susceptible persons at time t+1 in terms of the number at time t (see MD01 ), we see
that the number of susceptible individuals at time t+t is given by:
the number of
S(t+t) = susceptibles at time t,
S(t)
Equation
1
When the size of the time interval t is sufficiently small, the number of susceptibles who
become infected between time t and t+t equals the number of individuals that are newly
infected per unit time at time t, (t)S(t), multiplied by the size of the time interval t. This is
written as (t)S(t)t. For example, if 10 individuals are infected per day, then you would
expect 10 x 1/24 0.417 individuals to be newly infected per hour.
Substituting the expression (t)S(t)t into Equation 1 gives the following equation for the
number of susceptible individuals at time t+t.
S(t+t) = S(t) (t)S(t)t Equation 2
After subtracting the number of susceptibles at time t, S(t), from both sides of the
equation, we see that:
S(t+t) S(t) = (t)S(t)t Equation 3
We can then divide both sides of the equation by t to obtain:
S(t+t) - S(t)
= (t)S(t) Equation 4
t
Home
Content
Module Map
Glossary
Tools
Help
6.2
6.3
prev
next
Taking t to be "infinitesimally" small, then based on the formal definition of the rate of
change , the left side of the equation is equal to
. Therefore,
dS(t)
dt
S(t+t)S(t)
= (t)S(t)
t
as t 0
Therefore, the rate of change in the number of susceptible individuals at time t is equal to
(minus) the product of the force of infection at time t and the number of susceptibles at
time t, i.e.
dS(t)
= (t)S(t)
dt
Home
Content
Module Map
Glossary
Tools
Help
6.2
6.3
6.4
prev
next
We can use a similar logic to derive the expression for the rate of change in the number of
,
,
).
pre-infectious, infectious and immune individuals (
EXERCISE
Q1.6 Fill in the missing terms (provided in the drop down menus) to complete the
expression correctly for the number of pre-infectious individuals at time t+t. Not all terms
will be used and each term can only be used once. Click here if you would like to remind
yourself of the model diagram.
E(t+t) =
Choose...
Choose...
Choose...
Choose...
Choose...
Choose...
Answer
Home
Content
Module Map
Glossary
Tools
Help
6.2
6.3
6.4
6.5
prev
next
EXERCISE CTD.
As before, when the time interval t is sufficiently small, the number of pre-infectious
individuals who become infectious between time t and t+t is given by fE(t)t.
Q1.7 Use this term and others in the drop down menus to complete the expression for
E(t+t). Note that each term can be used only once. Not all terms will be used.
E(t+t) =
Choose...
Choose...
Choose...
Choose...
Choose...
Choose...
Equation 6
Answer
Home
Content
Module Map
Glossary
Tools
Help
6.2
6.3
6.4
6.5
6.6
prev
next
EXERCISE CTD.
Q1.8 Now, on paper, subtract the number of pre-infectious individuals at time t, E(t), from
both sides of Equation 6 .
Answer
As before, taking t to be infinitesimally small, then the left hand side of the equation is
, leaving us with:
equivalent to
dE(t)
= (t)S(t)E(t)
dt
You should recognise this equation as being identical to the one we obtained on page 16
, i.e. the rate of change in the number of pre-infectious individuals at time t is equal to the
product of the force of infection at time t and the number of susceptibles at time t minus
the number of pre-infectious individuals who become infectious between time t and t+t.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
Once we have written down the differential equations for our model, it is important to check
that they are consistent with our understanding of the system that we are trying to model.
One useful way to check our equations is to draw a model diagram corresponding to the
differential equations.
If the differential equations have been written correctly, the number of terms that make up
the differential equation for a given compartment should equal the number of arrows that
enter or exit the compartment in the model diagram. The direction of the arrow determines
whether the term represented by the arrow has a + or - sign in the differential equation for
the compartment in question.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
For example, since there is a minus sign in front of the term (t)S(t) in the differential
equation for the rate of change in the number of susceptible individuals, the arrow
represented by this term is leaving the susceptible compartment in the model diagram.
Likewise, since there is a + sign in front of the term (t)S(t) in the differential equation for
the rate of change in the number of infectious individuals, the arrow represented by this
term is entering the infectious compartment in the model diagram.
Home
Content
Module Map
Glossary
Tools
Help
7.2
prev
next
EXERCISE
Hookworm is a parasitic infection found frequently in tropical climates that causes
diarrhoea and abdominal pain. Transmission occurs by direct contact with contaminated
soil, primarily by walking barefoot, or through accidental ingestion.
Q1.10 Draw a diagram corresponding to the following differential equations describing the
transmission dynamics of hookworm. Individuals are either susceptible (S(t)), infected (I(t))
or recovered (R(t)).
dS(t) =r l(t)(t)S(t)
1
dt
dl(t) =(t)S(t)r l(t)r l(t)
1
2
dt
dR(t) =r l(t)
2
dt
Answer
Home
Content
Module Map
Glossary
Tools
Help
7.2
7.3
prev
next
EXERCISE
Q1.12 Try to draw a model diagram corresponding to the following equations. What do you
conclude about these equations?
dS(t) =(t)S(t)+r R(t)
s
dt
dl(t) =(t)S(t)r l(t)
r
dt
dR(t) =r l(t)
r
dt
Answer
Home
Content
Module Map
Glossary
Tools
Help
7.2
7.3
7.4
prev
next
EXERCISE CTD.
Q1.13 Think of two ways in which you could correct these equations so that they reflect
movement of individuals through a series of compartments.
dS(t) = (t)S(t)+r R(t)
s
dt
dl(t) = (t)S(t)r l(t)
r
dt
dR(t) =r l(t)
r
dt
Answer
Home
Content
Module Map
Glossary
Tools
Help
prev
next
Adding up the differential equations is useful for confirming that the demographic
assumptions have been incorporated into the model correctly.
For example, below we see the result of adding up the differential equations for the model
described on page 20 . The sum of these differential equations is zero (i.e.
= 0).
Click here to see how the term - (t)S(t) in the
differential equation for S(t) cancels out with the
term (t)S(t) in the equation for
.
Click here to see how the term - fE(t) in the
differential equation for E(t) cancels out with the
term fE(t) in the equation for
.
Click here to see how the term - rI(t) in the
differential equation for I(t) cancels with the term
rI(t) in the equation for
.
Since
size, the result that the sum of these terms equals zero implies that the population in the
model remains unchanged over time. This is consistent with the assumption that we
intended to make, namely that the population is closed.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
EXAMPLE
The following is the possible structure of a model that we might use to track how the
number of susceptible individuals in a cohort changes over time, assuming that they
become infected at a constant rate .
Assuming that no individuals die, the differential equations for this model are:
dS(t)
=S(t)
dt
and
dZ(t)
= S(t)
dt
This model belongs to a special category of models for which the number of individuals in
a given compartment can be expressed in terms of the mathematical constant, e,
approximately equal to 2.718. The definition of e is provided in page 11 of the maths
refresher or the Basic maths section B.3 of the recommended course text 1 .
In this instance, S(t) is given by the expression:
S(t) = S(0)e -t
Equation 1
where S(0) is the number of susceptible individuals in the cohort at the start. Since in this
model no individuals die, the number of individuals at time t who have ever been infected
is given by the difference between the number present at the start, S(0), and the number
susceptible at time t, i.e.
Z(t) = S(0) - S(0)e -t
Equation 2
Home
Content
Module Map
Glossary
Tools
Help
prev
next
For many purposes, difference equations that are set up with small time steps in a
spreadsheet, such as Excel, can be used to produce a reasonable description of the
transmission dynamics of an infection. However, the spreadsheet can become large and
unmanageable if detailed long-term predictions are required (e.g. the number of infections
occurring daily over a period of hundreds of years).
In this situation, it is practical to set up the difference equations using a programming
language such as C, C++, Visual Basic, FORTRAN, etc. Alternatively, one could use a
specialist modelling package such as Berkeley Madonna, ModelMaker, Matlab,
Mathematica, Maple, or R that is designed to manipulate differential equations. Each
package converts the differential equations to difference equations using various
techniques (e.g. Euler, Runge-Kutta, Bulirsch-Stoer, etc.) to correct for possible errors
introduced at each time step. For this reason, differential equations are often preferred to
difference equations.
The practical component of this session introduces Berkeley Madonna, which we will use
throughout the rest of this course. Before describing this package, we first discuss a model
that is frequently encountered in natural sciences and which we will use in later sessions,
for which we do not need to use any software in order to make predictions of the number
of individuals in a given compartment.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
We can check that the equation S(t) = S(0)e -t is consistent with the differential equations
on the last page by differentiating this equation and checking that the resulting equation for
is consistent with the equation that we started with.
If we apply the rules for differentiation (see pages 14-16 of the maths refresher ) to
and then use the mathematical expression for e -t, we obtain the equation:
Equation 1
dS(t)
= S(0)e -t
dt
Equation 3
Since S(t)=S(0)e -t, we obtain our intended result. See the recommended course text,
Appendix A.1.2 1 , for a further elaboration.
Note that if we divide Equations 1 and 2 by the size of the cohort, S(0), we obtain the
following expressions for the proportion of individuals in the cohort that are susceptible or
who have ever been infected, denoted by s(t) and z(t), respectively:
s(t) = e -t
Equation 4
z(t) = 1 - e -t
Equation 5
Home
Content
Module Map
Glossary
Tools
Help
prev
next
The equations described in this session do not account for changes in the age of
individuals, and they do not describe the transmission dynamics of an infection in a
population stratified by age. When susceptible, pre-infectious, infectious and immune
individuals are stratified by age, we also need to account for the fact that the ages of
individuals also changes over time. We could do so using so-called "partial differential
equations".
The equations for our model of the transmission dynamics of an immunising infection
would then be written as follows:
S(a,t) S(a,t)
+
= (t)S(a,t)
a
t
E(a,t) E(a,t)
+
= (t)S(a,t) E(a,t)
a
t
l(a,t) l(a,t)
+
=E(a,t) rl(a,t)
a
t
R(a,t) R(a,t)
+
= rl(a,t)
a
t
The expressions on the left side of the equations denote the fact that the number of
individuals in a given category changes both according to age (a) and over time (t). These
equations are more difficult to solve than ordinary differential equations and generally
require the use of a programming language, since few software packages are designed to
solve them.
An alternative, more straightforward, method of overcoming this problem is to adapt the
model to stratifyindividuals into age groups, rather than including age as a continuous
value. The transmission dynamics within annual birth cohorts, for instance, can be
described using ordinary differential equations. An example of this kind of model is
provided later in the module.
Home
Content
Module Map
Glossary
Tools
Help
prev
The rest of this session (the practical component) is likely to take 1-3 hours.
You may wish to take a short break before starting it.
next
Home
Content
Module Map
Glossary
Tools
Help
prev
next
OVERVIEW
We now begin the practical component (part 2) of this session, in which you will learn how
to set up, run and manipulate a simple model of the transmission of an immunising
infection in Berkeley Madonna.
OBJECTIVES
By the end of this part of the session, you should:
Understand the methods for setting up models using Berkeley Madonna.
Understand the relationship between the different input parameters for the model.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
Home
Content
Module Map
Glossary
Tools
Help
12.2
prev
next
The following diagram shows the flowchart that we would construct in Berkeley Madonna
for a model describing the transmission dynamics of an immunising infection, assuming
that we did not want to account for the time lag between infection and onset of
infectiousness (i.e. an SIR model).
Berkeley Madonna refers to the blue cylinders as "reservoirs", and these represent the
number of individuals in each category (i.e. Susceptible, Infectious or Immune) at a given
time t.
If we were to double click on the Susceptible
reservoir of this model in Berkeley Madonna,
we would see a window which is similar to the
one on the right. This is where we specify the
number of individuals that are susceptible
at the start. In a similar way, we can set the
initial values for the other compartments.
Home
Content
Module Map
Glossary
Tools
Help
12.2
12.3
prev
next
Notice that there are two types of arrows in the flow diagram.
For example, the expression for the number of new infections per unit time is given by:
*Susceptible*Infectious
Therefore, since the numbers of susceptible and infectious individuals are used in this
expression, there are thin arrows going from the susceptible and the infectious
compartments to the new infections arrow.
Home
Content
Module Map
Glossary
Tools
Help
12.2
12.3
12.4
prev
If we were to double click on the circle of the flow arrow labelled "new infections", we
would see the window below. This is where we edit the equations for the number of
individuals who move between categories per unit time.
flow arrows.
next
Home
Content
Module Map
Glossary
Tools
Help
12.2
12.3
12.4
12.5
prev
next
Home
Content
Module Map
Glossary
Tools
Help
12.2
12.3
12.4
12.5
12.6
prev
next
The image on the right shows the same model set up using the equation editor approach.
As you can see, this approach requires far fewer steps to set up a model than the
flowchart editor does. Curly brackets, {}, are used to enclose "comments" that are ignored
by Berkeley Madonna but can be useful for the modeller.
This is called the equations
window.Note the different
components of the window:
1. The differential equations
for the Susceptible, Infectious
and Immune compartments.
2. The initial numbers of
individuals in each
compartment.
3. The flows providing
expressions for the number
of individuals who move from
one category to the next.The
expressions on the right hand
side of the equals sign are
identical to those that go into
the corresponding flow
arrows of the flow diagram.
4. The input parameters.
These equations are identical
to the ones that go into the
globals window of the
flowchart.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
We will now describe both approaches for setting up models in Berkeley Madonna in
detail.
Download the pdf documents from the links below and work through the instructions in
these documents to set up your model using either the flowchart or equation editor
approaches.
Click here for instructions for setting up a model describing the transmission dynamics
of measles using flowcharts.
Click here for instructions for setting up a model describing the transmission dynamics
of measles using the equation editor.
The files mentioned in these pdfs are available from the following drop-down menu:
Show
Home
Content
Module Map
Glossary
Tools
Help
prev
next
You have now had the chance to try at least one approach for setting up models in
Berkeley Madonna. If you have only tried one approach, you can return to the previous
page and try the other approach. Alternatively, you can continue working with the
model that you have set up so far, and return to try the other approach once you have
finished this session.
The next page summarises the advantages and disadvantages of the two approaches for
setting up models.
Home
Content
Module Map
Glossary
Tools
Help
13.2
prev
next
The flowchart editor provides a way of setting up models without worrying too much about
the equations. Models set up using this approach provide a visual summary of the
equations and the ways that the components are linked. A disadvantage to this approach
is that a model requires many different elements to be generated - reservoirs, flow arrows,
arc arrows, globals - before it can be used. Furthermore, the differential equations cannot
be edited directly - they must be modified in the flow arrows and the globals window.
If you have already set up the model using the flowchart but would prefer to work with
differential equations instead, you can " discard the flowchart ". Once discarded, the
flowchart is irrecoverable, and the model can only be further developed using the equation
editor.
The equation editor allows you to work with the differential equations. The equations can
be typed directly into the equations window(orwritten in any word processing software or
text editor and then copied and pasted into the equations window). All the information
defining the model - the differential equations, the initial conditions, and the parameters - is
contained within a single text file. However, no model diagram is provided with this
method.
The method that you should use depends on your personal preference - some people
prefer to visualise their model and are happiest using the flowchart, whereas others prefer
to work directly with the equations. For transparency, speed of use, and ease of editing,
we recommend the equation editor.
Remember that either approach will provide the same results, and using both methods can
be helpful, as you can then check the predictions from one approach against those from
the other. In any case, whatever approach you choose, you should always check your
model carefully and make sure that you understand and agree with the equations.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
We are now ready to use our model to make predictions (i.e. "run the model"). There are
several methods for running models (i.e. using the model to predict the numbers of
individuals in different components). These methods are the same irrespective of whether
the model has been set up using the flowchart or the equation editor.
We first illustrate the method for running models using the parameters window. If you have
already closed your models, click measles1 - flowchart_solnd.mmd or measles equations_solnd.mmd to open up files containing the models that you should have
developed by now.
1. Select the "Parameters" option from the main menu and choose the "Parameter
Window" option.
You should see a window that resembles the one below. This window summarises all the
parameters in the model. This allows you to change the values of parameters and settings
for running the model. The different characteristics are highlighted below.
The box next to the "Run" button
shows the method Berkeley Madonna
uses to convert differential equations to
difference equations. For most models,
the default setting is appropriate.
The numbers next to "STARTTIME"
and "STOPTIME" specify the time period
over which the model makes predictions
of the number of individuals in each
compartment. By default the start and
stop times are set to 0 and 10,
respectively. The time units are
determined by the units of the parameters
used in the model equations. If these are
in daily units, then the predictions are also
in daily units.
The number next to "DT" specifies the
time step used by Berkeley Madonna to
solve the difference equations. By default
this is set to 0.02 time units.
The number next to DTOUT , which
indicates the frequency at which output
from the model is plotted or tabulated.
Please see the guide to Berkeley
Madonna for further information.
The remaining rows in this window show
the current values for all the parameters
in the model.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
Home
Content
Module Map
Glossary
Tools
Help
14.2
prev
next
4. To view the numbers of susceptible and immune individuals and the daily number of
new infectious people over time, click on the "Preinfectious" button on the bottom of
this window to remove this plot from the figure and click on the "Immune" and
"new_infectious" buttons.
Time (t) is plotted along the x-axis. You should see a figure which is similar to
one of the following, depending on whether "new_infectious" is plotted along
the right or left y-axis. The axis on which a variable is plotted can be changed
by double clicking in the middle of the figure, selecting the variable from the list
on the right hand side, clicking on it and clicking on the "Right Axis" box.
5. The buttons along the top of this window allow you to change the display. You may
wish to refer back to the guide to Berkeley Madonna guide for further
explanation of these buttons later.
6. Click on the "Legend" button
Home
Content
Module Map
Glossary
Tools
Help
14.2
14.3
prev
If needed, you can check your model against file measles1 flowchart_solne.mmd
measles1 equations_solne.mmd , which contains the model you should have
developed by this point in the practical.
next
or
Q2.1 What do you notice about the daily number of new infectious people? According to
the graph, how long does the epidemic last?
Note: To see the coordinates of a point, click on the "readout"
toolbar. A cross in a circle will appear. If you click anywhere on the figure, the coordinates
of the cross will appear in the upper right hand corner of the window next to the toolbar.
The readout function has some potentially confusing properties.
Answer
Home
Content
Module Map
Glossary
Tools
Help
14.2
14.3
14.4
prev
next
both runs simultaneously. To see only the most recent run, deselect the overlay button and
run the model.
Answer
Home
Content
Module Map
Glossary
Tools
Help
14.2
14.3
14.4
14.5
prev
next
The effect of modifying parameter values can also be explored using "sliders", as follows:
8. Select the parameters option from the main menu and choose the "Define Sliders"
option. This will open up the "Sliders" window.
9. Select preinfectious_period from the list of parameters on the left by double-clicking
on it. Specify that it should range between a minimum of 0 and a maximum of 20
days, using increments of 0.2. Click OK to continue.
You should now see the following slider:
You can change the value of the parameter by clicking on the bar, holding down the left
mouse button and dragging the bar from side to side. You can also change the value by
selecting the bar and using the left and right arrow keys on the keyboard.
Q2.3 What happens to the size of the epidemic (as reflected in the number of immune
people at the end) as the pre-infectious period increases? What happens if it decreases?
Note on changing parameters: Parameters must always be changed using either the
sliders or in the parameters window. Unfortunately, changes to parameter values in either
the globals window (flowchart version) or in the equation editor are not always recognised.
Answer
Home
Content
Module Map
Glossary
Tools
Help
14.2
14.3
14.4
14.5
14.6
prev
next
10. Before continuing, return to the Parameters window and reset any parameters you
have changed (apart from the STOPTIME) to their initial value (i.e.
preinfectious_period = 8, infectious_period = 7, R0 = 13) by clicking on the parameter
and then clicking the Reset button. Any parameter that has changed since it was
initially set in the model has an asterisk to the left of its value in the parameter list.
Please save your Berkeley Madonna file before continuing.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
We will now use the model to make long-term predictions (e.g. spanning decades). To do
this, we need to incorporate births into and deaths out of the population. The following
shows the final output that we should achieve after doing so.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
We will begin by thinking about the equations for the numbers of births into and deaths out
of the population. Use pen and paper for now.
1. Write down the expression for the number of births into the population per unit time,
in terms of the per capita birth rate per unit time (b_rate) and total_popn.
Answer
2. The daily mortality rate depends on the life-expectancy. Write down the expression
for the daily mortality rate (m_rate) given a life expectancy of 70 years, in terms of
the average life expectancy in years (life_expectancy_yrs).
Answer
3. Write down the expressions for the number of susceptible, pre-infectious, infectious
and immune individuals who die per day using the daily mortality rate.
Answer
Home
Content
Module Map
Glossary
Tools
Help
15.2
prev
Q2.4 Considering the following flowchart, what arrows would we need to add to the
diagram to reflect:
a) individuals being born into the population (ignoring the effects of maternal
immunity for now); and
b) susceptible, pre-infectious, infectious and immune people dying?
Answer
next
Home
Content
Module Map
Glossary
Tools
Help
15.2
15.3
prev
next
The following are the differential equations for our model without accounting for births and
deaths:
dS(t)
= (t)S(t)
dt
dE(t)
=(t)S(t) E(t)
dt
dl(t)
= E(t) rl(t)
dt
dR(t)
= rl(t)
dt
4. Change these equations using the expressions on page 58
deaths.
Answer
Home
Content
Module Map
Glossary
Tools
Help
15.2
15.3
15.4
prev
next
We will now incorporate births and deaths in our Berkeley Madonna models. If you wish to
make these changes yourself, click on the corresponding link below.
Click here
Click here
for instructions for updating the model using the flowchart editor.
for instructions for updating the model using the equation editor.
Alternatively, you can use the final models, in which these changes have already been
made.
Click here to link to the final model set up using the flowchart editor.
Click here to link to the final model set up using the equation editor.
The files mentioned in these pdfs are available from the following drop-down menu:
Show
Home
Content
Module Map
Glossary
Tools
Help
15.2
15.3
15.4
15.5
prev
next
The revised flowchart should resemble the following after including births and deaths in the
population:
If you used the equation editor method, the final model should be similar to that shown
below. The order of the parameters and equations may differ in your model - this is not a
problem.
Home
Content
Module Map
Glossary
Tools
Help
15.2
15.3
15.4
15.5
15.6
prev
next
Home
Content
Module Map
Glossary
Tools
Help
15.2
15.3
15.4
15.5
15.6
15.7
prev
next
or measles1 equations_solni_mmd
if
Q2.5 How do the general patterns in the numbers of susceptibles and immune individuals
differ from those predicted using the difference equations model in Excel during the
last practical?
Answer
Home
Content
Module Map
Glossary
Tools
Help
15.1
15.8
15.2
15.3
15.4
15.5
15.6
15.7
prev
next
You should notice that while the number of new infectious persons and the numbers of
susceptible and immune individuals oscillate over time, these oscillations become smaller
and eventually appear to disappear entirely. This pattern is not completely realistic. In
many populations without measles vaccination, epidemics occur every two years. This
discrepancy between the model's predictions and the observed data suggests that other
factors help sustain the epidemic cycles.
Q2.6 What other factors might influence the regular epidemic cycles?
Answer
If you have set up a model using only one of the two approaches for setting up models in
Berkeley Madonna, return to page 47 and set up the model using the other approach.
The next session will explore the factors determining these cycles in more detail. Please
save your model before closing Berkeley Madonna.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
This session has discussed some limitations of difference equations and has explored how
we can use differential equations to describe the transmission dynamics of infections.
1. Differential equations assume that individuals move between categories continuously
(i.e. from the susceptible to the pre-infectious category), rather than at discrete time
intervals.
2. The expressions for differential equations can be obtained by considering how many
individuals move into and out of each compartment per unit time or by using the
mathematical definition of the rate of change.
3. The notation used to write differential equations differs from that used to write
difference equations. For example, if we are considering events occurring
continuously (as we would when using differential equations), the number of
susceptible individuals at time t would be written using the notation S(t). If we are
considering events occurring at discrete time intervals (as we would when using
difference equations), the number of susceptible individuals at time t would be
written using the notation S t.
Home
Content
Module Map
Glossary
Tools
Help
16.1: Summary
page 67 of 71 16.1
prev
next
4. The following diagram and equations show the notation used to write differential
equations describing the transmission dynamics of an immunising infection:
dS(t)
= (t)S(t)
dt
dE(t)
=(t)S(t) - fE(t)
dt
dl(t)
=fE(t) -rl(t)
dt
dR(t)
=rl(t)
dt
where
S(t), E(t), I(t) and R(t) are the numbers of susceptible, pre-infectious, infectious
and immune (recovered) individuals at time t.
(t) is the rate at which susceptible individuals are infected per unit time (i.e.
the force of infection).
f is the rate at which pre-infectious individuals become infectious (and equal to
1/average pre-infectious period).
r is the rate at which infectious individuals recover from being infectious to
become immune (and equal to 1/infectious period).
Home
Content
Module Map
Glossary
Tools
Help
16.2: Summary
page 68 of 71 16.1
16.2
prev
next
whereby a
Home
Content
Module Map
Glossary
Tools
Help
16.3: Summary
page 69 of 71 16.1
16.2
16.3
prev
next
8. Models can be set up using the flowchart or the equation editor in Berkeley
Madonna.
9. Models can be set up using the flowchart without worrying too much about the
equations. The flowchart gives a visual summary of the equations and the links
between the components; however the differential equations cannot be edited
directly in the model - they must be modified in the flow arrows and the globals
window.
10. Models set up using the equation editor allow you to work directly with the differential
equations. The equations can be written in any word processing software or text
editor and then copied and pasted to the equations window. However, no visual
representation of the model is provided using this method.
11. Although we recommend the equation editor, both approaches provide the same
results. Familiarity with both methods can be helpful, as you can check the outputs
of a model set up using one approach against one set up using the other approach.
Home
Content
Module Map
Glossary
Tools
Help
prev
next
Chapter 3 of the recommended course text 1 , discusses the aspects covered in this
session in further detail.
You will also find it helpful to try the exercises at the end of that chapter, together with the
online exercises that are associated with the chapter (available at
www.anintroductiontoinfectiousdiseasemodelling.com ).
Home
Content
Module Map
Glossary
Tools
Help
References
page 71 of 71
prev