Está en la página 1de 72

MD02 Basic modelling methods II: an

introduction to differential equations


EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 1: Overview and objectives


page 1 of 71

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 2: Review: Difference Equations


page 2 of 71

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.

This model can be set up using the following difference equations:


S t+1 = S t - t S t
E t+1 = E t + t S t - E t
I t+1
= I t + E t - rI t

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

2.1: Review: Difference equations


page 3 of 71 2.1

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

to link to the measles spreadsheet developed in the last session.

EXERCISE (the answers are on the next page)


1. Change the size of the time step (cell F4) to be 0.5 days.
Q1.1 What happens to the cycles in the numbers of susceptible and immune individuals?
2. Change the size of the time step to be 5 days.
Q1.2 How does this affect the cycles?

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

2.2: Review: Difference equations


page 4 of 71 2.1

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

2.3: Review: Difference equations


page 5 of 71 2.1

2.2

2.3

prev

next

A one day time step


The following table and figure show model predictions of the number of susceptible,
infectious and newly infected individuals predicted by our model using a one day time step
for days 50-55, following the introduction of one infectious person into a completely
susceptible population and incorporating births into and deaths out of the population.

Number of individuals who are:


Day

Susceptible Infectious

Newly infected by the end of the


current time step (St I t )

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).

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

2.4: Review: Difference equations


page 6 of 71 2.1

2.2

2.3

2.4

prev

next

A five day time step


We obtain the following output if we use a five day time step instead of a one day time
step.

Number of individuals who are:


Day

Susceptible

Infectious

Newly infected by the end of the


current time step (S t I t )

50

50,387

11,530

53,948

55

-3,551

24,265

-8,002

On day 50 we have 50,387 susceptible individuals and 11,530 infectious individuals.


In this situation, = 9.29 x 10-5 per 5 days, and the number newly infected between day
50 and 55 is: 9.29 x 10-5 x 50,387 x 11,530 = 53,948 individuals. Because this number is
larger than the number who were initially susceptible on day 50 (50,387), the model
predicts that the number of individuals who are susceptible at the start of day 55 is less
than zero, which is clearly unrealistic.
The number who are newly infected between day 55 and 60 is then predicted to be: 9.29 x
10-5 x 24,265 x -3,551= -8,002 individuals, which is obviously impossible.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

2.5: Review: Difference equations


page 7 of 71 2.1

2.2

2.3

2.4

2.5

prev

next

The effect of the size of the time step


As discussed in MD01 , when we change the step size used in difference equations we
also need to adjust the size of the parameters. For example, if the rate at which two
specific individuals come into effective contact per unit time () is 10-5 per day, the
corresponding value for 2 days is 2 x 10-5 per 2 days, the value for 3 days is 3 x 10-5 per
3 days, etc. It is appropriate to approximate the risk by (rate) x (time period) if the rate and
time period are small, but as we have seen this approximation breaks down once the time
step is too long.
As illustrated in the previous example, we cannot increase the size of the time step
indefinitely simply by multiplying the parameter by the size of the time step, because,
once the time step size becomes too large, the equations start to predict nonsense results.
Instead, we should use the more accurate formula linking rates and risks as found in
theAppendix to session MD01.
For our measles problem, once the time step size reached 5 days, the transmission
parameter became so large that more individuals were predicted to become infected
within some time step than were susceptible at the beginning of the time step. This, in turn
led to predictions of negative numbers of susceptible individuals in the population. At this
point, it becomes sensible either to introduce corrections into the model, so that it does not
predict negative numbers of individuals, or to reduce the size of the time step.
The real problem with difference equation models
The more important issue is that in difference equation models multiple events take place
in each time step, but the risks are not updated until the next time step. For example, as
soon as one new infectious person appears then the force of infection experienced by
each susceptible person should immediately increase.
Updating the model at discrete time intervals introduces inaccuracies into the rates that the
model uses. This problem can be solved by using smaller time steps, in which fewer
events are expected to take place.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

2.6: Review: Difference equations


page 8 of 71 2.1

2.2

2.3

2.4

2.5

2.6

prev

next

A half day time step


As a general rule, the larger the time step used in the difference equations, the greater the
inaccuracy in the model predictions. The following shows the model predictions obtained
using a half day time step.
Number of individuals who are:
Day

Susceptible

Infectious

Newly infected by the end of the


current time step ( S t I t )

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 3: What are differential equations?


page 9 of 71

prev

next

In order to describe the transmission dynamics of an infection whereby individuals move


between compartments continuously, we need to use so-called "differential" rather than
difference equations. Differential equation models can be thought of simply as difference
equation models with extremely small time steps.
An important distinction between difference and differential equations is that differential
equations describe the rate of change of a given quantity relative to something else, i.e.
the rate of change in the number of individuals in each category at time t. Difference
equations describe the total number of individuals in a given category at time t. Either
model can be used to describe how the system changes over time.
To describe the transmission dynamics of an immunising infection such as measles,
mumps, rubella, etc. over time using differential equations, we need to write down the
expressions for the rate of change in the number of susceptible, pre-infectious, infectious
and immune individuals.
The notation used to write down differential equations is distinct from that used to write
down difference equations, as discussed on the next page.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

3.1: Notation for differential equations


page 10 of 71 3.1

prev

next

Notation for the rate of change


To represent the rate of change in the number of susceptible individuals using differential
equations, we use the notation
.
The notation for the rate of change in the number of pre-infectious, infectious and immune
,
and
respectively. We describe the origin of this notation
individuals is
later.
The "t" in parentheses (i.e. "(t)") is included to show explicitly that the numbers of
individuals in the various categories are expected to change over time. However, for
convenience of writing it is often dropped from the notation so that, for example, the rate of
change in the number of infectious individuals would be written as .
Other notation that you might encounter for the rate of change in a given quantity, such as
the number of infectious people, I(t), is (t) (i.e. a capital I with a dot above it) or I'(t).

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

3.2: Notation for differential equations


page 11 of 71 3.1

3.2

prev

next

Denoting dependency on time or other factors


When we use differential equations, the symbol for time "t" is conventionally enclosed in
brackets (t). For example, the numbers of susceptible, pre-infectious, infectious and
immune individuals at exact time t are written as S(t), E(t), I(t) and R(t) when writing
differential equations, but as S t, E t, I t, Rt when writing difference equations.
Similarly, the force of infection would be written as (t) rather than as t.
Sometimes the number of infectious persons (or another compartment in the model)
depends on something other than time, such as age ("a"). In this case, and still
considering the infectious individuals, we would use the notation I(a) for the number of
infectious individuals of age a, and we would want to calculate how I(a) changes with age.
The mathematical notation for this rate of change is
.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

3.3: Notation for differential equations


page 12 of 71 3.1

3.2

3.3

prev

next

Definitions of key parameters


Note that the key parameters used in difference equations ( t, , r) represent the risks or
proportions of individuals who move from one compartment to the next, while the
corresponding parameters in differential equations ((t),, r) describe the rate at which
individuals move between compartments.
Figure 3 compares the notation used for difference and differential equations.
Difference equations model:

Differential equations model:

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

3.4: Notation for differential equations


page 13 of 71 3.1

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

The number of susceptible individuals


at time t.

dS(t)
dt

The rate of change in the number of


susceptible individuals at time t.

Et

The number of pre-infectious individuals


at time t.

dE(t)
dt

The rate of change in the number of


pre-infectious individuals at time t.

It

The number of infectious individuals at


time t.

dl(t)
dt

The rate of change in the number of


infectious individuals at time t.

Rt

The number of recovered (immune)


individuals at time t.

dR(t)
dt

The rate of change in the number of


recovered (immune) individuals at time
t.

The risk of a susceptible individual


becoming infected between time t and
t+1.

(t)

The risk of an individual in the preinfectious category becoming infectious


between time t and t+1.

The rate at which individuals in the preinfectious category become infectious


per unit time.

The risk of an infectious individual


recovering between time t and t+1 to
become immune.

The rate at which infectious individuals


recover (become immune) per unit time.

The rate at which susceptible


individuals become infected per unit
time, at time t.

Note about the time-dependency in the model parameters


In the model that we have discussed so far, only the risk (or rate) at which susceptibles are
infected,(t), depends on time.This is because it is influenced by the number of infectious
individuals in the population, which changes over time.So far, we have assumed that the
rates at which pre-infectious individuals become infectious and infectious individuals
recover to become immune are constant over time and so we do not need to include a
subscript t or (t) for the parameters f and r. However, these parameters could change
over time in some cases, for example because of an intervention. In this instance, we
would indicate the time-dependency in the rate at which pre-infectious individuals become
infectious and infectious individuals recover using the notation f(t) and r(t) respectively.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 4: Writing down differential equations: intuitive


explanation
page 14 of 71

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

the number who exit the category per unit time

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

4.1: The rate of change in the number of susceptible


individuals
page 15 of 71 4.1

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

The number of susceptible individuals who are newly


infected (or become pre-infectious) per unit time

Note about minus sign

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 ).

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

4.2: The rate of change in the number of pre-infectious


individuals
page 16 of 71 4.1

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

Note about the plus sign

the number of pre-infectious


individuals who become infectious per
unit time

Note about the minus sign

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

4.3: The rate of change in the number of infectious and


immune individuals
page 17 of 71 4.1

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:

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

4.4: Exercise: The rate of change in the number of infectious


and immune individuals
page 18 of 71 4.1

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

4.5: Exercise: The rate of change in the number of infectious


and immune individuals
page 19 of 71 4.1

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 (

). Note that more than one answer may be correct.

a) fE(t) - rI(t)
=

b) (t)S(t) + 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)

Check your answer

a) - rI(t)

Check your answer

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

4.6: Summary: differential equations describing the


transmission dynamics of an immunising infection in a closed
population
page 20 of 71 4.1

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 5: Exercise: Differential equations for the


transmission dynamics of Haemophilus influenzae type B
page 21 of 71

prev

next

The following is a greatly simplified diagram describing the transmission dynamics of


Haemophilus Influenzae type B. The letters above the arrows represent the rate at which
individuals move between the compartments which are linked by the arrows, per unit time.
Q1.5 Using pen and paper, write down the differential equations for this model.

dS(t)
dt

Answer

dC(t)
dt

Answer

dD(t)
dt

Answer

dR(t)
dt

Answer

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 6: Differential equations: Mathematical derivation


page 22 of 71

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.

Recall that the gradient of


a line is the ratio between
the amount by which the
line goes up vertically
and the amount by which
the line goes across
horizontally.

Figure 4: Illustration of the rate of change of the number of susceptible individuals, S(t), over time.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

6.1: Differential equations: Mathematical derivation


page 23 of 71 6.1

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:

Figure 5: Illustration of the rate of change of the number


of susceptible individuals S(t) over time.

We will now use this expression to derive an equation for the rate of change in the number
of susceptible individuals.
Note

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

6.2: Differential equations: Mathematical derivation


page 24 of 71 6.1

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)

the number who became


infected between time t and t+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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

6.3: Differential equations: Mathematical derivation


page 25 of 71 6.1

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

6.4: Differential equations: Mathematical derivation


page 26 of 71 6.1

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

6.5: Differential equations: Mathematical derivation


page 27 of 71 6.1

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

6.6: Differential equations: Mathematical derivation


page 28 of 71 6.1

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

Q1.9 Divide both sides of the equation by t.


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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 7: Methods for checking differential equations: 1.


Drawing model diagrams
page 29 of 71

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

7.1: Methods for checking differential equations: 1. Drawing


model diagrams
page 30 of 71 7.1

prev

next

EXAMPLE: SEXUALLY TRANSMITTED INFECTIONS


The following are differential equations for a model describing the transmission dynamics
of a non-immunising sexually transmitted infection (STI), such as gonorrhoea. STI models
will be discussed further in session MD08 .
dS(t) = (t)S(t)+r l(t)
s
dt
dl(t) = r l(t)+(t)S(t)
s
dt
Below is the diagram corresponding to these equations. Note that the symbols used for the
parameters are arbitrary - we chose to use the notation rs rather than r in this model to
reflect the fact that infectious individuals return to the susceptible compartment once
recovered.
As there are two equations, there are two compartments in this model. As each equation
has two terms (one preceded by a minus sign and the other preceded by a plus sign),
each compartment has one arrow exiting and one arrow entering it. The direction of the
arrow matches the sign preceding the term.

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

7.2: Methods for checking differential equations: 1. Drawing


model diagrams
page 31 of 71 7.1

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

Q1.11 What do you conclude about what happens to infected individuals?


Answer

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

7.3: Exercise: Drawing model diagrams


page 32 of 71 7.1

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

7.4: Exercise: Drawing model diagrams


page 33 of 71 7.1

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 8: Methods for checking differential equations: Check


for population size
page 34 of 71

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

represents the rate of change of the total population

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 10: How to solve differential equations


page 36 of 71

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 9: How to use differential equations to make


predictions
page 35 of 71

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

10.1: How to solve differential equations


page 37 of 71 10.1

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

We will be using these equations repeatedly in MD04.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Optional: Partial differential equations


page 38 of 71

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 11: Break...


page 39 of 71

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 12: Berkeley Madonna practical


page 40 of 71

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

12.1: Introduction to Berkeley Madonna


page 41 of 71 12.1

prev

next

Berkeley Madonna is a specialist model-building package that is designed to deal with


differential equations. Models can be built using either a flowchart or an equation editor.
The flowchart approach involves drawing a flowchart of the model and provides a quick
way of setting up models while minimising the use of equations. Models built using the
flowchart provide a visual summary of all the equations and how the components are
linked together.
The equation editor requires users to type in the differential equations directly.
Both methods produce identical results, and it is useful to understand both. That way, if
one model gives unexpected results, it can be checked against a model built using the
other approach.
While either method can be used, many people find the flowchart editor to be fiddly to set
up and hard to edit. The equation editor is easier to work with and more transparent, and
is the approach we recommend.
The practical exercises in this module are set up using both methods, and you will usually
be able to choose which approach to use.

Pages 42-46 provide an overview of the two approaches. You


are NOT expected to set up the model whilst you are reading
these pages. You will get the chance to set up the model when
you reach page 47.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

12.2: Introduction to Berkeley Madonna: Flowchart approach


page 42 of 71 12.1

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

12.3: Introduction to Berkeley Madonna: Flowchart approach


page 43 of 71 12.1

12.2

12.3

prev

next

Notice that there are two types of arrows in the flow diagram.

The flow arrow with the circle in


contains the
the middle
expression for the number of
individuals who move from one
category to the next.

The thin arc arrows


tell Berkeley
Madonna which components
in the model are used in the
expression.

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

12.4: Introduction to Berkeley Madonna: Flowchart approach


page 44 of 71 12.1

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.

These boxes list terms


which can be used in
the expressions for the

flow arrows.

This box contains the actual expression


for the number of individuals who move
from one category to the next per unit
time, or, in this case, the number of new
infections.

next

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

12.5: Introduction to Berkeley Madonna: Flowchart approach


page 45 of 71 12.1

12.2

12.3

12.4

12.5

This is the toolbar of the flowchart window. If


we were to click on the "globals" button on the
right side of the toolbar we would see the
window to the right. This is where we set up
the input parameters in our model.
Note that there is a space on either side of the
equals sign in these equations in this window.
Berkeley Madonna requires these spaces to be
inserted as otherwise, the equations are
ignored.

prev

next

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

12.6: Introduction to Berkeley Madonna: Equation editor


approach
page 46 of 71 12.1

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 13: Setting up models in Berkeley Madonna


page 47 of 71

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

13.1: Setting up models in Berkeley Madonna


page 48 of 71 13.1

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

13.2: Setting up models in Berkeley Madonna: the advantages


and disadvantages of the two approaches
page 49 of 71 13.1

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 14: Running the model


page 50 of 71

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

14.1: Running the model


page 51 of 71 14.1

prev

next

We will now run the model for 150 days.


2. Click on the STOPTIME line and then change it to equal 150 by typing in 150 in the
box alongside the Reset button. Do not press the reset button, as this will reset the
value of STOPTIME back to 10. Note that since our parameters are in daily units, the
STOPTIME is also in daily units.
3. Now click on the Run button. This opens up a window showing predictions of the
numbers of susceptible and pre-infectious individuals in the population over time.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

14.2: Running the model


page 52 of 71 14.1

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

to see the legend.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

14.3: Running the model


page 53 of 71 14.1

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"

button on the graph

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

14.4: Running the model


page 54 of 71 14.1

14.2

14.3

14.4

prev

next

Parameter values can also be changed in the parameters window.


7. Open the parameter window, select the pre-infectious period, change it to 5 days
(rather than 8 days) and run the model.
Q2.2 How does this change affect the graph of the number of susceptible, immune and
daily number of new infectious people?
Note: Click on the overlay button

on the graph toolbar before running the model to see

both runs simultaneously. To see only the most recent run, deselect the overlay button and
run the model.
Answer

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

14.5: Running the model


page 55 of 71 14.1

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

14.6: Running the model


page 56 of 71 14.1

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 15: Incorporating births and deaths


page 57 of 71

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

15.1: Incorporating births and deaths


page 58 of 71 15.1

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

15.2: Incorporating births and deaths


page 59 of 71 15.1

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

15.3: Incorporating births and deaths


page 60 of 71 15.1

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

to deal with births and

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

15.4: Incorporating births and deaths


page 61 of 71 15.1

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

15.5: Incorporating births and deaths


page 62 of 71 15.1

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

15.6: Incorporating births and deaths


page 63 of 71 15.1

15.2

15.3

15.4

15.5

15.6

prev

next

We will now run the model.


5. Open the parameters window and change the STOPTIME to 36500 (i.e. the model
will make predictions for 365*100 days = 100 years) and click on the Run button.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

15.7: Incorporating births and deaths


page 64 of 71 15.1

15.2

15.3

15.4

15.5

15.6

15.7

prev

next

Your resulting diagram should resemble the following (depending on whether


new_infectious is plotted on the right or left y-axis).
Refer to measles1 flowchart_solni_mmd
you wish to check your model.

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

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

15.8: Incorporating births and deaths


page 65 of 71

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 16: Summary


page 66 of 71

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

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).

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

16.2: Summary
page 68 of 71 16.1

16.2

prev

next

5. Several software packages can be used to manipulate differential equations and


generate predictions. Predictions obtained from these packages will be similar to
those obtained using difference equations with very small time steps.
6. For the following simple model,

whereby a

cohort of susceptible individuals become infected at a constant rate, , the number


of susceptible individuals at time t is given by the expression S(t)=S(0)e -t, where
S(0) is the size of the cohort at the start.
7. The practical part of this session has illustrated how Berkeley Madonna can be used
to set up models describing the transmission dynamics of an immunising infection
(measles) using differential equations.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

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.

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

Section 17: Further reading and exercises


page 70 of 71

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 ).

MD02 Basic modelling methods II: an


introduction to differential equations
EPM302 Modelling and the Dynamics of Infectious Diseases

Home

Content

Module Map

Glossary

Tools

Help

References
page 71 of 71

prev

1. Vynnycky E, White RG. An introduction to infectious disease modelling. Oxford


University Press, Oxford. 2010
2. Anderson, R.M. and R.M. May, Infectious diseases of humans. Dynamics and control.
1991, Oxford University Press, Oxford.

También podría gustarte