-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_day2_outbreak.html
More file actions
1418 lines (1379 loc) · 96.7 KB
/
Copy path02_day2_outbreak.html
File metadata and controls
1418 lines (1379 loc) · 96.7 KB
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.8.25">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="author" content="Marco Sorbona, PhD">
<meta name="dcterms.date" content="2026-03-01">
<title>Outbreak Signal Investigation</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
/* CSS for syntax highlighting */
html { -webkit-text-size-adjust: 100%; }
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
</style>
<script src="02_day2_outbreak_files/libs/clipboard/clipboard.min.js"></script>
<script src="02_day2_outbreak_files/libs/quarto-html/quarto.js" type="module"></script>
<script src="02_day2_outbreak_files/libs/quarto-html/tabsets/tabsets.js" type="module"></script>
<script src="02_day2_outbreak_files/libs/quarto-html/axe/axe-check.js" type="module"></script>
<script src="02_day2_outbreak_files/libs/quarto-html/popper.min.js"></script>
<script src="02_day2_outbreak_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="02_day2_outbreak_files/libs/quarto-html/anchor.min.js"></script>
<link href="02_day2_outbreak_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="02_day2_outbreak_files/libs/quarto-html/quarto-syntax-highlighting-7b89279ff1a6dce999919e0e67d4d9ec.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="02_day2_outbreak_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="02_day2_outbreak_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="02_day2_outbreak_files/libs/bootstrap/bootstrap-4d7f0bce1131f3e5f9547cd857cfbfc8.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light">
<link href="02_day2_outbreak_files/libs/htmltools-fill-0.5.9/fill.css" rel="stylesheet">
<script src="02_day2_outbreak_files/libs/htmlwidgets-1.6.4/htmlwidgets.js"></script>
<script src="02_day2_outbreak_files/libs/plotly-binding-4.12.0/plotly.js"></script>
<script src="02_day2_outbreak_files/libs/typedarray-0.1/typedarray.min.js"></script>
<script src="02_day2_outbreak_files/libs/jquery-3.5.1/jquery.min.js"></script>
<link href="02_day2_outbreak_files/libs/crosstalk-1.2.2/css/crosstalk.min.css" rel="stylesheet">
<script src="02_day2_outbreak_files/libs/crosstalk-1.2.2/js/crosstalk.min.js"></script>
<link href="02_day2_outbreak_files/libs/plotly-htmlwidgets-css-2.25.2/plotly-htmlwidgets.css" rel="stylesheet">
<script src="02_day2_outbreak_files/libs/plotly-main-2.25.2/plotly-latest.min.js"></script>
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script>
<script type="text/javascript">
const typesetMath = (el) => {
if (window.MathJax) {
// MathJax Typeset
window.MathJax.typeset([el]);
} else if (window.katex) {
// KaTeX Render
var mathElements = el.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN" && texText && texText.data) {
window.katex.render(texText.data, mathElements[i], {
displayMode: mathElements[i].classList.contains('display'),
throwOnError: false,
macros: macros,
fleqn: false
});
}
}
}
}
window.Quarto = {
typesetMath
};
</script>
</head>
<body class="quarto-light">
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#outbreak-signal-investigation" id="toc-outbreak-signal-investigation" class="nav-link active" data-scroll-target="#outbreak-signal-investigation">Outbreak Signal Investigation</a>
<ul class="collapse">
<li><a href="#task" id="toc-task" class="nav-link" data-scroll-target="#task">Task</a>
<ul class="collapse">
<li><a href="#why-c.-difficile" id="toc-why-c.-difficile" class="nav-link" data-scroll-target="#why-c.-difficile">Why C. difficile?</a></li>
<li><a href="#data-source-ukhsa-c.-difficile-surveillance" id="toc-data-source-ukhsa-c.-difficile-surveillance" class="nav-link" data-scroll-target="#data-source-ukhsa-c.-difficile-surveillance">Data Source: UKHSA C. difficile Surveillance</a></li>
<li><a href="#data-coverage-and-statistical-approach" id="toc-data-coverage-and-statistical-approach" class="nav-link" data-scroll-target="#data-coverage-and-statistical-approach">Data Coverage and Statistical Approach</a></li>
</ul></li>
<li><a href="#analysis" id="toc-analysis" class="nav-link" data-scroll-target="#analysis">Analysis</a>
<ul class="collapse">
<li><a href="#filtering-hospital-onset" id="toc-filtering-hospital-onset" class="nav-link" data-scroll-target="#filtering-hospital-onset">Filtering hospital-onset</a></li>
<li><a href="#screen-all-regions" id="toc-screen-all-regions" class="nav-link" data-scroll-target="#screen-all-regions">Screen all regions</a></li>
<li><a href="#deep-dive-east-midlands" id="toc-deep-dive-east-midlands" class="nav-link" data-scroll-target="#deep-dive-east-midlands">Deep dive: East Midlands</a></li>
<li><a href="#compare-with-runner-up-region" id="toc-compare-with-runner-up-region" class="nav-link" data-scroll-target="#compare-with-runner-up-region">Compare with runner-up region</a></li>
<li><a href="#regional-comparison" id="toc-regional-comparison" class="nav-link" data-scroll-target="#regional-comparison">Regional Comparison</a></li>
</ul></li>
<li><a href="#findings" id="toc-findings" class="nav-link" data-scroll-target="#findings">Findings</a>
<ul class="collapse">
<li><a href="#key-results" id="toc-key-results" class="nav-link" data-scroll-target="#key-results">Key results</a></li>
<li><a href="#public-health-response" id="toc-public-health-response" class="nav-link" data-scroll-target="#public-health-response">Public Health Response</a></li>
<li><a href="#limitations" id="toc-limitations" class="nav-link" data-scroll-target="#limitations">Limitations</a></li>
</ul></li>
<li><a href="#conclusion" id="toc-conclusion" class="nav-link" data-scroll-target="#conclusion">Conclusion</a></li>
</ul></li>
</ul>
</nav>
</div>
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">Outbreak Signal Investigation</h1>
</div>
<div class="quarto-title-meta">
<div>
<div class="quarto-title-meta-heading">Author</div>
<div class="quarto-title-meta-contents">
<p>Marco Sorbona, PhD </p>
</div>
</div>
<div>
<div class="quarto-title-meta-heading">Published</div>
<div class="quarto-title-meta-contents">
<p class="date">March 1, 2026</p>
</div>
</div>
</div>
</header>
<section id="outbreak-signal-investigation" class="level1">
<h1>Outbreak Signal Investigation</h1>
<section id="task" class="level2">
<h2 class="anchored" data-anchor-id="task">Task</h2>
<p>Using real UKHSA C. difficile surveillance data, I investigated potential outbreaks by focusing on hospital-onset cases – those detected 48 or more hours after admission. These cases are most relevant for identifying transmission within healthcare settings.</p>
<section id="why-c.-difficile" class="level3">
<h3 class="anchored" data-anchor-id="why-c.-difficile">Why C. difficile?</h3>
<p>C. difficile (Clostridioides difficile) is a major <strong>healthcare-associated infection</strong> and a UKHSA priority. It causes severe diarrhoea, particularly in:</p>
<ul>
<li><p><strong>Hospitals</strong> – vulnerable patients, antibiotic exposure</p></li>
<li><p><strong>Care homes</strong> – elderly residents, shared facilities</p></li>
<li><p><strong>Community</strong> – emerging community-associated cases</p></li>
</ul>
<p>Outbreaks in healthcare settings require <strong>rapid detection and response</strong> to prevent transmission and protect patients.</p>
</section>
<section id="data-source-ukhsa-c.-difficile-surveillance" class="level3">
<h3 class="anchored" data-anchor-id="data-source-ukhsa-c.-difficile-surveillance">Data Source: UKHSA C. difficile Surveillance</h3>
<p>I will use the <code>ukhsadatR</code> package to access the official UKHSA data directly. This package provides a programmatic interface to the UKHSA Data Dashboard.</p>
<p>The dataset contains hospital-onset C. difficile cases from nine UKHSA regions for 2023 and 2024. 2023 includes only 7 weeks of data, while 2024 includes 11 weeks. This means many weeks in 2024 lack historical baselines for comparison (a common real-world limitation).</p>
</section>
<section id="data-coverage-and-statistical-approach" class="level3">
<h3 class="anchored" data-anchor-id="data-coverage-and-statistical-approach">Data Coverage and Statistical Approach</h3>
<p>The C. difficile data covers <strong>July 2023 – November 2024</strong> (13 weeks per region). This is not enough to establish full seasonal baselines: in an ideal world, 3–5 years of complete data would be preferred. However, this is <strong>real surveillance data</strong>. Reporting systems evolve, data availability changes, and analysts must work with what exists.</p>
<p>Critically, <strong>each week in 2023 has only one observation</strong> – insufficient to calculate standard deviations. Disease counts like these typically follow a <strong>Poisson distribution</strong>, where the variance equals the mean. This allows calculation of statistically valid thresholds even with sparse data.</p>
<p><strong>The Poisson method:</strong></p>
<p>For a given week with baseline mean <code>λ</code>, the 95% upper limit is:</p>
<p><code>Upper limit = λ + 1.96 × √λ</code></p>
<p>This represents the value that would be exceeded by chance less than 5% of the time if only random variation were operating. It is a standard approach in outbreak detection systems when historical data is limited.</p>
<p>This analysis should therefore be seen as:</p>
<ul>
<li><p>A <strong>proof of method</strong> for outbreak detection</p></li>
<li><p>A <strong>transparent</strong> account of working with imperfect data</p></li>
<li><p>A <strong>foundation</strong> that would be refined as more data accrues</p></li>
</ul>
</section>
</section>
<section id="analysis" class="level2">
<h2 class="anchored" data-anchor-id="analysis">Analysis</h2>
<section id="filtering-hospital-onset" class="level3">
<h3 class="anchored" data-anchor-id="filtering-hospital-onset">Filtering hospital-onset</h3>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>hospital_cases <span class="ot"><-</span> cdiff_data <span class="sc">|></span> </span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(onset_type <span class="sc">==</span> <span class="st">"Hospital-onset, healthcare associated"</span>) <span class="sc">|></span> </span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(region, year, week, date, cases) <span class="sc">|></span> </span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">arrange</span>(region, year, week)</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="co"># Summary </span></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a>hospital_cases <span class="sc">|></span> </span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(year) <span class="sc">|></span> </span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(</span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a> <span class="at">total_cases =</span> <span class="fu">sum</span>(cases),</span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a> <span class="at">weeks =</span> <span class="fu">n_distinct</span>(week),</span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a> <span class="at">regions =</span> <span class="fu">n_distinct</span>(region)</span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">|></span> </span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">kable</span>(<span class="at">caption =</span> <span class="st">"Hospital-onset C. Difficile cases by year"</span>)</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<caption>Hospital-onset C. Difficile cases by year</caption>
<thead>
<tr class="header">
<th style="text-align: right;">year</th>
<th style="text-align: right;">total_cases</th>
<th style="text-align: right;">weeks</th>
<th style="text-align: right;">regions</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">2023</td>
<td style="text-align: right;">4358</td>
<td style="text-align: right;">7</td>
<td style="text-align: right;">9</td>
</tr>
<tr class="even">
<td style="text-align: right;">2024</td>
<td style="text-align: right;">7676</td>
<td style="text-align: right;">11</td>
<td style="text-align: right;">9</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section id="screen-all-regions" class="level3">
<h3 class="anchored" data-anchor-id="screen-all-regions">Screen all regions</h3>
<p>First, I identify which regions show the largest increases or most unusual patterns.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Calculate summary statistics by region</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>region_summary <span class="ot"><-</span> hospital_cases <span class="sc">|></span> </span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(region, year) <span class="sc">|></span> </span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(</span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> <span class="at">total_cases =</span> <span class="fu">sum</span>(cases),</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> <span class="at">mean_cases =</span> <span class="fu">mean</span>(cases),</span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a> <span class="at">peak_cases =</span> <span class="fu">max</span>(cases),</span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a> <span class="at">peak_week =</span> week[<span class="fu">which.max</span>(cases)],</span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a> <span class="at">.groups =</span> <span class="st">"drop"</span></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">|></span> </span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_wider</span>(</span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a> <span class="at">names_from =</span> year,</span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a> <span class="at">values_from =</span> <span class="fu">c</span>(total_cases, mean_cases, peak_cases, peak_week),</span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a> <span class="at">names_glue =</span> <span class="st">"{.value}_{year}"</span></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">|></span> </span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(</span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a> <span class="at">pct_change =</span> (total_cases_2024 <span class="sc">-</span> total_cases_2023) <span class="sc">/</span> total_cases_2023 <span class="sc">*</span> <span class="dv">100</span>,</span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a> <span class="at">abs_change =</span> total_cases_2024 <span class="sc">-</span> total_cases_2023</span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">|></span> </span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">arrange</span>(<span class="fu">desc</span>(pct_change))</span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a><span class="co"># Display screening results</span></span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a>region_summary <span class="sc">|></span></span>
<span id="cb2-25"><a href="#cb2-25" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(region, total_cases_2023, total_cases_2024, pct_change, abs_change, peak_cases_2024) <span class="sc">|></span></span>
<span id="cb2-26"><a href="#cb2-26" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(</span>
<span id="cb2-27"><a href="#cb2-27" aria-hidden="true" tabindex="-1"></a> <span class="at">pct_change =</span> <span class="fu">round</span>(pct_change, <span class="dv">1</span>)</span>
<span id="cb2-28"><a href="#cb2-28" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">|></span></span>
<span id="cb2-29"><a href="#cb2-29" aria-hidden="true" tabindex="-1"></a> <span class="fu">kable</span>(<span class="at">caption =</span> <span class="st">"Regional Screening: change in C. Difficile cases (2023-2024)"</span>)</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<caption>Regional Screening: change in C. Difficile cases (2023-2024)</caption>
<colgroup>
<col style="width: 22%">
<col style="width: 18%">
<col style="width: 18%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 17%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">region</th>
<th style="text-align: right;">total_cases_2023</th>
<th style="text-align: right;">total_cases_2024</th>
<th style="text-align: right;">pct_change</th>
<th style="text-align: right;">abs_change</th>
<th style="text-align: right;">peak_cases_2024</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">East Midlands</td>
<td style="text-align: right;">346</td>
<td style="text-align: right;">665</td>
<td style="text-align: right;">92.2</td>
<td style="text-align: right;">319</td>
<td style="text-align: right;">77</td>
</tr>
<tr class="even">
<td style="text-align: left;">Yorkshire and Humber</td>
<td style="text-align: right;">396</td>
<td style="text-align: right;">730</td>
<td style="text-align: right;">84.3</td>
<td style="text-align: right;">334</td>
<td style="text-align: right;">78</td>
</tr>
<tr class="odd">
<td style="text-align: left;">London</td>
<td style="text-align: right;">425</td>
<td style="text-align: right;">783</td>
<td style="text-align: right;">84.2</td>
<td style="text-align: right;">358</td>
<td style="text-align: right;">106</td>
</tr>
<tr class="even">
<td style="text-align: left;">South West</td>
<td style="text-align: right;">433</td>
<td style="text-align: right;">797</td>
<td style="text-align: right;">84.1</td>
<td style="text-align: right;">364</td>
<td style="text-align: right;">92</td>
</tr>
<tr class="odd">
<td style="text-align: left;">North East</td>
<td style="text-align: right;">237</td>
<td style="text-align: right;">422</td>
<td style="text-align: right;">78.1</td>
<td style="text-align: right;">185</td>
<td style="text-align: right;">45</td>
</tr>
<tr class="even">
<td style="text-align: left;">North West</td>
<td style="text-align: right;">863</td>
<td style="text-align: right;">1523</td>
<td style="text-align: right;">76.5</td>
<td style="text-align: right;">660</td>
<td style="text-align: right;">178</td>
</tr>
<tr class="odd">
<td style="text-align: left;">East of England</td>
<td style="text-align: right;">528</td>
<td style="text-align: right;">893</td>
<td style="text-align: right;">69.1</td>
<td style="text-align: right;">365</td>
<td style="text-align: right;">102</td>
</tr>
<tr class="even">
<td style="text-align: left;">West Midlands</td>
<td style="text-align: right;">545</td>
<td style="text-align: right;">902</td>
<td style="text-align: right;">65.5</td>
<td style="text-align: right;">357</td>
<td style="text-align: right;">98</td>
</tr>
<tr class="odd">
<td style="text-align: left;">South East</td>
<td style="text-align: right;">585</td>
<td style="text-align: right;">961</td>
<td style="text-align: right;">64.3</td>
<td style="text-align: right;">376</td>
<td style="text-align: right;">119</td>
</tr>
</tbody>
</table>
<p>C. Difficile cases by region: 2023 vs 2024 comparison</p>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Visualise all regions together</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>hospital_cases <span class="sc">|></span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x =</span> week, <span class="at">y =</span> cases, <span class="at">color =</span> <span class="fu">factor</span>(year))) <span class="sc">+</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_line</span>(<span class="at">linewidth =</span> <span class="fl">0.8</span>) <span class="sc">+</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_point</span>(<span class="at">size =</span> <span class="dv">1</span>) <span class="sc">+</span></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">facet_wrap</span>(<span class="sc">~</span>region) <span class="sc">+</span></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_color_manual</span>(<span class="at">values =</span> <span class="fu">c</span>(<span class="st">"2023"</span> <span class="ot">=</span> <span class="st">"#2c3e50"</span>, <span class="st">"2024"</span> <span class="ot">=</span> <span class="st">"#3498db"</span>)) <span class="sc">+</span></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"C. Difficile hospital-onset cases by region"</span>,</span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a> <span class="at">subtitle =</span> <span class="st">"2023 (grey) vs 2024 (blue) - 13 weeks of data per region"</span>,</span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="st">"Week number"</span>,</span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="st">"Number of cases"</span>,</span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a> <span class="at">color =</span> <span class="st">"Year"</span></span>
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb3-15"><a href="#cb3-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_minimal</span>() <span class="sc">+</span></span>
<span id="cb3-16"><a href="#cb3-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">legend.position =</span> <span class="st">"bottom"</span>)</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="02_day2_outbreak_files/figure-html/screen-regions-1.png" class="img-fluid figure-img" width="672"></p>
<figcaption>C. Difficile cases by region: 2023 vs 2024 comparison</figcaption>
</figure>
</div>
</div>
</div>
<section id="key-findings" class="level4">
<h4 class="anchored" data-anchor-id="key-findings">Key findings</h4>
<p>The screening identified multiple regions with substantial increases. <strong>East</strong> <strong>Midlands</strong> showed the highest relative increase (<strong>92.2%</strong>), indicating its 2024 values are most elevated above baseline. The <strong>North West</strong>, while lower in percentage terms (<strong>76.5%</strong>), has the <strong>highest absolute peak</strong> (<strong>178</strong> cases) and largest total increase (<strong>+660</strong>). Both patterns warrant investigation, relative increase signals unexpected change, while absolute burden indicates scale of potential impact.</p>
</section>
</section>
<section id="deep-dive-east-midlands" class="level3">
<h3 class="anchored" data-anchor-id="deep-dive-east-midlands">Deep dive: East Midlands</h3>
<p>Based on investigation, I selected <strong>East Midlands</strong> for detailed analysis as the strongest statistical signal.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>region_focus <span class="ot"><-</span> <span class="st">"East Midlands"</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Also note the runner-up for comparison</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a>region_runnerup <span class="ot"><-</span> <span class="st">"Yorkshire and Humber"</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(<span class="fu">paste</span>(<span class="st">"Focus region:"</span>, region_focus, <span class="st">"-"</span>, <span class="fu">round</span>(region_summary<span class="sc">$</span>pct_change[region_summary<span class="sc">$</span>region <span class="sc">==</span> region_focus], <span class="dv">1</span>), <span class="st">"% increase"</span>))</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] "Focus region: East Midlands - 92.2 % increase"</code></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(<span class="fu">paste</span>(<span class="st">"Comparison region:"</span>, region_runnerup, <span class="st">"-"</span>, <span class="fu">round</span>(region_summary<span class="sc">$</span>pct_change[region_summary<span class="sc">$</span>region <span class="sc">==</span> region_runnerup], <span class="dv">1</span>), <span class="st">"% increase"</span>))</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] "Comparison region: Yorkshire and Humber - 84.3 % increase"</code></pre>
</div>
</div>
<section id="statistical-rationale-analysis-with-poisson-method" class="level4">
<h4 class="anchored" data-anchor-id="statistical-rationale-analysis-with-poisson-method">Statistical rationale: Analysis with Poisson method</h4>
<p>With only one observation per week in 2023, I cannot calculate standard deviations. However, disease counts typically follow a <strong>Poisson distribution</strong>, where variance equals the mean. This allows calculation of a 95% upper limit:</p>
<p><span class="math inline">\(UpperLimit = baseline + 1.96\times \sqrt{baseline}\)</span></p>
<p>Values exceeding this limit have <5% probability of occurring by chance alone.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Create lookup of 2023 baseline values for focus region</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a>baseline_2023 <span class="ot"><-</span> hospital_cases <span class="sc">|></span> </span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(year <span class="sc">==</span> <span class="dv">2023</span>, region <span class="sc">==</span> region_focus) <span class="sc">|></span> </span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(week, <span class="at">baseline_cases =</span> cases) <span class="sc">|></span> </span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(</span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> <span class="co"># Poisson 95% upper limit</span></span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a> <span class="at">threshold_poisson =</span> baseline_cases <span class="sc">+</span> <span class="fl">1.96</span> <span class="sc">*</span> <span class="fu">sqrt</span>(baseline_cases),</span>
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a> <span class="co"># Also calculate doubling threshold (simple heuristic)</span></span>
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a> <span class="at">threshold_double =</span> baseline_cases <span class="sc">*</span> <span class="dv">2</span></span>
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a> )</span>
<span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-12"><a href="#cb8-12" aria-hidden="true" tabindex="-1"></a><span class="co"># Get 2024 data and apply threshold</span></span>
<span id="cb8-13"><a href="#cb8-13" aria-hidden="true" tabindex="-1"></a>current_2024_all <span class="ot"><-</span> hospital_cases <span class="sc">|></span> </span>
<span id="cb8-14"><a href="#cb8-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(year <span class="sc">==</span> <span class="dv">2024</span>, region <span class="sc">==</span> region_focus) <span class="sc">|></span> </span>
<span id="cb8-15"><a href="#cb8-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">left_join</span>(</span>
<span id="cb8-16"><a href="#cb8-16" aria-hidden="true" tabindex="-1"></a> baseline_2023,</span>
<span id="cb8-17"><a href="#cb8-17" aria-hidden="true" tabindex="-1"></a> <span class="at">by =</span> <span class="st">"week"</span></span>
<span id="cb8-18"><a href="#cb8-18" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">|></span> </span>
<span id="cb8-19"><a href="#cb8-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(</span>
<span id="cb8-20"><a href="#cb8-20" aria-hidden="true" tabindex="-1"></a> <span class="at">alert_poisson =</span> cases <span class="sc">></span> threshold_poisson,</span>
<span id="cb8-21"><a href="#cb8-21" aria-hidden="true" tabindex="-1"></a> <span class="at">alert_double =</span> cases <span class="sc">></span> threshold_double,</span>
<span id="cb8-22"><a href="#cb8-22" aria-hidden="true" tabindex="-1"></a> <span class="at">excess_pct =</span> (cases <span class="sc">-</span> baseline_cases) <span class="sc">/</span> baseline_cases <span class="sc">*</span> <span class="dv">100</span></span>
<span id="cb8-23"><a href="#cb8-23" aria-hidden="true" tabindex="-1"></a> )</span>
<span id="cb8-24"><a href="#cb8-24" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-25"><a href="#cb8-25" aria-hidden="true" tabindex="-1"></a><span class="co"># Show the data</span></span>
<span id="cb8-26"><a href="#cb8-26" aria-hidden="true" tabindex="-1"></a>current_2024_all <span class="sc">|></span> </span>
<span id="cb8-27"><a href="#cb8-27" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(week, baseline_cases, cases, threshold_poisson, alert_poisson, excess_pct) <span class="sc">|></span> </span>
<span id="cb8-28"><a href="#cb8-28" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">excess_pct =</span> <span class="fu">round</span>(excess_pct, <span class="dv">1</span>)) <span class="sc">|></span> </span>
<span id="cb8-29"><a href="#cb8-29" aria-hidden="true" tabindex="-1"></a> <span class="fu">kable</span>(<span class="at">caption =</span> <span class="fu">paste</span>(<span class="st">"Deep dive: "</span>, region_focus, <span class="st">" - weekly comparison"</span>))</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<caption>Deep dive: East Midlands - weekly comparison</caption>
<colgroup>
<col style="width: 7%">
<col style="width: 21%">
<col style="width: 8%">
<col style="width: 26%">
<col style="width: 20%">
<col style="width: 15%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: right;">week</th>
<th style="text-align: right;">baseline_cases</th>
<th style="text-align: right;">cases</th>
<th style="text-align: right;">threshold_poisson</th>
<th style="text-align: left;">alert_poisson</th>
<th style="text-align: right;">excess_pct</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">5</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">53</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
</tr>
<tr class="even">
<td style="text-align: right;">9</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">48</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: right;">13</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">61</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
</tr>
<tr class="even">
<td style="text-align: right;">18</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">51</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: right;">22</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">64</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
</tr>
<tr class="even">
<td style="text-align: right;">26</td>
<td style="text-align: right;">42</td>
<td style="text-align: right;">56</td>
<td style="text-align: right;">54.70225</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: right;">33.3</td>
</tr>
<tr class="odd">
<td style="text-align: right;">31</td>
<td style="text-align: right;">47</td>
<td style="text-align: right;">63</td>
<td style="text-align: right;">60.43708</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: right;">34.0</td>
</tr>
<tr class="even">
<td style="text-align: right;">35</td>
<td style="text-align: right;">45</td>
<td style="text-align: right;">76</td>
<td style="text-align: right;">58.14808</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: right;">68.9</td>
</tr>
<tr class="odd">
<td style="text-align: right;">40</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">57</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
</tr>
<tr class="even">
<td style="text-align: right;">44</td>
<td style="text-align: right;">52</td>
<td style="text-align: right;">77</td>
<td style="text-align: right;">66.13376</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: right;">48.1</td>
</tr>
<tr class="odd">
<td style="text-align: right;">48</td>
<td style="text-align: right;">52</td>
<td style="text-align: right;">59</td>
<td style="text-align: right;">66.13376</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: right;">13.5</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section id="note-on-missing-weeks" class="level4">
<h4 class="anchored" data-anchor-id="note-on-missing-weeks">Note on Missing Weeks</h4>
<p>The 2023 data for East Midlands covers only <strong>weeks 26, 31, 35, 44, and 48</strong>. Weeks 5, 9, 13, 18, 22, and 40 exist in 2024 but cannot be assessed for outbreaks due to lack of baseline. This reflects the real-world reality that surveillance data is often incomplete.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Filter to weeks with baseline for analysis</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>current_2024 <span class="ot"><-</span> current_2024_all <span class="sc">|></span> </span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(baseline_cases))</span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a><span class="co"># Summary of comparable weeks</span></span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a>alert_summary <span class="ot"><-</span> current_2024 <span class="sc">|></span> </span>
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(</span>
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a> <span class="at">weeks_with_baseline =</span> <span class="fu">n</span>(),</span>
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a> <span class="at">weeks_alert =</span> <span class="fu">sum</span>(alert_poisson, <span class="at">na.rm =</span> <span class="cn">TRUE</span>),</span>
<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a> <span class="at">alert_percent =</span> weeks_alert <span class="sc">/</span> weeks_with_baseline <span class="sc">*</span> <span class="dv">100</span>,</span>
<span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a> <span class="at">mean_excess =</span> <span class="fu">mean</span>(excess_pct, <span class="at">na.rm =</span> <span class="cn">TRUE</span>)</span>
<span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a> )</span>
<span id="cb9-13"><a href="#cb9-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb9-14"><a href="#cb9-14" aria-hidden="true" tabindex="-1"></a>alert_summary <span class="sc">|></span> </span>
<span id="cb9-15"><a href="#cb9-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(</span>
<span id="cb9-16"><a href="#cb9-16" aria-hidden="true" tabindex="-1"></a> <span class="at">alert_percent =</span> <span class="fu">round</span>(alert_percent, <span class="dv">1</span>),</span>
<span id="cb9-17"><a href="#cb9-17" aria-hidden="true" tabindex="-1"></a> <span class="at">mean_excess =</span> <span class="fu">round</span>(mean_excess, <span class="dv">1</span>)</span>
<span id="cb9-18"><a href="#cb9-18" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">|></span> </span>
<span id="cb9-19"><a href="#cb9-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">kable</span>(<span class="at">caption =</span> <span class="fu">paste</span>(<span class="st">"Outbreak detection summary for "</span>, region_focus))</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<caption>Outbreak detection summary for East Midlands</caption>
<thead>
<tr class="header">
<th style="text-align: right;">weeks_with_baseline</th>
<th style="text-align: right;">weeks_alert</th>
<th style="text-align: right;">alert_percent</th>
<th style="text-align: right;">mean_excess</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">5</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">80</td>
<td style="text-align: right;">39.6</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section id="results-for-east-midlands" class="level4">
<h4 class="anchored" data-anchor-id="results-for-east-midlands">Results for East Midlands</h4>
<p>Of the 5 weeks with baseline data, 4 (80 %) exceed the Poisson 95% upper limit.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Prepare data for plotting</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a>plot_data <span class="ot"><-</span> current_2024 <span class="sc">|></span> </span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_longer</span>(</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a> <span class="at">cols =</span> <span class="fu">c</span>(cases, baseline_cases, threshold_poisson),</span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a> <span class="at">names_to =</span> <span class="st">"series"</span>,</span>
<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a> <span class="at">values_to =</span> <span class="st">"value"</span></span>
<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">|></span> </span>
<span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(</span>
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a> <span class="at">series =</span> <span class="fu">case_when</span>(</span>
<span id="cb10-10"><a href="#cb10-10" aria-hidden="true" tabindex="-1"></a> series <span class="sc">==</span> <span class="st">"cases"</span> <span class="sc">~</span> <span class="st">"2024 observed"</span>,</span>
<span id="cb10-11"><a href="#cb10-11" aria-hidden="true" tabindex="-1"></a> series <span class="sc">==</span> <span class="st">"baseline_cases"</span> <span class="sc">~</span> <span class="st">"2023 baseline"</span>,</span>
<span id="cb10-12"><a href="#cb10-12" aria-hidden="true" tabindex="-1"></a> series <span class="sc">==</span> <span class="st">"threshold_poisson"</span> <span class="sc">~</span> <span class="st">"Poisson 95% upper limit"</span></span>
<span id="cb10-13"><a href="#cb10-13" aria-hidden="true" tabindex="-1"></a> )</span>
<span id="cb10-14"><a href="#cb10-14" aria-hidden="true" tabindex="-1"></a> )</span>
<span id="cb10-15"><a href="#cb10-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-16"><a href="#cb10-16" aria-hidden="true" tabindex="-1"></a>p_dive <span class="ot"><-</span> <span class="fu">ggplot</span>() <span class="sc">+</span></span>
<span id="cb10-17"><a href="#cb10-17" aria-hidden="true" tabindex="-1"></a> <span class="co"># Baseline line</span></span>
<span id="cb10-18"><a href="#cb10-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_line</span>(<span class="at">data =</span> <span class="fu">filter</span>(plot_data, series <span class="sc">==</span> <span class="st">"2023 baseline"</span>),</span>
<span id="cb10-19"><a href="#cb10-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">aes</span>(<span class="at">x =</span> week, <span class="at">y =</span> value, <span class="at">color =</span> series),</span>
<span id="cb10-20"><a href="#cb10-20" aria-hidden="true" tabindex="-1"></a> <span class="at">linewidth =</span> <span class="fl">0.5</span>, <span class="at">linetype =</span> <span class="st">"dashed"</span></span>
<span id="cb10-21"><a href="#cb10-21" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb10-22"><a href="#cb10-22" aria-hidden="true" tabindex="-1"></a> <span class="co"># Threshold line</span></span>
<span id="cb10-23"><a href="#cb10-23" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_line</span>(<span class="at">data =</span> <span class="fu">filter</span>(plot_data, series <span class="sc">==</span> <span class="st">"Poisson 95% upper limit"</span>),</span>
<span id="cb10-24"><a href="#cb10-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">aes</span>(<span class="at">x =</span> week, <span class="at">y =</span> value, <span class="at">color =</span> series), </span>
<span id="cb10-25"><a href="#cb10-25" aria-hidden="true" tabindex="-1"></a> <span class="at">linewidth =</span> <span class="fl">0.6</span></span>
<span id="cb10-26"><a href="#cb10-26" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb10-27"><a href="#cb10-27" aria-hidden="true" tabindex="-1"></a> <span class="co"># 2024 observed line</span></span>
<span id="cb10-28"><a href="#cb10-28" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_line</span>(<span class="at">data =</span> <span class="fu">filter</span>(plot_data, series <span class="sc">==</span> <span class="st">"2024 observed"</span>),</span>
<span id="cb10-29"><a href="#cb10-29" aria-hidden="true" tabindex="-1"></a> <span class="fu">aes</span>(<span class="at">x =</span> week, <span class="at">y =</span> value, <span class="at">color =</span> series), </span>
<span id="cb10-30"><a href="#cb10-30" aria-hidden="true" tabindex="-1"></a> <span class="at">linewidth =</span> <span class="fl">0.6</span></span>
<span id="cb10-31"><a href="#cb10-31" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span> </span>
<span id="cb10-32"><a href="#cb10-32" aria-hidden="true" tabindex="-1"></a> <span class="co"># Alert points</span></span>
<span id="cb10-33"><a href="#cb10-33" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_point</span>(<span class="at">data =</span> <span class="fu">filter</span>(current_2024, alert_poisson <span class="sc">==</span> <span class="cn">TRUE</span>),</span>
<span id="cb10-34"><a href="#cb10-34" aria-hidden="true" tabindex="-1"></a> <span class="fu">aes</span>(<span class="at">x =</span> week, <span class="at">y =</span> cases), </span>
<span id="cb10-35"><a href="#cb10-35" aria-hidden="true" tabindex="-1"></a> <span class="at">color =</span> <span class="st">"red"</span>, <span class="at">size =</span> <span class="dv">2</span></span>
<span id="cb10-36"><a href="#cb10-36" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb10-37"><a href="#cb10-37" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_color_manual</span>(<span class="at">values =</span> <span class="fu">c</span>(</span>
<span id="cb10-38"><a href="#cb10-38" aria-hidden="true" tabindex="-1"></a> <span class="st">"2023 baseline"</span> <span class="ot">=</span> <span class="st">"#2c3e50"</span>,</span>
<span id="cb10-39"><a href="#cb10-39" aria-hidden="true" tabindex="-1"></a> <span class="st">"Poisson 95% upper limit"</span> <span class="ot">=</span> <span class="st">"#e67e22"</span>,</span>
<span id="cb10-40"><a href="#cb10-40" aria-hidden="true" tabindex="-1"></a> <span class="st">"2024 observed"</span> <span class="ot">=</span> <span class="st">"#3498db"</span></span>
<span id="cb10-41"><a href="#cb10-41" aria-hidden="true" tabindex="-1"></a> )) <span class="sc">+</span></span>
<span id="cb10-42"><a href="#cb10-42" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
<span id="cb10-43"><a href="#cb10-43" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="fu">paste</span>(<span class="st">"C. difficile outbreak detection:"</span>, region_focus),</span>
<span id="cb10-44"><a href="#cb10-44" aria-hidden="true" tabindex="-1"></a> <span class="at">subtitle =</span> <span class="fu">paste</span>(<span class="st">"4 of 5 comparable weeks exceed threshold (80% alert rate)"</span>),</span>
<span id="cb10-45"><a href="#cb10-45" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="st">"Week number"</span>,</span>
<span id="cb10-46"><a href="#cb10-46" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="st">"Number of cases"</span>,</span>
<span id="cb10-47"><a href="#cb10-47" aria-hidden="true" tabindex="-1"></a> <span class="at">color =</span> <span class="st">""</span>,</span>
<span id="cb10-48"><a href="#cb10-48" aria-hidden="true" tabindex="-1"></a> <span class="at">caption =</span> <span class="st">"Poisson limit = baseline + 1.96×√(baseline). Based on 5 weeks with baseline data."</span></span>
<span id="cb10-49"><a href="#cb10-49" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb10-50"><a href="#cb10-50" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_minimal</span>() <span class="sc">+</span></span>
<span id="cb10-51"><a href="#cb10-51" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">legend.position =</span> <span class="st">"bottom"</span>)</span>
<span id="cb10-52"><a href="#cb10-52" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-53"><a href="#cb10-53" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplotly</span>(p_dive, <span class="at">tooltip =</span> <span class="fu">c</span>(<span class="st">"week"</span>, <span class="st">"value"</span>, <span class="st">"series"</span>))</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
<div class="cell-output-display">
<div class="plotly html-widget html-fill-item" id="htmlwidget-b1d05f7f988ff642ad33" style="width:100%;height:464px;"></div>
<script type="application/json" data-for="htmlwidget-b1d05f7f988ff642ad33">{"x":{"data":[{"x":[26,31,35,44,48],"y":[42,47,45,52,52],"text":["week: 26<br />value: 42<br />series: 2023 baseline","week: 31<br />value: 47<br />series: 2023 baseline","week: 35<br />value: 45<br />series: 2023 baseline","week: 44<br />value: 52<br />series: 2023 baseline","week: 48<br />value: 52<br />series: 2023 baseline"],"type":"scatter","mode":"lines","line":{"width":1.8897637795275593,"color":"rgba(44,62,80,1)","dash":"dash"},"hoveron":"points","name":"2023 baseline","legendgroup":"2023 baseline","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","frame":null},{"x":[26,31,35,44,48],"y":[54.702251768879407,60.437083016786048,58.148079707698763,66.133760999818833,66.133760999818833],"text":["week: 26<br />value: 54.70225<br />series: Poisson 95% upper limit","week: 31<br />value: 60.43708<br />series: Poisson 95% upper limit","week: 35<br />value: 58.14808<br />series: Poisson 95% upper limit","week: 44<br />value: 66.13376<br />series: Poisson 95% upper limit","week: 48<br />value: 66.13376<br />series: Poisson 95% upper limit"],"type":"scatter","mode":"lines","line":{"width":2.2677165354330708,"color":"rgba(230,126,34,1)","dash":"solid"},"hoveron":"points","name":"Poisson 95% upper limit","legendgroup":"Poisson 95% upper limit","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","frame":null},{"x":[26,31,35,44,48],"y":[56,63,76,77,59],"text":["week: 26<br />value: 56<br />series: 2024 observed","week: 31<br />value: 63<br />series: 2024 observed","week: 35<br />value: 76<br />series: 2024 observed","week: 44<br />value: 77<br />series: 2024 observed","week: 48<br />value: 59<br />series: 2024 observed"],"type":"scatter","mode":"lines","line":{"width":2.2677165354330708,"color":"rgba(52,152,219,1)","dash":"solid"},"hoveron":"points","name":"2024 observed","legendgroup":"2024 observed","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","frame":null},{"x":[26,31,35,44],"y":[56,63,76,77],"text":["week: 26","week: 31","week: 35","week: 44"],"type":"scatter","mode":"markers","marker":{"autocolorscale":false,"color":"rgba(255,0,0,1)","opacity":1,"size":7.559055118110237,"symbol":"circle","line":{"width":1.8897637795275593,"color":"rgba(255,0,0,1)"}},"hoveron":"points","showlegend":false,"xaxis":"x","yaxis":"y","hoverinfo":"text","frame":null}],"layout":{"margin":{"t":40.840182648401829,"r":7.3059360730593621,"b":37.260273972602747,"l":37.260273972602747},"paper_bgcolor":"rgba(255,255,255,1)","font":{"color":"rgba(0,0,0,1)","family":"","size":14.611872146118724},"title":{"text":"C. difficile outbreak detection: East Midlands","font":{"color":"rgba(0,0,0,1)","family":"","size":17.534246575342465},"x":0,"xref":"paper"},"xaxis":{"domain":[0,1],"automargin":true,"type":"linear","autorange":false,"range":[24.899999999999999,49.100000000000001],"tickmode":"array","ticktext":["25","30","35","40","45"],"tickvals":[25,30,35,40,45],"categoryorder":"array","categoryarray":["25","30","35","40","45"],"nticks":null,"ticks":"","tickcolor":null,"ticklen":3.6529680365296811,"tickwidth":0,"showticklabels":true,"tickfont":{"color":"rgba(77,77,77,1)","family":"","size":11.68949771689498},"tickangle":-0,"showline":false,"linecolor":null,"linewidth":0,"showgrid":true,"gridcolor":"rgba(235,235,235,1)","gridwidth":0.66417600664176002,"zeroline":false,"anchor":"y","title":{"text":"Week number","font":{"color":"rgba(0,0,0,1)","family":"","size":14.611872146118724}},"hoverformat":".2f"},"yaxis":{"domain":[0,1],"automargin":true,"type":"linear","autorange":false,"range":[40.25,78.75],"tickmode":"array","ticktext":["50","60","70"],"tickvals":[50,60,70],"categoryorder":"array","categoryarray":["50","60","70"],"nticks":null,"ticks":"","tickcolor":null,"ticklen":3.6529680365296811,"tickwidth":0,"showticklabels":true,"tickfont":{"color":"rgba(77,77,77,1)","family":"","size":11.68949771689498},"tickangle":-0,"showline":false,"linecolor":null,"linewidth":0,"showgrid":true,"gridcolor":"rgba(235,235,235,1)","gridwidth":0.66417600664176002,"zeroline":false,"anchor":"x","title":{"text":"Number of cases","font":{"color":"rgba(0,0,0,1)","family":"","size":14.611872146118724}},"hoverformat":".2f"},"shapes":[],"showlegend":true,"legend":{"bgcolor":null,"bordercolor":null,"borderwidth":0,"font":{"color":"rgba(0,0,0,1)","family":"","size":11.68949771689498},"orientation":"h","x":0.5,"y":-0.14999999999999999,"xanchor":"center","yanchor":"top","title":{"text":"","font":{"color":"rgba(0,0,0,1)","family":"","size":14.611872146118724}}},"hovermode":"closest","barmode":"relative"},"config":{"doubleClick":"reset","modeBarButtonsToAdd":["hoverclosest","hovercompare"],"showSendToCloud":false},"source":"A","attrs":{"44283b5b6454":{"x":{},"y":{},"colour":{},"type":"scatter"},"4428316f11f9":{"x":{},"y":{},"colour":{}},"442878fc4980":{"x":{},"y":{},"colour":{}},"442828fd3259":{"x":{},"y":{}}},"cur_data":"44283b5b6454","visdat":{"44283b5b6454":["function (y) ","x"],"4428316f11f9":["function (y) ","x"],"442878fc4980":["function (y) ","x"],"442828fd3259":["function (y) ","x"]},"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.20000000000000001,"selected":{"opacity":1},"debounce":0},"shinyEvents":["plotly_hover","plotly_click","plotly_selected","plotly_relayout","plotly_brushed","plotly_brushing","plotly_clickannotation","plotly_doubleclick","plotly_deselect","plotly_afterplot","plotly_sunburstclick"],"base_url":"https://plot.ly"},"evals":[],"jsHooks":[]}</script>
<p>Outbreak detection: East Midlands - weeks with baseline only</p>
</div>
</div>
</section>
</section>
<section id="compare-with-runner-up-region" class="level3">
<h3 class="anchored" data-anchor-id="compare-with-runner-up-region">Compare with runner-up region</h3>
<p>For context, I compared East Midlands to Yorkshire and Humber, the region with the second-highest relative increase.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Get data for runner-up with baseline only</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a>runnerup_data <span class="ot"><-</span> hospital_cases <span class="sc">|></span> </span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(region <span class="sc">==</span> region_runnerup) <span class="sc">|></span> </span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">left_join</span>(</span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> hospital_cases <span class="sc">|></span> </span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(year <span class="sc">==</span> <span class="dv">2023</span>, region <span class="sc">==</span> region_runnerup) <span class="sc">|></span> </span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(week, <span class="at">baseline_cases =</span> cases),</span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a> <span class="at">by =</span> <span class="st">"week"</span></span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">|></span> </span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(</span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a> <span class="at">threshold_poisson =</span> baseline_cases <span class="sc">+</span> <span class="fl">1.96</span> <span class="sc">*</span> <span class="fu">sqrt</span>(baseline_cases),</span>
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a> <span class="at">alert =</span> cases <span class="sc">></span> threshold_poisson</span>
<span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">|></span> </span>
<span id="cb11-14"><a href="#cb11-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(year <span class="sc">==</span> <span class="dv">2024</span>, <span class="sc">!</span><span class="fu">is.na</span>(baseline_cases))</span>
<span id="cb11-15"><a href="#cb11-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-16"><a href="#cb11-16" aria-hidden="true" tabindex="-1"></a><span class="co"># Plot both regions</span></span>
<span id="cb11-17"><a href="#cb11-17" aria-hidden="true" tabindex="-1"></a><span class="fu">bind_rows</span>(</span>
<span id="cb11-18"><a href="#cb11-18" aria-hidden="true" tabindex="-1"></a> current_2024 <span class="sc">|></span> <span class="fu">mutate</span>(<span class="at">region =</span> region_focus, <span class="at">alert =</span> alert_poisson),</span>
<span id="cb11-19"><a href="#cb11-19" aria-hidden="true" tabindex="-1"></a> runnerup_data <span class="sc">|></span> <span class="fu">mutate</span>(<span class="at">region =</span> region_runnerup)</span>
<span id="cb11-20"><a href="#cb11-20" aria-hidden="true" tabindex="-1"></a>) <span class="sc">|></span> </span>
<span id="cb11-21"><a href="#cb11-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x =</span> week, <span class="at">y =</span> cases)) <span class="sc">+</span></span>
<span id="cb11-22"><a href="#cb11-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_line</span>(<span class="fu">aes</span>(<span class="at">color =</span> <span class="st">"2024 observed"</span>), <span class="at">linewidth =</span> <span class="dv">1</span>) <span class="sc">+</span></span>
<span id="cb11-23"><a href="#cb11-23" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_line</span>(<span class="fu">aes</span>(<span class="at">y =</span> baseline_cases, <span class="at">color =</span> <span class="st">"2023 baseline"</span>),</span>
<span id="cb11-24"><a href="#cb11-24" aria-hidden="true" tabindex="-1"></a> <span class="at">linetype =</span> <span class="st">"dashed"</span>, <span class="at">linewidth =</span> <span class="fl">0.8</span>) <span class="sc">+</span></span>
<span id="cb11-25"><a href="#cb11-25" aria-hidden="true" tabindex="-1"></a> <span class="fu">facet_wrap</span>(<span class="sc">~</span>region) <span class="sc">+</span></span>
<span id="cb11-26"><a href="#cb11-26" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_color_manual</span>(<span class="at">values =</span> <span class="fu">c</span>(</span>
<span id="cb11-27"><a href="#cb11-27" aria-hidden="true" tabindex="-1"></a> <span class="st">"2024 observed"</span> <span class="ot">=</span> <span class="st">"#3498db"</span>,</span>
<span id="cb11-28"><a href="#cb11-28" aria-hidden="true" tabindex="-1"></a> <span class="st">"2023 baseline"</span> <span class="ot">=</span> <span class="st">"#2c3e50"</span>,</span>
<span id="cb11-29"><a href="#cb11-29" aria-hidden="true" tabindex="-1"></a> <span class="st">"Poisson limit"</span> <span class="ot">=</span> <span class="st">"#e67e22"</span></span>
<span id="cb11-30"><a href="#cb11-30" aria-hidden="true" tabindex="-1"></a> )) <span class="sc">+</span></span>
<span id="cb11-31"><a href="#cb11-31" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
<span id="cb11-32"><a href="#cb11-32" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"Outbreak signals: East Midlands (80% alert rate) vs Yorkshire and Humber"</span>,</span>
<span id="cb11-33"><a href="#cb11-33" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="st">"Week"</span>,</span>
<span id="cb11-34"><a href="#cb11-34" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="st">"Cases"</span>,</span>
<span id="cb11-35"><a href="#cb11-35" aria-hidden="true" tabindex="-1"></a> <span class="at">color =</span> <span class="st">""</span></span>
<span id="cb11-36"><a href="#cb11-36" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb11-37"><a href="#cb11-37" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_minimal</span>() <span class="sc">+</span></span>
<span id="cb11-38"><a href="#cb11-38" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">legend.position =</span> <span class="st">"bottom"</span>)</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="02_day2_outbreak_files/figure-html/comparison-plot-1.png" class="img-fluid figure-img" width="672"></p>
<figcaption>Comparison with runner-up region (Yorkshire and Humber)</figcaption>
</figure>
</div>
</div>
</div>
</section>
<section id="regional-comparison" class="level3">
<h3 class="anchored" data-anchor-id="regional-comparison">Regional Comparison</h3>
<p>I applied the same method to all regions for weeks with baseline data.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Calculate alerts for all regions (weeks with baseline only)</span></span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>regional_2024 <span class="ot"><-</span> hospital_cases <span class="sc">|></span> </span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(year <span class="sc">==</span> <span class="dv">2024</span>) <span class="sc">|></span> </span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">left_join</span>(</span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> hospital_cases <span class="sc">|></span> </span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(year <span class="sc">==</span> <span class="dv">2023</span>) <span class="sc">|></span> </span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(region, week, <span class="at">baseline_cases =</span> cases),</span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a> <span class="at">by =</span> <span class="fu">c</span>(<span class="st">"region"</span>, <span class="st">"week"</span>)</span>
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">|></span> </span>
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(baseline_cases)) <span class="sc">|></span> </span>
<span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(</span>
<span id="cb12-12"><a href="#cb12-12" aria-hidden="true" tabindex="-1"></a> <span class="at">threshold_poisson =</span> baseline_cases <span class="sc">+</span> <span class="fl">1.96</span> <span class="sc">*</span> <span class="fu">sqrt</span>(baseline_cases),</span>
<span id="cb12-13"><a href="#cb12-13" aria-hidden="true" tabindex="-1"></a> <span class="at">alert =</span> cases <span class="sc">></span> threshold_poisson,</span>
<span id="cb12-14"><a href="#cb12-14" aria-hidden="true" tabindex="-1"></a> <span class="at">excess_pct =</span> (cases <span class="sc">-</span> baseline_cases) <span class="sc">/</span> baseline_cases <span class="sc">*</span> <span class="dv">100</span>,</span>
<span id="cb12-15"><a href="#cb12-15" aria-hidden="true" tabindex="-1"></a> <span class="at">alert_strength =</span> <span class="fu">ifelse</span>(alert, excess_pct, <span class="dv">0</span>)</span>
<span id="cb12-16"><a href="#cb12-16" aria-hidden="true" tabindex="-1"></a> )</span>
<span id="cb12-17"><a href="#cb12-17" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-18"><a href="#cb12-18" aria-hidden="true" tabindex="-1"></a><span class="co"># Heatmap of alert intensity</span></span>
<span id="cb12-19"><a href="#cb12-19" aria-hidden="true" tabindex="-1"></a>regional_2024 <span class="sc">|></span> </span>
<span id="cb12-20"><a href="#cb12-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x =</span> week, <span class="at">y =</span> <span class="fu">reorder</span>(region, <span class="fu">desc</span>(region)), <span class="at">fill =</span> alert_strength)) <span class="sc">+</span></span>
<span id="cb12-21"><a href="#cb12-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_tile</span>() <span class="sc">+</span></span>
<span id="cb12-22"><a href="#cb12-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_fill_gradient2</span>(<span class="at">low =</span> <span class="st">"white"</span>, <span class="at">mid =</span> <span class="st">"yellow"</span>, <span class="at">high =</span> <span class="st">"red"</span>,</span>
<span id="cb12-23"><a href="#cb12-23" aria-hidden="true" tabindex="-1"></a> <span class="at">midpoint =</span> <span class="dv">50</span>, <span class="at">name =</span> <span class="st">"Excess</span><span class="sc">\n</span><span class="st">%"</span>,</span>
<span id="cb12-24"><a href="#cb12-24" aria-hidden="true" tabindex="-1"></a> <span class="at">na.value =</span> <span class="st">"white"</span>) <span class="sc">+</span></span>
<span id="cb12-25"><a href="#cb12-25" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(</span>
<span id="cb12-26"><a href="#cb12-26" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"C. difficile outbreak signals by region (2024)"</span>,</span>
<span id="cb12-27"><a href="#cb12-27" aria-hidden="true" tabindex="-1"></a> <span class="at">subtitle =</span> <span class="st">"Only weeks with 2023 baseline shown. East Midlands: 4/5 weeks alert."</span>,</span>
<span id="cb12-28"><a href="#cb12-28" aria-hidden="true" tabindex="-1"></a> <span class="at">x =</span> <span class="st">"Week number"</span>,</span>
<span id="cb12-29"><a href="#cb12-29" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> <span class="st">""</span>,</span>
<span id="cb12-30"><a href="#cb12-30" aria-hidden="true" tabindex="-1"></a> <span class="at">caption =</span> <span class="st">"White = no baseline or no alert. Colour intensity shows % above Poisson 95% limit."</span></span>
<span id="cb12-31"><a href="#cb12-31" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb12-32"><a href="#cb12-32" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_minimal</span>() <span class="sc">+</span></span>
<span id="cb12-33"><a href="#cb12-33" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">axis.text.y =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">8</span>))</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="02_day2_outbreak_files/figure-html/regional-heatmap-1.png" class="img-fluid figure-img" width="672"></p>
<figcaption>Outbreak signals by region (2024) - weeks with baseline only</figcaption>
</figure>
</div>
</div>
</div>
<section id="regional-summary" class="level4">
<h4 class="anchored" data-anchor-id="regional-summary">Regional summary</h4>
<div class="cell" data-tbl-cap="Outbreak detection summary by region (weeks with baseline only)">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>region_alert_summary <span class="ot"><-</span> regional_2024 <span class="sc">|></span> </span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(region) <span class="sc">|></span> </span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(</span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a> <span class="at">weeks_with_baseline =</span> <span class="fu">n</span>(),</span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a> <span class="at">weeks_alert =</span> <span class="fu">sum</span>(alert, <span class="at">na.rm =</span> <span class="cn">TRUE</span>),</span>
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a> <span class="at">alert_rate =</span> weeks_alert <span class="sc">/</span> weeks_with_baseline <span class="sc">*</span> <span class="dv">100</span>,</span>
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a> <span class="at">mean_excess_alert =</span> <span class="fu">mean</span>(excess_pct[alert <span class="sc">==</span> <span class="cn">TRUE</span>], <span class="at">na.rm =</span> <span class="cn">TRUE</span>),</span>
<span id="cb13-8"><a href="#cb13-8" aria-hidden="true" tabindex="-1"></a> <span class="at">max_excess =</span> <span class="fu">max</span>(excess_pct, <span class="at">na.rm =</span> <span class="cn">TRUE</span>),</span>
<span id="cb13-9"><a href="#cb13-9" aria-hidden="true" tabindex="-1"></a> <span class="at">peak_cases =</span> <span class="fu">max</span>(cases, <span class="at">na.rm =</span> <span class="cn">TRUE</span>),</span>
<span id="cb13-10"><a href="#cb13-10" aria-hidden="true" tabindex="-1"></a> <span class="at">.groups =</span> <span class="st">"drop"</span></span>
<span id="cb13-11"><a href="#cb13-11" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">|></span> </span>
<span id="cb13-12"><a href="#cb13-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">arrange</span>(<span class="fu">desc</span>(alert_rate))</span>
<span id="cb13-13"><a href="#cb13-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-14"><a href="#cb13-14" aria-hidden="true" tabindex="-1"></a>region_alert_summary <span class="sc">|></span> </span>
<span id="cb13-15"><a href="#cb13-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="fu">across</span>(<span class="fu">where</span>(is.numeric), <span class="sc">~</span><span class="fu">round</span>(.,<span class="dv">1</span>))) <span class="sc">|></span> </span>
<span id="cb13-16"><a href="#cb13-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">kable</span>(<span class="at">caption =</span> <span class="st">"Outbreak detection by region"</span>)</span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<caption>Outbreak detection summary by region (weeks with baseline only)</caption>
<colgroup>
<col style="width: 20%">
<col style="width: 19%">
<col style="width: 11%">
<col style="width: 10%">
<col style="width: 17%">
<col style="width: 10%">
<col style="width: 10%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">region</th>
<th style="text-align: right;">weeks_with_baseline</th>
<th style="text-align: right;">weeks_alert</th>
<th style="text-align: right;">alert_rate</th>
<th style="text-align: right;">mean_excess_alert</th>
<th style="text-align: right;">max_excess</th>
<th style="text-align: right;">peak_cases</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">East Midlands</td>
<td style="text-align: right;">5</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">80</td>
<td style="text-align: right;">46.1</td>
<td style="text-align: right;">68.9</td>
<td style="text-align: right;">77</td>
</tr>
<tr class="even">
<td style="text-align: left;">London</td>
<td style="text-align: right;">5</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">40</td>
<td style="text-align: right;">74.0</td>
<td style="text-align: right;">96.3</td>
<td style="text-align: right;">106</td>
</tr>
<tr class="odd">
<td style="text-align: left;">North West</td>
<td style="text-align: right;">5</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">40</td>
<td style="text-align: right;">49.9</td>
<td style="text-align: right;">58.9</td>
<td style="text-align: right;">178</td>
</tr>
<tr class="even">
<td style="text-align: left;">South West</td>
<td style="text-align: right;">5</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">40</td>
<td style="text-align: right;">40.2</td>
<td style="text-align: right;">49.1</td>
<td style="text-align: right;">92</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Yorkshire and Humber</td>
<td style="text-align: right;">5</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">40</td>
<td style="text-align: right;">34.5</td>
<td style="text-align: right;">37.5</td>
<td style="text-align: right;">77</td>
</tr>
<tr class="even">
<td style="text-align: left;">North East</td>
<td style="text-align: right;">5</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">40.6</td>
<td style="text-align: right;">40.6</td>
<td style="text-align: right;">45</td>
</tr>
<tr class="odd">
<td style="text-align: left;">South East</td>
<td style="text-align: right;">5</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">58.7</td>
<td style="text-align: right;">58.7</td>
<td style="text-align: right;">119</td>
</tr>
<tr class="even">
<td style="text-align: left;">West Midlands</td>
<td style="text-align: right;">5</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">24.1</td>
<td style="text-align: right;">24.1</td>
<td style="text-align: right;">98</td>
</tr>
<tr class="odd">
<td style="text-align: left;">East of England</td>
<td style="text-align: right;">5</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">NaN</td>
<td style="text-align: right;">14.1</td>
<td style="text-align: right;">89</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
</section>
</section>
<section id="findings" class="level2">
<h2 class="anchored" data-anchor-id="findings">Findings</h2>
<section id="key-results" class="level3">
<h3 class="anchored" data-anchor-id="key-results">Key results</h3>
<p>The analysis shows the following results:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th>Finding</th>
<th>Implication</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>East Midlands: 80% alert rate</td>
<td>4 of 5 comparable weeks exceed the Poisson threshold</td>
</tr>
<tr class="even">
<td>Other regions: 0-40% alert rate</td>
<td>East Midlands is an outlier</td>
</tr>
<tr class="odd">
<td>Mean excess in alert weeks: 46%</td>
<td>Cases are consistently above baseline</td>
</tr>
<tr class="even">
<td>Consistency across weeks</td>
<td>Pattern suggests ongoing transmission</td>
</tr>
</tbody>
</table>
<p>The North West has the highest peak (178 cases) and largest total increase, but its alert rate is 40% – half that of East Midlands.</p>
</section>
<section id="public-health-response" class="level3">
<h3 class="anchored" data-anchor-id="public-health-response">Public Health Response</h3>
<p>These findings would trigger:</p>
<ol type="1">
<li><p>Alert to East Midlands Health Protection Team</p></li>
<li><p>Request for line lists to identify common wards, procedures, or patient characteristics</p></li>
<li><p>Enhanced surveillance in other regions with alerts</p></li>
<li><p>Review of infection control practices in East Midlands hospitals</p></li>
<li><p>National briefing on regional variation</p></li>
</ol>
</section>
<section id="limitations" class="level3">
<h3 class="anchored" data-anchor-id="limitations">Limitations</h3>
<ul>
<li>Only 5 weeks could be assessed; other weeks may hide signals</li>
<li>Single-year baseline assumes stability</li>
<li>No denominator data (rates per 1,000 bed days) was available</li>