Epidemics Models and Data Using R Premium Ebook Download
Epidemics Models and Data Using R Premium Ebook Download
Visit the link below to download the full version of this book:
[Link]
vii
viii Preface
work. Working with distributed-delay models has been a collaboration with Bill Nel-
son and my students Lindsay Beck-Johnson and Megan Greischar. Angie Luis and I
cooked up the R code to do transfer functions as part of her PhD research. Much of
the code on the catalytic model is from collaborations with Laura Pomeroy and then
CIDD postdoctoral fellows Grainne Long and Jess Metcalf. The in-host TSIR was
also a collaboration with Jess. The Gillespie code arose from collaborations with
postdoctoral fellow Shouli Li and my honor student Reilly Mummah. Reilly also
taught me how to write my first Shiny app. Away from Penn State, Aaron King
and Ben Bolker have at various times been unbelievably patient in teaching me
bits of maths I did not understand. Roger Nisbet painstakingly guided me through
my first transfer functions during my postdoctoral fellowship at NCEAS. During
the same period, Jordi Bascompte introduced me to coupled map lattice models.
Finally, Bryan Grenfell showed me wavelets and introduced me to the field of infec-
tious disease dynamics some 20 years ago.
The data used has been kindly shared by Janis Antonovics, Jeremy Burdon, Re-
becca Grais, Sylvije Huygen, Jenn Keslow, Sandy Leibhold, Grainne Long, and
Mary Poss. The first draft of the text was completed while I was on sabbatical at the
University of Western Australia and University of Oslo/the Norwegian Veterinary
Institute during 2017. My work leading up to this text has variously been funded by
the National Science Foundation, the National Institutes of Health, the US Depart-
ment of Agriculture, and the Bill and Melinda Gates Foundation.
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 In-Host Persistence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Patterns of Endemicity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 R ..................................................... 6
1.5 Other Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 SIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1 The SIR Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Numerical Integration of the SIR Model . . . . . . . . . . . . . . . . . . . . 11
2.3 Final Epidemic Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.4 Open Epidemic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.5 Phase Analyses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.6 Stability and Periodicity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.7 Advanced: More Realistic Infectious Periods . . . . . . . . . . . . . . . . 23
2.8 ShinyApp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3 R0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.1 Primacy of R0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.2 Preamble: Rates and Probabilities . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.3 Estimating R0 from a Simple Epidemic . . . . . . . . . . . . . . . . . . . . . 33
3.4 Maximum Likelihood: The Chain-Binomial Model . . . . . . . . . . . 35
3.5 Stochastic Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.6 Further Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.6.1 Influenza A/H1N1 1977 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.6.2 Ebola Sierra Leone 2014–2015 . . . . . . . . . . . . . . . . . . . . . . 43
3.6.3 Ebola DRC 1995 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.7 R0 from S(E)IR Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.8 Other Rules of Thumb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.8.1 Mean Age of Infection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
ix
x Contents
5 Seasonality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
5.1 Environmental Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
5.2 The Seasonally Forced SEIR Model . . . . . . . . . . . . . . . . . . . . . . . . 84
5.3 Seasonality in β . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
5.4 Bifurcation Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
5.5 Stroboscopic Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
5.6 Susceptible Recruitment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
5.7 ShinyApp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
6 Time-Series Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
6.1 Taxonomy of Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
6.2 Time Domain: ACF and ARMA . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
6.2.1 ARMA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
6.3 Frequency Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
6.4 Wavelets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
6.5 Measles in London . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
6.6 Project Tycho . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
6.7 Lomb Periodogram: Whooping Cough . . . . . . . . . . . . . . . . . . . . . . 107
6.8 Triennial Cycles: Philadelphia Measles . . . . . . . . . . . . . . . . . . . . . 108
6.9 Wavelet Reconstruction and Wavelet Filter: Diphtheria . . . . . . . . 111
6.10 Advanced: FFT and Reconstruction . . . . . . . . . . . . . . . . . . . . . . . . 114
10 Exotica . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
10.2 Chaos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
10.3 Local Lyapunov Exponents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
10.4 Coexisting Attractors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
10.5 Repellors/Unstable Manifolds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
10.6 Invasion Orbits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
10.7 Stochastic Resonance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
10.8 Predictability: Empirical Dynamic Modeling . . . . . . . . . . . . . . . . . 203
Appendix: Making a Pomp-Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
14 Parasitoids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
14.1 Parasitoid-Host Dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
14.2 Stability and Resonant Periodicity . . . . . . . . . . . . . . . . . . . . . . . . . 260
14.3 Biological Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
14.4 Larch Bud Moth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
14.5 Host-Parasitoid Metapopulation Dynamics . . . . . . . . . . . . . . . . . . 263
14.6 ShinyApp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Chapter 1
Introduction
1.1 Preamble
1 Though, as reviewed by Dietz and Heesterbeek (2002), the original calculations leading to the
catalytic model was proposed by Daniel Bernoulli in the late eighteenth century.
variation in prevalence, some have predictable seasonal shifts, and others exhibit
violent epidemics that may be regular or irregular in their timing. Models and
“models-with-data” have proved invaluable for understanding and predicting this
diversity, and thence help improve intervention and control. The following chapters
are an attempt at providing some notes for a “field guide” for working with data,
models, and “models-and-data” to understand epidemics and infectious disease dy-
namics in space and time.
Infectious diseases can be classified according to their persistence within the host
and attack rates with respect to age. Some infections result in life-long colonization
of a host because the immune system does not clear them. Such “in-host persistence”
may be because the immune system permits it—as for the many symbionts that are
beneficial to the host (viz. commmensals and mutualists)—or because detrimental
symbionts (viz. pathogens) are able to evade clearance. Examples of “in-host persis-
tent” pathogens are retroviruses such as HIV, latent viruses such as, herpes viruses,
and a number of bacteria such as the causative agents of tuberculosis (Mycobac-
terium tuberculosis) and leprosy (M. leprae).
“Acute” infections, in contrast, result in transient colonization of the host—that
in humans can last for days or months depending on the pathogen—followed by
clearance. The clearance is usually immune-mediated, though some viruses like ca-
nine distemper virus may run out of target cells and some pathogens may have
a programmed life cycle within the host. Some coccidian pathogens within the
genus Eimeria, for example, go through an exact number of replication cycles in
the host (as merozoites) before all pathogen cells are expelled into the environment
(as oocysts). The more common example of transience is due to immune-mediated
clearance. Examples are plentiful and include acute viruses like measles and in-
fluenza, bacteria such as many that causes respiratory disease like bacterial menin-
gitis (e.g., Neisseria meningitidis) or whooping cough (Bordetella pertussis and B.
parapertussis), and protozoans such as those that cause malaria (Plasmodium spp.).
Among the acute infections we further distinguish between those that leave ster-
ilizing immunity following clearance versus those that leave no or short-lived im-
munity. This can happen via a number of mechanisms including variable gene ex-
pression, rapid evolution, co-circulating strain clouds, or other immune evasive ma-
neuvers. N. meningitidis and its congener N. gonorrhoeae (which cause gonorrhea),
for example, are thought to leave little effective immune memory because of the
bacteria’s ability to express a very variable arsenal of surface proteins (e.g., Stern
1.2 In-Host Persistence 3
et al. 1984; Tettelin et al. 2000). Many influenza subtypes, in contrast, render ef-
fective immune memory short-lived because of rapid evolution; high mutation rates
lead to “antigenic drift” and viral recombination during coinfection leads to anti-
genic “shifts.” Plasmodium falciparum is thought to be comprised of a diverse set
of strains with nonoverlapping “antigenic repertoires” (as well as variable antigen
expression) that allows repeat reinfection (e.g., Gupta et al. 1998). A number of
common viral afflictions of children have a somewhat more limited strain diversity
that may allow several reinfection cycles, but the immune system is ultimately able
to cover their antigenic space; Examples include rotavirus (Pitzer et al. 2011) and
the enterovirus-complex that cause hand-foot-and-mouse disease (Takahashi et al.
2016). Finally, many pathogens have various “anti-immune devices.” Respiratory
syncytial virus, for example, uses molecular decoys against neutralizing antibodies
(Bukreyev et al. 2008) and Bordetella pertussis employs the pertussis toxin to, at
least transiently, inhibit recruitment of immune effector cells to sites of infection
(Kirimanjeswara et al. 2005).
Many of the remaining “acute, immunizing pathogens”—the ones that result
in a transient infection followed by life-long sterilizing immunity—are the poster
children of mathematical epidemiology. Notable examples are among the classic
vaccine-preventable viruses like measles, rubella, and smallpox. From a biolog-
ical point of view, the complete failure of immune escape of these pathogens is
somewhat mysterious (Kennedy and Read 2017), but the resulting simple dynam-
ical clockwork is a joy to anyone hoping to apply mathematics to understand the
living world.
From an epidemiological point of view, it is important to make the functional—as
opposed to taxonomical—classification of pathogens because it allows us to under-
stand the differences in age-specific attack rates and contrasting disease dynamics.
The acute, immunizing infections mainly circulate among the young and therefore
comprise the many “childhood” infections because most or all older hosts are im-
mune. From the point of view of the compartmental “SIR-like” formalism (Fig. 1.1),
it is thus natural to divide the host population in S, I, and R compartments and as-
sume a unidirectional flow from susceptible children through immune (“removed”)
adults. In contrast, the prevalence of “in-host persistent” infections will tend to ac-
cumulate with age. With respect to the SIR formalism, it is thus natural to consider
a model with a unidirectional flow from the S class to a terminal I class. The acute
but imperfectly immunizing infections should lead to relatively age-invariant attack
rates, and S → I → S or S → I → R → S flows depending on the duration of immune
protection.
The SIR-like framework predicts how the broad expectation for age-prevalence
curves will be modulated by factors such as age-specific pattern of mixing and
differential mortality between infected and noninfected individuals. Statistical epi-
demiology can thus be used to probe empirical patterns to discover subtleties in the
dynamics of disease transmission that is hard to observe directly.
4 1 Introduction
Birth / loss of
(ii)
immunity
(i)
Susceptible Infected Recovered Susceptible
S I R S
Fig. 1.1 The two bottlenecks for local persistence: (i) the transmission bottleneck for poorly trans-
mitted infections and (ii) the susceptible bottleneck for highly transmissible, acute immunizing (or
lethal) pathogens
1.3 Patterns of Endemicity 5
Fig. 1.2 Persistence of measles against population size for 954 cities and villages in pre-
vaccination England and Wales (1944–1964). Communities below 500k exhibited occasional or
frequent (depending on size) local extinction of the virus
The locally persistent infections can be classified as: (1) Stable endemics that
show little variation in incidence through time. Many STDs with SI and SIS-like
dynamics like gonorrhea (Fig. 1.3a) and HIV exhibit this pattern. (2) Seasonal en-
demics that show low’ish-level predictable seasonal variation around some mean.
Many endemic vector-borne and water-borne infections exhibit this pattern. A clas-
sic example is the seasonal two-peaked mortality rate from Cholera in the province
6 1 Introduction
of Dacca, East Bengal (King et al. 2008); The first peak at the beginning of the mon-
soon season and the second towards the end (Fig. 1.3b). Finally, (3) recurrent epi-
demics that may be regular or irregular are characterized by violent epidemic fluc-
tuations over time. Many acute, immunizing highly contagious pathogens—measles
being the poster-child—follow this pattern (Fig. 1.4).
100 120
1500
80
1000
Cases
Deaths
60
40
500
20
0
0
1.4 R
To provide a cohesive framework for the practical calculations, all analyses are done
in the open-source R-program. The text is written assuming a basic knowledge of
this platform. All functions, data, and ShinyApp’s discussed in the text are contained
in the epimdr-package. With the package everything contained herein should be
reproducible. The above Figs. 1.2 and 1.4 were for example generated using the
following code:
#Fig 1.2
data(ccs)
plot(ccs$size, ccs$ext*100, log="x", xlab=
"Community size", ylab="Percent
of time extinct")
#Fig 1.3a
plot(magono$time, magono$number, ylab="Cases",
xlab="Year")
lines(lowess(x=magono$time, y=magono$number, f=.4))
1.4 R 7
10
2 8
Cases (x 10-3)
1 4
0 0
44 46 48 50 52 54 56 58 44 46 48 50 52 54 56 58
London Baltimore
14 5
12
4
Cases (x 10-3)
10
3
8
6 2
4
1
2
0 0
44 46 48 50 52 54 56 58 44 46 48 50 52 54 56 58
year year
Fig. 1.4 Incidence of measles in various US and UK cities during the pre-vaccination era. The data
represent fortnightly incidence (roughly corresponding to the virus’ serial interval). The vertical
bars mark annual intervals
#Fig 1.3b
data(cholera)
ses=sesdv=rep(NA, 12)
ses[c(7:12, 1:6)]=sapply(split(cholera$Dacca,
cholera$Month), mean, [Link]=TRUE)
sesdv[c(7:12, 1:6)]=sapply(split(cholera$Dacca,
cholera$Month), sd, [Link]=TRUE)/
sqrt(length(split(cholera$Dacca, cholera$Month)))
require(plotrix)
plotCI(x=1:12, y=ses, ui=ses+sesdv, li=ses-
sesdv, xlab="Month", ylab="Deaths")
lines(x=1:12, y=ses)