forked from bristolmathmodellers/biddmodellingcourse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
solutions-two.html
325 lines (303 loc) · 18.3 KB
/
solutions-two.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Solutions 2: Exploring Compartmental Model Dynamics • BIDD Modelling Course</title>
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/lumen/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/all.min.css" integrity="sha256-nAmazAk6vS34Xqo0BSrTb+abbtFlgsFK7NKSi6o7Y78=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/v4-shims.min.css" integrity="sha256-6qHlizsOWFskGlwVOKuns+D1nB6ssZrHQrNj1wGplHc=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- sticky kit --><script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><meta property="og:title" content="Solutions 2: Exploring Compartmental Model Dynamics">
<meta property="og:description" content="">
<meta name="twitter:card" content="summary">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-article">
<header><div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">BIDD Modelling Course</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.0.0</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">Home</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Practicals
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/practical-one.html">Practical 1 - Designing a Model</a>
</li>
<li>
<a href="../articles/practical-two.html">Practical 2 - Exloring Compartmental Model Dynamics</a>
</li>
<li>
<a href="../articles/practical-three.html">Practical 3 - Compartmental Models to Equations</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Solutions
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/solutions-one.html">Solutions 1 - Designing a Model</a>
</li>
<li>
<a href="../articles/solutions-two.html">Solutions 2 - Exloring Compartmental Model Dynamics</a>
</li>
<li>
<a href="../articles/solutions-three.html">Solutions 3 - Compartmental Models to Equations</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Fact Sheets
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/tb-fact-sheet.html">Tuberculosis</a>
</li>
</ul>
</li>
<li>
<a href="http://www.seabbs.co.uk/shiny/exploreidmodels/">Explore ID Models Interactively</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="../reference/index.html">
<span class="fa fa-file-code-o"></span>
Functions
</a>
</li>
<li>
<a href="https://github.com/bristolmathmodellers/biddmodellingcourse/">
<span class="fa fa-github fa-lg"></span>
Github
</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container -->
</div>
<!--/.navbar -->
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1>Solutions 2: Exploring Compartmental Model Dynamics</h1>
<h4 class="author">Sam Abbott</h4>
<small class="dont-index">Source: <a href="https://github.com/bristolmathmodellers/biddmodellingcourse/blob/master/vignettes/solutions-two.Rmd"><code>vignettes/solutions-two.Rmd</code></a></small>
<div class="hidden name"><code>solutions-two.Rmd</code></div>
</div>
<div id="learning-objectives" class="section level1">
<h1 class="hasAnchor">
<a href="#learning-objectives" class="anchor"></a>Learning Objectives</h1>
<ol style="list-style-type: decimal">
<li>Understand how changing parameter values, and model structure, can influence model dynamics.</li>
<li>Understand the dynamics of the SEIR model in detail.</li>
<li>Understand the impact of risk group stratification on model dynamics.</li>
<li>Understand some of the complex dynamics produced by a more realistic model.</li>
</ol>
</div>
<div id="outline-for-session" class="section level1">
<h1 class="hasAnchor">
<a href="#outline-for-session" class="anchor"></a>Outline for Session</h1>
<ol style="list-style-type: decimal">
<li>Set up (5 minutes)</li>
<li>Investigate the dynamics of a simple SEIR model (10 minutes)</li>
<li>Explore the impact of adding high and low risk latency to a SEIR model, in comparison to the SEIR model (10 minutes).</li>
<li>Investigate the complex dynamics of a more realistic SHLIR model (10 minutes) .</li>
<li>Explore the parameter space of multiple models and try to understand some of the general implications of model structures on dynamics (20 minutes).</li>
<li>Session wrap up (5 minutes)</li>
</ol>
</div>
<div id="solutions" class="section level1">
<h1 class="hasAnchor">
<a href="#solutions" class="anchor"></a>Solutions</h1>
<p>The practical solutions are in <strong>bold</strong>, all code has been completed and the exercise models have been simmulated and summarised.</p>
</div>
<div id="set-up" class="section level1">
<h1 class="hasAnchor">
<a href="#set-up" class="anchor"></a>Set up</h1>
<p>In order to more systematically explore the parameter space of multiple models we have provided an interactive interface. Start the interactive interface by running the following in <code>R</code>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="cf">if</span> (<span class="op">!</span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(shiny, <span class="dt">logical.return =</span> <span class="ot">TRUE</span>)) {
<span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/install.packages">install.packages</a></span>(<span class="st">"shiny"</span>)
<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(shiny)
}
shiny<span class="op">::</span><span class="kw"><a href="https://www.rdocumentation.org/packages/shiny/topics/runUrl">runGitHub</a></span>(<span class="st">"exploreidmodels"</span>, <span class="st">"seabbs"</span>)</code></pre></div>
<p>If having problems running the application then talk to an instructor and/or try the hosted web version (<a href="http://seabbs.co.uk/shiny/exploreidmodels/" class="uri">http://seabbs.co.uk/shiny/exploreidmodels/</a>).</p>
<p>Use this interface to explore the some of the model that have already been discussed and to answer the following ec. Instructions for using the interactive interface can be found in the about section of the application.</p>
</div>
<div id="exercises" class="section level1">
<h1 class="hasAnchor">
<a href="#exercises" class="anchor"></a>Exercises</h1>
<div id="a-simple-seir-model-of-tuberculosis-tb" class="section level2">
<h2 class="hasAnchor">
<a href="#a-simple-seir-model-of-tuberculosis-tb" class="anchor"></a>1. A Simple SEIR Model of Tuberculosis (TB)</h2>
<p>As a first exercise, we are going to explore the simple SEIR model, as seen in the design a model practical, in R. For reference the SEIR model flow diagram seen in the first practical’s solutions.<span class="citation">[1]</span> The equations below are a translation of this into <code>R</code> code.</p>
<div class="figure">
<img src="resources/SEIR_flow_diag.png" alt="Figure 1: An SEIR model of TB transmission, including simple demographic processes"><p class="caption">Figure 1: An SEIR model of TB transmission, including simple demographic processes</p>
</div>
<div id="explore" class="section level3">
<h3 class="hasAnchor">
<a href="#explore" class="anchor"></a>Explore</h3>
<p>Model dynamics are parameter dependent. Even in a simplistic model like the one outlined above parameter values can greatly alter the dynamics. Answer the following questions by varying the parameters and rerunning the model.</p>
<ol style="list-style-type: decimal">
<li>
<p>What is the impact of adding demographic processes (births and deaths)?</p>
<ul>
<li><strong>Without demograpic processes Tuberculosis eventually dies out. The addition of demographic processes results in a continous supply of susceptibles that makes this less likely to happen. However if the disease is sufficiently infectious and has a short serial interval then even with demographic processes the supply of new susceptibles may run out, resulting in the disease dieing out.</strong></li>
</ul>
</li>
<li>
<p>What happens when the transmission rate (beta) is reduced to 0.5?</p>
<ul>
<li><strong>When the transmission rate is reduced to 0.5 Tuberculosis will die out without spreading any further than the index case. This is because the basic reproduction number is below 1 for this set of parameters.</strong></li>
</ul>
</li>
<li>
<p>What happens as the rate of recovery is increased?</p>
<ul>
<li><strong>As the rate of recovery is increased the size of the epidemic peak is decreased and the duration of the epidemic increases. The cumulative number of cases is reduced.</strong></li>
</ul>
</li>
</ol>
</div>
</div>
<div id="add-high-and-low-risk-compartments" class="section level2">
<h2 class="hasAnchor">
<a href="#add-high-and-low-risk-compartments" class="anchor"></a>2. Add High and Low Risk Compartments</h2>
<p>To make the SEIR model slightly more realistic, and therefore better able to capture the observed dynamics of TB, we add a second latent population (as discussed in the solutions for practical 1). This change can be seen in the model flow diagram (Figure 2). Go back to <a href="https://bristolmathmodellers.github.io/biddmodellingcourse/articles/practical_1.html">practical 1</a> if you need a refresher for the motivation behind this. We have also added reinfection for the low risk latent population.</p>
<div class="figure">
<img src="resources/SHLIR_flow_diag.png" alt="Figure 2: An SHLIR model of TB transmission, including simple demographic processes"><p class="caption">Figure 2: An SHLIR model of TB transmission, including simple demographic processes</p>
</div>
<div id="explore-1" class="section level3">
<h3 class="hasAnchor">
<a href="#explore-1" class="anchor"></a>Explore</h3>
<ol style="list-style-type: decimal">
<li>
<p>What has the impact of adding the second latent population been?</p>
<ul>
<li><strong>It has reduced the peak epidemic size and slowed the initial spread of the disease. In addition there are fewer cumulative active cases but a larger pool of latently infected cases.</strong></li>
</ul>
</li>
</ol>
</div>
</div>
<div id="a-more-realistic-shlir-model-flow-diagram" class="section level2">
<h2 class="hasAnchor">
<a href="#a-more-realistic-shlir-model-flow-diagram" class="anchor"></a>3. A more realistic SHLIR model flow diagram</h2>
<p>The most complex model supported by the interactive interface, this is a more realistic model that might be used in research. The SHLIR model flow diagram (Figure 3) includes: risk groups, treatment, and reinfection for those who have recovered from active disease. Whilst many realistic TB models use age structure this is not included here (if you are interested in discussing how you would include this talk to your instructors or contact <a href="https://www.samabbott.co.uk/">me</a>). For simplicity we have assumed that it is possible to be born into both populations. For the motivation behind this model see <a href="https://bristolmathmodellers.github.io/biddmodellingcourse/articles/practical-one.html">practical 1</a>.</p>
<div class="figure">
<img src="resources/SHLIR_real_flow_diag.png" alt="Figure 3: A realistic SHLIR model of TB transmission, including simple demographic processes"><p class="caption">Figure 3: A realistic SHLIR model of TB transmission, including simple demographic processes</p>
</div>
<p>Figure 3 does not include the interaction between the high and low risk subgroups as this is through the force of infection. The force of infection is defined as,</p>
<p><span class="math display">\[ \lambda_i = \beta \sum_{j = L, H}M_{ij}I_j \]</span></p>
<p>Where <span class="math inline">\(\lambda_i\)</span> is the force of infection in each risk group (<span class="math inline">\(i = L, H\)</span>) and <span class="math inline">\(M_{LH}\)</span> is the mixing rate between risk groups. It is assumed that within group contact rates are equivalent and defined such that,</p>
<p><span class="math display">\[ M_{ii} = 1 \]</span></p>
<p>It is also assumed that the between group contact rates are defined as (where <span class="math inline">\(i \neq j\)</span>),</p>
<p><span class="math display">\[ M_{ij} = 0.1 \]</span></p>
<div id="explore-2" class="section level3">
<h3 class="hasAnchor">
<a href="#explore-2" class="anchor"></a>Explore</h3>
<ol style="list-style-type: decimal">
<li>
<p>What happens when one group has a much higher transmission probability (use the default settings for all other parameters), compared to when the transmission probability is the same for both groups?</p>
<ul>
<li><strong>The proportion of cases that are in the high risk latent and infectious populations has increased.</strong></li>
</ul>
</li>
<li>
<p>What is the impact of varying the mixing between high and low risk groups for the above scenario?</p>
<ul>
<li><strong>As mixing is reduced the proportion of the low risk population that are infected is reduced.</strong></li>
<li><strong>As mixing is increased the disease dynamics become more homogeneous between groups.</strong></li>
</ul>
</li>
</ol>
</div>
</div>
<div id="explore-model-dynamics" class="section level2">
<h2 class="hasAnchor">
<a href="#explore-model-dynamics" class="anchor"></a>3. Explore model dynamics</h2>
<ul>
<li>
<p>The interactive interface allows for exploration of multiple other models, using it can you identify some commonalities between different models? What generalisations can you draw from these commonalities.</p>
<ul>
<li><strong>Adding birth and death process can lead to oscillating behaviour around some steady state.</strong></li>
<li><strong>Add additional latent compartments reduces the speed of progression of the epidemic through the population.</strong></li>
<li><strong>Highly infectious disease may die out in a short space of time if there is not a sufficient number of susceptibles.</strong></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="references" class="section level1 unnumbered">
<h1 class="hasAnchor">
<a href="#references" class="anchor"></a>References</h1>
<div id="refs" class="references">
<div id="ref-Brooks-Pollock2010">
<p>1 Brooks-Pollock E, Cohen T, Murray M. The impact of realistic age structure in simple models of tuberculosis transmission. <em>PLoS One</em> 2010;<strong>5</strong>:3–8. doi:<a href="https://doi.org/10.1371/journal.pone.0008479">10.1371/journal.pone.0008479</a></p>
</div>
</div>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<div id="tocnav">
<h2 class="hasAnchor">
<a href="#tocnav" class="anchor"></a>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#learning-objectives">Learning Objectives</a></li>
<li><a href="#outline-for-session">Outline for Session</a></li>
<li><a href="#solutions">Solutions</a></li>
<li><a href="#set-up">Set up</a></li>
<li>
<a href="#exercises">Exercises</a><ul class="nav nav-pills nav-stacked">
<li><a href="#a-simple-seir-model-of-tuberculosis-tb">1. A Simple SEIR Model of Tuberculosis (TB)</a></li>
<li><a href="#add-high-and-low-risk-compartments">2. Add High and Low Risk Compartments</a></li>
<li><a href="#a-more-realistic-shlir-model-flow-diagram">3. A more realistic SHLIR model flow diagram</a></li>
<li><a href="#explore-model-dynamics">3. Explore model dynamics</a></li>
</ul>
</li>
<li><a href="#references">References</a></li>
</ul>
</div>
</div>
</div>
<footer><div class="copyright">
<p>Developed by Sam Abbott, Josephine Walker.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.9000.</p>
</div>
</footer>
</div>
</body>
</html>