-
Notifications
You must be signed in to change notification settings - Fork 0
/
school_reopening.m
920 lines (830 loc) · 29.7 KB
/
school_reopening.m
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
% Futility of school reopening
% This script runs sim_school to project the spread of the epidemic in a
% congregate setting like a school, and what will be detected from that
% outbreak, how long it will take to detect it, and how large the outbreak
% will grow.
close all; clear all; clc
%% Start with calling a function with:
% INPUTS:
% initial condition (I0)
% transmission rate (Reff)
% percent symptomatic (psym)
% time to seek testing if symptomatic (tseek)
% time to get test results back (tdelay)
% threshold for closing based on detected case (close_thresh)
% OUTPUTS:
% % infected over time (I_t)
% % detected cases over time (detI_t)
% time to detect first case (tfirst)
% outbreak size at time of detection (Ifirst)
% time to close (tclose)
% outbreak size at time of closing (Iclose)
% Set parameters
I0 =1; % number of initial infections in a school of 1,000
N = 1000;
Reff = 2.5;
psym = 0.21;
tseek = 3;
tdelay = 4;
sens = 0.85;
close_thresh = 1;
tvec = 0:0.01:120;
tvec = tvec';
alpha = 1/3; % 1/latency
gamma = 1/14; % 1/infection duration
pSEIR = [alpha, gamma];
[I_t,cumI_t, detI_t, detcumI_t, tfirst, Ifirst, tclose, Iclose] = sim_school(I0,N, tvec, Reff, pSEIR, psym, tseek,tdelay,sens, close_thresh);
%%
I0vec = linspace(0.4, 25,6);
I0vec = [0.4, 1, 3, 5,10,25]; % corresponding to low, medium, and high prevalence
colorsets2 = colormap(prism(6));
colorsets2= flip(colorsets2,1);
for i = 1:length(I0vec)
I0i=I0vec(i);
[I_t,cumI_t, detI_t, detcumI_t, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reff,pSEIR, psym, tseek,tdelay,sens, close_thresh);
I_ti(:,i)=I_t;
cumI_ti(:,i) = cumI_t;
detI_ti(:,i)=detI_t;
detcumI_ti(:,i) = detcumI_t;
tfirsti(i) = tfirst;
Ifirsti(i) = Ifirst;
tclosei(i) = tclose;
Iclosei(i) = Iclose;
end
% record continuous iterating through I0
I0veccont = linspace(0.4,25,60);
for i = 1:length(I0veccont)
I0i=I0veccont(i);
[I_t,cumI_t, detI_t, detcumI_t, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reff,pSEIR, psym, tseek,tdelay,sens, close_thresh);
tfirstci(i) = tfirst;
Ifirstci(i) = Ifirst;
tcloseci(i) = tclose;
Icloseci(i) = Iclose;
end
% calculate upperbound (1 in 10 reporting rate)
for i = 1:length(I0veccont)
I0i=I0veccont(i);
Reffi = 3.5;
[I_t,cumI_t, detI_t, detcumI_t, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
tfirstupi(i) = tfirst;
Ifirstupi(i) = Ifirst;
tcloseupi(i) = tclose;
Icloseupi(i) = Iclose;
end
% calculate lowerbound (1 in 3 reporting rate)
I0veclo = .6.*linspace(0.4,10,60);
for i = 1:length(I0veccont)
I0i=I0veccont(i);
Reffi = 2.2;
[I_t,cumI_t, detI_t, detcumI_t, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
tfirstloi(i) = tfirst;
Ifirstloi(i) = Ifirst;
tcloseloi(i) = tclose;
Icloseloi(i) = Iclose;
end
%% 4 panel figure varying I0, looking at infections and time to close
figure;
subplot(1,2,1)
for i = 1:length(I0vec)
plot(tvec, 100.*cumI_ti(:,i)./N, '-', 'Linewidth',2, 'color', colorsets2(i,:))
%plot(tvec, 100.*10.*detI_ti(:,i)./N, '-', 'Linewidth',2, 'color', colorsets2(i,:))
hold on
end
plot([30 30], [0 100], 'k-', 'LineWidth', 2)
i30 = find(tvec==30);
plot(30, 100*cumI_ti(i30,2)./N, 'r*' ,'LineWidth', 5)
xlabel('time (days)')
xlim([0 tvec(end)])
%ylim([0 50])
%ylabel('% of school quarantined')
ylabel('% of school infected')
legend('4 in 10,000','1 in 1000','3 in 1000', '5 in 1000', '10 in 1000','25 in 1000', 'Location', 'NorthWest')
legend boxoff
set(gca,'FontSize',18,'LineWidth',1.5)
%title('Percent quarantined')
title('Percent infected')
subplot(1,2,2)
plot(I0veccont, tcloseci, 'k-', 'LineWidth', 2)
hold on
plot(I0veccont, tcloseupi, 'k--', 'LineWidth',2)
plot(I0veccont, tcloseloi, 'k--', 'LineWidth',2)
for i =1:length(I0vec)
plot(I0vec(i), tclosei(i), '*', 'LineWidth', 4, 'color', colorsets2(i,:))
hold on
end
xlabel('Initial infections (out of 1000)')
ylabel('Time to close (days)')
set(gca,'FontSize',14,'LineWidth',1.5, 'Xscale', 'log')
title('Time to close')
ylim([0 max(tcloseloi)+1])
xlim([I0veccont(1) I0veccont(end)])
figure;
for i = 1:length(I0vec)
plot(I0vec(i), Ifirsti(i), '*', 'LineWidth', 10, 'color', colorsets2(i,:))
hold on
end
plot(I0veccont, Ifirstci, 'k-', 'LineWidth', 2)
hold on
plot(I0veccont, Ifirstupi, 'k--', 'LineWidth',2)
plot(I0veccont, Ifirstloi, 'k--', 'LineWidth',2)
hold on
for i = 1:length(I0vec)
plot(I0vec(i), Ifirsti(i), '*', 'LineWidth', 8, 'color', colorsets2(i,:))
hold on
end
xlabel('Initial infections (out of 1000)')
ylabel('Actual infections')
legend('4 in 10,000','1 in 1000','3 in 1000', '5 in 1000', '10 in 1000','25 in 1000', 'Location', 'NorthWest')
legend boxoff
set(gca,'FontSize',18,'LineWidth',1.5)
title('Effect of prevalence on infections at first case')
ylim([0 max(Ifirsti)+2])
xlim([I0veccont(1) I0veccont(end)])
figure;
for i = 1:length(I0vec)
%plot(tvec, 100.*cumI_ti(:,i)./N, '-', 'Linewidth',2, 'color', colorsets2(i,:))
plot(tvec, 100.*10.*detI_ti(:,i)./N, '-', 'Linewidth',2, 'color', colorsets2(i,:))
hold on
end
xlabel('time (days)')
xlim([0 tvec(end)])
ylim([0 70])
ylabel('% of school quarantined')
%ylabel('% of school infected')
legend('4 in 10,000','1 in 1000','3 in 1000', '5 in 1000', '10 in 1000','25 in 1000', 'Location', 'NorthWest')
legend boxoff
set(gca,'FontSize',18,'LineWidth',1.5)
title('Percent quarantined for different initial prevalences')
%title('Percent infected')
%% 6 panel figure for supplement varying I0
colorsets3 = [0.6667 0 1;0 0.5 0; 1 0 0];
figure;
subplot(3,2,1)
for i = 1:length(I0vec)
plot(tvec, cumI_ti(:,i), '-', 'Linewidth',2, 'color', colorsets2(i,:))
hold on
end
xlabel('time(days)')
xlim([0 tvec(end)])
ylim([0 0.5*N])
ylabel('Cumulative Infections')
legend('4 in 10,000','1 in 1000','3 in 1000', '5 in 1000', '7 in 1000', '10 in 1000', 'Location', 'NorthWest')
legend boxoff
set(gca,'FontSize',14,'LineWidth',1.5)
title('Total infections')
subplot(3,2,2)
for i = 1:length(I0vec)
plot(tvec, detcumI_ti(:,i), '--', 'Linewidth',2, 'color', colorsets2(i,:))
hold on
end
plot([tvec(1) tvec(end)], [1 1], 'k--', 'LineWidth',2)
plot([tvec(1) tvec(end)], [close_thresh*N/100, close_thresh*N/100], 'k-', 'LineWidth',2)
xlabel('time(days)')
xlim([0 tvec(end)])
ylim([0 (close_thresh*N/100)+10])
ylabel('Detected Infections')
legend('4 in 10,000','1 in 1000','3 in 1000', '5 in 1000', '7 in 1000', '10 in 1000', 'Location', 'NorthEast')
legend boxoff
set(gca,'FontSize',14,'LineWidth',1.5)
title('Expected cumulative detected infections')
subplot(3,2,3)
plot(I0veccont, tfirstci, 'k-', 'LineWidth',2)
hold on
%plot(I0veccont, tfirstupi, 'k--', 'LineWidth',2)
%plot(I0veccont, tfirstloi, 'k--', 'LineWidth',2)
for i =1:length(I0vec)
plot(I0vec(i), tfirsti(i), '*', 'LineWidth', 4, 'color', colorsets2(i,:))
hold on
end
xlabel('Initial infections (out of 1000)')
ylabel('Time to first detected infection (days)')
set(gca,'FontSize',14,'LineWidth',1.5)
title('Time to first detected case')
ylim([0 max(tfirsti)+1])
subplot(3,2,4)
plot(I0veccont, Ifirstci, 'b-', 'LineWidth', 2)
hold on
%plot(I0veccont, Ifirstupi, 'b--', 'LineWidth',2)
%plot(I0veccont, Ifirstloi, 'b--', 'LineWidth',2)
for i = 1:length(I0vec)
plot(I0vec(i), Ifirsti(i), '*', 'LineWidth', 4, 'color', colorsets2(i,:))
hold on
end
xlabel('Initial infections (out of 1000)')
ylabel('Number of infections')
set(gca,'FontSize',14,'LineWidth',1.5)
title('Number of infections at first detected case')
ylim([0 max(Ifirsti)+1])
subplot(3,2,5)
plot(I0veccont, tcloseci, 'k-', 'LineWidth', 2)
hold on
%plot(I0veccont, tcloseupi, 'k--', 'LineWidth',2)
%plot(I0veccont, tcloseloi, 'k--', 'LineWidth',2)
for i =1:length(I0vec)
plot(I0vec(i), tclosei(i), '*', 'LineWidth', 4, 'color', colorsets2(i,:))
hold on
end
xlabel('Initial infections (out of 1000)')
ylabel('Time to close (days)')
set(gca,'FontSize',14,'LineWidth',1.5)
title('Time to close')
ylim([0 max(tclosei)+1])
subplot(3,2,6)
plot(I0veccont,Icloseci, 'b-', 'LineWidth',2)
hold on
%plot(I0veccont, Icloseupi, 'b--', 'LineWidth',2)
%plot(I0veccont, Icloseloi, 'b--', 'LineWidth',2)
for i = 1:length(I0vec)
plot(I0vec(i), Iclosei(i), '*', 'LineWidth', 4, 'color', colorsets2(i,:))
hold on
end
xlabel('Initial infections (out of 1000)')
ylabel('Number of infections')
set(gca,'FontSize',14,'LineWidth',1.5)
title('Number of infections at close')
ylim([0 max(Icloseupi)+10])
% Compare total infections to detected infections
figure;
subplot(1,2,1)
i = 3;
plot(tvec, cumI_ti(:,i), '-', 'Linewidth',2, 'color', colorsets2(2,:))
hold on
plot(tvec, detcumI_ti(:,i), '--', 'Linewidth',2, 'color', colorsets2(2,:))
plot([tvec(1) tvec(end)], [1 1], 'k--', 'LineWidth',2)
plot([tvec(1) tvec(end)], [close_thresh*N/100, close_thresh*N/100], 'k-', 'LineWidth',2)
plot([tfirsti(i) tfirsti(i)], [0 Ifirsti(i)], 'k-', 'LineWidth',2)
plot([tclosei(i) tclosei(i)], [0 Iclosei(i)], 'k-', 'LineWidth',2)
xlabel('time (days)')
xlim([0 tvec(end)])
ylim([0 135])
ylabel('Infections')
legend('True infections', 'Detected cases', 'Location', 'NorthWest')
legend boxoff
title('Relationship between true infections and detected cases')
set(gca,'FontSize',18,'LineWidth',1.5)
ifirst = find(detcumI_ti(:,i)>1,1);
subplot(1,2,2)
plot(tvec(ifirst:end)-tfirsti(i), cumI_ti(ifirst:end,i)./detcumI_ti(ifirst:end,i), '-', 'Linewidth',2, 'color', colorsets2(2,:))
hold on
xlabel('time since first detected case (days)')
xlim([0 tvec(end)-tfirsti(i)])
%ylim([0 6])
%ylim([0 (close_thresh*N/100)+35])
ylabel('True infections per detected case')
title('True infections per case detected')
set(gca,'FontSize',18,'LineWidth',1.5)
%% Vary transmission rate
figure;
subplot(2,2,1)
for i = 1:length(I0vec)
plot(tvec, 100.*cumI_ti(:,i)./N, '-', 'Linewidth',2, 'color', colorsets2(i,:))
%plot(tvec, 100.*10.*detI_ti(:,i)./N, '-', 'Linewidth',2, 'color', colorsets2(i,:))
hold on
end
xlabel('time (days)')
xlim([0 tvec(end)])
i30 = find(tvec==30);
%plot(30, 100*cumI_ti(i30,2)./N, 'r*' ,'LineWidth', 8)
%ylim([0 50])
%ylabel('% of school quarantined')
ylabel('% of school infected')
legend('4 in 10,000','1 in 1000','3 in 1000', '5 in 1000', '10 in 1000','25 in 1000', 'Location', 'NorthWest')
legend boxoff
set(gca,'FontSize',18,'LineWidth',1.5)
%title('Percent quarantined')
title('Effect of prevalence on percent infected')
subplot(2,2,2)
plot(I0veccont, tcloseci, 'k-', 'LineWidth', 2)
hold on
plot(I0veccont, tcloseupi, 'k--', 'LineWidth',2)
plot(I0veccont, tcloseloi, 'k--', 'LineWidth',2)
for i =1:length(I0vec)
plot(I0vec(i), tclosei(i), '*', 'LineWidth', 10, 'color', colorsets2(i,:))
hold on
end
xlabel('Initial infections (out of 1000)')
ylabel('Time to close (days)')
set(gca,'FontSize',18,'LineWidth',1.5, 'Xscale', 'log')
title('Effect of prevalence on time to close')
ylim([5 max(tcloseloi)+1])
xlim([I0veccont(1) I0veccont(end)])
I0 = 5; % national average prevalence
Reffvec = [1.5, 2.5, 3, 3.5, 4, 5 ]; % corresponding to low, medium, and high prevalence
for i = 1:length(Reffvec)
Reffi=Reffvec(i);
[I_t,cumI_t, detI_t, detcumI_t, tfirst, Ifirst, tclose, Iclose] = sim_school(I0,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
I_ti(:,i)=I_t;
cumI_ti(:,i) = cumI_t;
detI_ti(:,i)=detI_t;
detcumI_ti(:,i) = detcumI_t;
cumcases(:,i) = detcumI_t;
tfirsti(i) = tfirst;
Ifirsti(i) = Ifirst;
tclosei(i) = tclose;
Iclosei(i) = Iclose;
end
% record continuous iterating through Reff
Reffveccont = linspace(1.5,5,60);
for i = 1:length(I0veccont)
Reffi=Reffveccont(i);
[I_t,cumI_t, detI_t, detcumI_t, tfirst, Ifirst, tclose, Iclose] = sim_school(I0,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
tfirstci(i) = tfirst;
Ifirstci(i) = Ifirst;
tcloseci(i) = tclose;
Icloseci(i) = Iclose;
end
% calculate upperbound (1 in 10 reporting rate)
for i = 1:length(Reffveccont)
Reffi=Reffveccont(i);
I0i = 2*I0;
[I_t,cumI_t, detI_t, detcumI_t, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
tfirstupi(i) = tfirst;
Ifirstupi(i) = Ifirst;
tcloseupi(i) = tclose;
Icloseupi(i) = Iclose;
end
% calculate lowerbound (1 in 3 reporting rate)
for i = 1:length(I0veccont)
Reffi=Reffveccont(i);
I0i = 0.6*I0;
[I_t,cumI_t, detI_t, detcumI_t, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
tfirstloi(i) = tfirst;
Ifirstloi(i) = Ifirst;
tcloseloi(i) = tclose;
Icloseloi(i) = Iclose;
end
% 2 panels below varying Reff
subplot(2,2,3)
for i = 1:length(Reffvec)
%plot(tvec, 100.*10.*detI_ti(:,i)./N, '-', 'Linewidth',2, 'color', colorsets2(i,:))
plot(tvec, 100.*cumI_ti(:,i)./N, '-', 'Linewidth',2, 'color', colorsets2(i,:))
hold on
end
xlabel('time (days)')
xlim([0 tvec(end)])
%ylim([0 50])
ylabel('% of school infected')
%ylabel('% of school quarantined')
legend('R_0=1.5','R_0=2.5', 'R_0=3', 'R_0=3.5', 'R_0=4', 'R_0=5', 'Location', 'NorthWest')
legend boxoff
set(gca,'FontSize',18,'LineWidth',1.5)
title('Effect of R_0 on percent infected')
%title('Percent quarantined')
ylim([0 100])
subplot(2,2,4)
plot(Reffveccont, tcloseci, 'k-', 'LineWidth', 2)
hold on
plot(Reffveccont, tcloseupi, 'k--', 'LineWidth',2)
plot(Reffveccont, tcloseloi, 'k--', 'LineWidth',2)
for i =1:length(I0vec)
plot(Reffvec(i), tclosei(i), '*', 'LineWidth', 10, 'color', colorsets2(i,:))
hold on
end
xlabel('R_0')
ylabel('Time to close (days)')
set(gca,'FontSize',18,'LineWidth',1.5)
title('Effect of R_0 on time to close')
ylim([5 max(tcloseloi)+1])
xlim([Reffveccont(1) Reffveccont(end)])
figure;
for i = 1:length(Reffvec)
plot(Reffvec(i), Ifirsti(i), '*', 'LineWidth', 8, 'color', colorsets2(i,:))
hold on
end
plot(Reffveccont, Ifirstci, 'k-', 'LineWidth', 2)
hold on
plot(Reffveccont, Ifirstupi, 'k--', 'LineWidth',2)
plot(Reffveccont, Ifirstloi, 'k--', 'LineWidth',2)
hold on
for i = 1:length(Reffvec)
plot(Reffvec(i), Ifirsti(i), '*', 'LineWidth', 8, 'color', colorsets2(i,:))
hold on
end
xlabel('R_0')
ylabel('Actual infections')
set(gca,'FontSize',18,'LineWidth',1.5)
title('Effect of R_0 on infections at first case')
legend('R_0=1.5','R_0=2.5', 'R_0=3', 'R_0=3.5', 'R_0=4', 'R_0=5', 'Location', 'NorthWest')
legend boxoff
ylim([0 max(Ifirsti)+2])
xlim([Reffveccont(1) Reffveccont(end)])
figure;
for i = 1:length(Reffvec)
plot(tvec, 100.*10.*detI_ti(:,i)./N, '-', 'Linewidth',2, 'color', colorsets2(i,:))
%plot(tvec, 100.*cumI_ti(:,i)./N, '-', 'Linewidth',2, 'color', colorsets2(i,:))
hold on
end
xlabel('time (days)')
xlim([0 tvec(end)])
%ylim([0 50])
%ylabel('% of school infected')
ylabel('% of school quarantined')
legend('R_0=2.2','R_0=2.5', 'R_0=3', 'R_0=3.5', 'R_0=4', 'R_0=5', 'Location', 'NorthWest')
legend boxoff
set(gca,'FontSize',18,'LineWidth',1.5)
%title('Total infections')
title('Percent quarantined for different R_0')
ylim([0 70])
%% 6 panel figure for supplement varying R0
figure;
subplot(3,2,1)
for i = 1:length(Reffvec)
plot(tvec, cumI_ti(:,i), '-', 'Linewidth',2, 'color', colorsets2(i,:))
hold on
end
xlabel('time (days)')
xlim([0 tvec(end)])
ylim([0 0.5*N])
ylabel('Cumulative Infections')
legend('R_0=2.2','R_0=2.5', 'R_0=3', 'R_0=3.5', 'R_0=4', 'R_0=5', 'Location', 'NorthWest')
legend boxoff
set(gca,'FontSize',14,'LineWidth',1.5)
title('Total infections')
subplot(3,2,2)
for i = 1:length(Reffvec)
plot(tvec, detcumI_ti(:,i), '--', 'Linewidth',2, 'color', colorsets2(i,:))
hold on
end
plot([tvec(1) tvec(end)], [1 1], 'k--', 'LineWidth',2)
plot([tvec(1) tvec(end)], [close_thresh*N/100, close_thresh*N/100], 'k-', 'LineWidth',2)
xlabel('time(days)')
xlim([0 tvec(end)])
ylim([0 (close_thresh*N/100)+10])
ylabel('Detected Infections')
legend('R_0=2.2','R_0=2.5', 'R_0=3', 'R_0=3.5', 'R_0=4', 'R_0=5', 'Location', 'NorthEast')
legend boxoff
set(gca,'FontSize',14,'LineWidth',1.5)
title('Expected cumulative detected infections')
subplot(3,2,3)
plot(Reffveccont, tfirstci, 'k-', 'LineWidth',2)
hold on
%plot(I0veccont, tfirstupi, 'k--', 'LineWidth',2)
%plot(I0veccont, tfirstloi, 'k--', 'LineWidth',2)
for i =1:length(Reffvec)
plot(Reffvec(i), tfirsti(i), '*', 'LineWidth', 4, 'color', colorsets2(i,:))
hold on
end
xlabel('Initial infections (out of 1000)')
ylabel('Time to first detected infection (days)')
set(gca,'FontSize',14,'LineWidth',1.5)
title('Time to first detected case')
ylim([0 max(tfirsti)+1])
subplot(3,2,4)
plot(Reffveccont, Ifirstci, 'b-', 'LineWidth', 2)
hold on
%plot(I0veccont, Ifirstupi, 'b--', 'LineWidth',2)
%plot(I0veccont, Ifirstloi, 'b--', 'LineWidth',2)
for i = 1:length(I0vec)
plot(Reffvec(i), Ifirsti(i), '*', 'LineWidth', 4, 'color', colorsets2(i,:))
hold on
end
xlabel('R_0')
ylabel('Number of infections at first detected case')
set(gca,'FontSize',14,'LineWidth',1.5)
title('Number of infections when first case is detected')
ylim([0 max(Ifirsti)+1])
subplot(3,2,5)
plot(Reffveccont, tcloseci, 'k-', 'LineWidth', 2)
hold on
%plot(I0veccont, tcloseupi, 'k--', 'LineWidth',2)
%plot(I0veccont, tcloseloi, 'k--', 'LineWidth',2)
for i =1:length(Reffvec)
plot(Reffvec(i), tclosei(i), '*', 'LineWidth', 4, 'color', colorsets2(i,:))
hold on
end
xlabel('R_0')
ylabel('Time to close (days)')
set(gca,'FontSize',14,'LineWidth',1.5)
title('Time to close')
ylim([0 max(tclosei)+1])
subplot(3,2,6)
plot(Reffveccont,Icloseci, 'b-', 'LineWidth',2)
hold on
%plot(I0veccont, Icloseupi, 'b--', 'LineWidth',2)
%plot(I0veccont, Icloseloi, 'b--', 'LineWidth',2)
for i = 1:length(I0vec)
plot(Reffvec(i), Iclosei(i), '*', 'LineWidth', 4, 'color', colorsets2(i,:))
hold on
end
xlabel('R_0')
ylabel('Number of infections at time of close')
set(gca,'FontSize',14,'LineWidth',1.5)
title('Number of infections at time of close')
ylim([0 max(Icloseupi)+10])
%% Heatmaps of transmission vs initial prevalence colored by time to close
I0vec =linspace(0.1, 10,40);
Reffvec = linspace(1.1, 5,40);
tvec = 0:0.1:200;
[REFF,INIT] = meshgrid(Reffvec, I0vec); % big ol grid of parameters
REFFflat = reshape(REFF,1,[]);
INITflat = reshape(INIT,1, []);
for i = 1:length(REFFflat)
Reffi = REFFflat(i);
I0i = INITflat(i);
[I_t,cumI_t, detI_t, detcumI_t, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
tfirstj(i) = tfirst;
if isnan(tfirst);
tfirstj(i) = 180;
end
Ifirstj(i) = Ifirst;
if isnan(Ifirst)
ifirstj(i)=1;
end
tclosej(i) = tclose;
if isnan(tclose)
tclosej(i)=180;
end
Iclosej(i) = Iclose;
if isnan(Iclose)
Iclosej(i) = cumI_t(end);
end
end
TFIRST = reshape(tfirstj, size(REFF));
IFIRST = reshape(Ifirstj, size(REFF));
TCLOSE = reshape(tclosej, size(REFF));
ICLOSE = reshape(Iclosej, size(REFF));
%% Plot the heatmaps
figure;
subplot(1,2,2)
minmax = @(x)([min(x) max(x)]);
imagesc(minmax(1*(Reffvec)),minmax(I0vec),TCLOSE);
V = linspace(0,100,11);
V2 = horzcat(linspace(0,15,4), linspace(20,100,9));
[C,h]=contourf(REFF,INIT,TCLOSE); clabel(C,h);
[C2,h2]=contourf(REFF,INIT,TCLOSE, V2);
clabel(C2,h2);
[x,y,z] = C2xyz(C);
j=find(z==100);
R0crit=cell2mat(x(j));
I0crit =cell2mat(y(j));
%imagesc(minmax(1*(Reffvec)),minmax(I0vec),TCLOSE);
hold on
plot(x{j}, y{j}, 'w-', 'LineWidth', 5)
colorbar
colormap(flipud(jet));
caxis([7 100])
xlabel('R_0');
ylabel('Initial infected out of 1000');
title('Time to close (days)')
set(gca,'FontSize',20,'LineWidth',1.5)
subplot(1,2,1)
imagesc(minmax(1*(Reffvec)),minmax(I0vec),TFIRST);
%imagesc(minmax(1*(alphav)),minmax(tremv),PCTINF);
V = linspace(0, 100, 11);
[C,h]=contourf(Reffvec,I0vec,TFIRST, V2); clabel(C,h);
%imagesc(minmax(1*(Reffvec)),minmax(I0vec),TFIRST);
colorbar
colormap(flipud(jet));
caxis([7 100])
xlabel('R_0');
ylabel('Initial infected out of 1000');
title('Time to first detected case (days)')
set(gca,'FontSize',20,'LineWidth',1.5)
%%
figure;
subplot(1,2,1)
imagesc(minmax(1*(Reffvec)),minmax(I0vec),IFIRST);
%imagesc(minmax(1*(alphav)),minmax(tremv),PCTINF);
[C,h]=contourf(Reffvec,I0vec,IFIRST); clabel(C,h);
colorbar
colormap(jet);
xlabel('School R_0');
ylabel('Initial infected out of 1000');
title('Number infected out of 1000 at first detected case')
set(gca,'FontSize',18,'LineWidth',1.5)
% Make heatmap of number of additional community cases
%
Casesvec = linspace(10,900, 17);
Rtvec = linspace(0.8, 1.3,17);
tvec = 0:1:100;
[CASES, RT] = meshgrid(Casesvec,Rtvec); % big ol grid of parameters
RTflat = reshape(RT,1,[]);
CASESflat = reshape(CASES,1, []);
Tg = 13;
Ncom = 1e7;
n_intervals = 100./Tg;
for i = 1:length(RTflat)
RTi = RTflat(i);
CASESi = CASESflat(i);
addcases = [];
for j = 1:floor(n_intervals)
addcases(1) = CASESi.*RTi;
addcases(j+1) = addcases(j).*RTi;
end
addcases(floor(n_intervals)+1) = addcases(end)*(n_intervals-floor(n_intervals)).*RTi;
newcases = sum(addcases);
%newcases = CASESi.* RTi.^(100./Tg);
tvec = 0:0.01:100;
[I_t,cumI_t, ~, ~, ~,~, ~, ~] = sim_school(CASESi,Ncom,tvec, RTi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
ADDCASESSEIRi(i) = cumI_t(end);
ADDCASESi(i)= newcases;
end
ADDCASES = reshape(ADDCASESi, size(RT));
ADDCASESSEIR = reshape(ADDCASESSEIRi, size(RT));
subplot(1,2,2)
minmax = @(x)([min(x) max(x)]);
imagesc(minmax(Casesvec),minmax(Rtvec),ADDCASESSEIR);
V = linspace(0,24000,25);
[C,h]=contourf(Rtvec,Casesvec, ADDCASESSEIR,V);
clabel(C,h);
colorbar
colormap(jet);
ylabel('Cases seeded by school');
xlabel('Community R_{t}');
title('Additional community cases')
set(gca,'FontSize',18,'LineWidth',1.5)
%%
figure;
minmax = @(x)([min(x) max(x)]);
imagesc(minmax(Casesvec),minmax(Rtvec),ADDCASES);
V = linspace(0,24000,25)
[C,h]=contourf(Casesvec,Rtvec,ADDCASES, V); clabel(C,h);
colorbar
colormap(jet);
xlabel('Cases caused by school');
ylabel('Community R_{t}');
title('Additional community cases')
set(gca,'FontSize',14,'LineWidth',1.5)
%% Zoom in on safe reopening scenarios
%I0vec =linspace(0.1, 10,20);
%Reffvec = linspace(1.3, 5,20);
I0vec =linspace(0.1, 8,40);
Reffvec = linspace(1.3, 2,40);
tvec = 0:0.1:200;
[REFF,INIT] = meshgrid(Reffvec, I0vec); % big ol grid of parameters
REFFflat = reshape(REFF,1,[]);
INITflat = reshape(INIT,1, []);
for i = 1:length(REFFflat)
Reffi = REFFflat(i);
I0i = INITflat(i);
[I_t,cumI_t, detI_t, detcumI_t, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
tfirstj(i) = tfirst;
if isnan(tfirst);
tfirstj(i) = 180;
end
Ifirstj(i) = Ifirst;
if isnan(Ifirst)
ifirstj(i)=1;
end
tclosej(i) = tclose;
if isnan(tclose)
tclosej(i)=180;
end
Iclosej(i) = Iclose;
if isnan(Iclose)
Iclosej(i) = cumI_t(end);
end
end
TFIRST = reshape(tfirstj, size(REFF));
IFIRST = reshape(Ifirstj, size(REFF));
TCLOSE = reshape(tclosej, size(REFF));
ICLOSE = reshape(Iclosej, size(REFF));
% Plot the heatmaps
figure;
minmax = @(x)([min(x) max(x)]);
imagesc(minmax(1*(Reffvec)),minmax(I0vec),TCLOSE);
%imagesc(minmax(1*(alphav)),minmax(tremv),PCTINF);
[C,h]=contourf(REFF,INIT,TCLOSE); clabel(C,h);
[x,y,z] = C2xyz(C);
j=find(z==100);
R0crit=cell2mat(x(j));
I0crit =cell2mat(y(j));
hold on
plot(x{j}, y{j}, 'k-', 'LineWidth', 3)
colorbar
colormap(flipud(jet));
caxis([0 180])
xlabel('R_0');
ylabel('Initial infected out of 1000');
title('Time to close (days)')
set(gca,'FontSize',18,'LineWidth',1.5)
%% Scenarios
% K-12 high (25) medium (5) low prevalence(0.5), low resources R0=3(2.5,3.5),
% K-12 high medium low prevalence, high testing R0 = 1.5(1.2, 1.8)
% University national prevalence, low resources
% University national prevalence, high resources
% K-12 Public school low prevalence
psym = 0.2;
tdelay = 4;
N=1000;
I0i= 25;
I0hi = 2*I0i;
I0lo = 0.6*I0i;
Reffi= 3;
Reffhi = 3.5;
Refflo = 2.5;
[~,~, ~, ~, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirsthi, Ifirsthi, tclosehi, Iclosehi] = sim_school(I0hi,N,tvec, Reffhi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirstlo, Ifirstlo, tcloselo, Icloselo] = sim_school(I0lo,N,tvec, Refflo,pSEIR, psym, tseek,tdelay,sens, close_thresh);
matrix = zeros(8, 18);
matrix(1,:) = [Reffi, Refflo, Reffhi, I0i, I0lo, I0hi, tfirst, tfirstlo, tfirsthi, Ifirst, Ifirstlo, Ifirsthi, tclose, tcloselo, tclosehi, Iclose, Icloselo, Iclosehi];
% Public school medium prevalence
N=1000;
I0i= 5;
I0hi = 2*I0i;
I0lo = 0.6*I0i;
Reffi= 3;
Reffhi = 3.5;
Refflo = 2.5;
[~,~, ~, ~, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirsthi, Ifirsthi, tclosehi, Iclosehi] = sim_school(I0hi,N,tvec, Reffhi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirstlo, Ifirstlo, tcloselo, Icloselo] = sim_school(I0lo,N,tvec, Refflo,pSEIR, psym, tseek,tdelay,sens, close_thresh);
matrix(2,:) = [Reffi, Refflo, Reffhi, I0i, I0lo, I0hi, tfirst, tfirstlo, tfirsthi, Ifirst, Ifirstlo, Ifirsthi, tclose, tcloselo, tclosehi, Iclose, Icloselo, Iclosehi];
% Public school low prevalence
N=1000;
I0i= 0.5;
I0hi = 2*I0i;
I0lo = 0.6*I0i;
Reffi= 3;
Reffhi = 3.5;
Refflo = 2.5;
[~,~, ~, ~, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirsthi, Ifirsthi, tclosehi, Iclosehi] = sim_school(I0hi,N,tvec, Reffhi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirstlo, Ifirstlo, tcloselo, Icloselo] = sim_school(I0lo,N,tvec, Refflo,pSEIR, psym, tseek,tdelay,sens, close_thresh);
matrix(3,:) = [Reffi, Refflo, Reffhi, I0i, I0lo, I0hi, tfirst, tfirstlo, tfirsthi, Ifirst, Ifirstlo, Ifirsthi, tclose, tcloselo, tclosehi, Iclose, Icloselo, Iclosehi];
%Private local school high prevalence
tdelay =2;
N=1000;
I0i= 25;
I0hi = 2*I0i;
I0lo = 0.6*I0i;
Reffi= 1.5;
Reffhi = 1.8;
Refflo = 1.2;
[~,~, ~, ~, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirsthi, Ifirsthi, tclosehi, Iclosehi] = sim_school(I0hi,N,tvec, Reffhi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirstlo, Ifirstlo, tcloselo, Icloselo] = sim_school(I0lo,N,tvec, Refflo,pSEIR, psym, tseek,tdelay,sens, close_thresh);
row = [Reffi, Refflo, Reffhi, I0i, I0lo, I0hi, tfirst, tfirstlo, tfirsthi, Ifirst, Ifirstlo, Ifirsthi, tclose, tcloselo, tclosehi, Iclose, Icloselo, Iclosehi];
matrix(4,:) = row;
%Private local school in NE (i.e. NH) with lots of testing resources
N=1000;
I0i= 5;
I0hi = 2*I0i;
I0lo = 0.6*I0i;
Reffi= 1.5;
Reffhi = 1.8;
Refflo = 1.2;
[~,~, ~, ~, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirsthi, Ifirsthi, tclosehi, Iclosehi] = sim_school(I0hi,N,tvec, Reffhi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirstlo, Ifirstlo, tcloselo, Icloselo] = sim_school(I0lo,N,tvec, Refflo,pSEIR, psym, tseek,tdelay,sens, close_thresh);
row = [Reffi, Refflo, Reffhi, I0i, I0lo, I0hi, tfirst, tfirstlo, tfirsthi, Ifirst, Ifirstlo, Ifirsthi, tclose, tcloselo, tclosehi, Iclose, Icloselo, Iclosehi];
matrix(5,:) = row;
% Private local school in South (i.e. MS)
N=1000;
I0i= 0.5;
I0hi = 2*I0i;
I0lo = 0.6*I0i;
Reffi= 1.5;
Reffhi = 1.8;
Refflo = 1.2;
[~,~, ~, ~, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirsthi, Ifirsthi, tclosehi, Iclosehi] = sim_school(I0hi,N,tvec, Reffhi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirstlo, Ifirstlo, tcloselo, Icloselo] = sim_school(I0lo,N,tvec, Refflo,pSEIR, psym, tseek,tdelay,sens, close_thresh);
matrix(6,:) = [Reffi, Refflo, Reffhi, I0i, I0lo, I0hi, tfirst, tfirstlo, tfirsthi, Ifirst, Ifirstlo, Ifirsthi, tclose, tcloselo, tclosehi, Iclose, Icloselo, Iclosehi];
% College with lots of resources for testing
% Assume that tdelay is lower and the psym is higher
N=20000;
I0i= 100;
I0hi = 2*I0i;
I0lo = 0.6*I0i;
Reffi= 1.5;
Reffhi = 1.8;
Refflo = 1.2;
tdelay = 2;
psym = (0.6.*0.6)+ (0.2.*0.4); % weighted average of 18 & 19 year olds, 20, 21, 22, and 23 y.os
[~,~, ~, ~, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirsthi, Ifirsthi, tclosehi, Iclosehi] = sim_school(I0hi,N,tvec, Reffhi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirstlo, Ifirstlo, tcloselo, Icloselo] = sim_school(I0lo,N,tvec, Refflo,pSEIR, psym, tseek,tdelay,sens, close_thresh);
matrix(7,:) = [Reffi, Refflo, Reffhi, I0i, I0lo, I0hi, tfirst, tfirstlo, tfirsthi, Ifirst, Ifirstlo, Ifirsthi, tclose, tcloselo, tclosehi, Iclose, Icloselo, Iclosehi];
% College with limited resources
N=20000;
I0i= 100;
I0hi = 2*I0i;
I0lo = 0.6*I0i;
Reffi= 3;
Reffhi = 3.5;
Refflo = 2.5;
[~,~, ~, ~, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirsthi, Ifirsthi, tclosehi, Iclosehi] = sim_school(I0hi,N,tvec, Reffhi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, ~, tfirstlo, Ifirstlo, tcloselo, Icloselo] = sim_school(I0lo,N,tvec, Refflo,pSEIR, psym, tseek,tdelay,sens, close_thresh);
matrix(8,:) = [Reffi, Refflo, Reffhi, I0i, I0lo, I0hi, tfirst, tfirstlo, tfirsthi, Ifirst, Ifirstlo, Ifirsthi, tclose, tcloselo, tclosehi, Iclose, Icloselo, Iclosehi];
%% Example of infections versus detected cases
N=1000;
I0i= 5; % 5% prevalence, no entry testing
I0hi = 2*I0i;
I0lo = 0.6*I0i;
Reffi= 3;
Reffhi = 3.5;
Refflo = 2.5;
[I_t,cumI_t, detI_t, detcumI_t, tfirst, Ifirst, tclose, Iclose] = sim_school(I0i,N,tvec, Reffi,pSEIR, psym, tseek,tdelay,sens, close_thresh)
[~,~, ~, detcumI_thi, tfirsthi, Ifirsthi, tclosehi, Iclosehi] = sim_school(I0hi,N,tvec, Reffhi,pSEIR, psym, tseek,tdelay,sens, close_thresh);
[~,~, ~, detcumI_tlo, tfirstlo, Ifirstlo, tcloselo, Icloselo] = sim_school(I0lo,N,tvec, Refflo,pSEIR, psym, tseek,tdelay,sens, close_thresh);
figure;
hold on
plot(tvec(1:800), detcumI_t(1:800)*N/100, 'k-', 'LineWidth', 2)
plot(tvec(1:800), detcumI_thi(1:800)*N/100, 'k--', 'LineWidth', 2)
plot(tvec(1:800), detcumI_tlo(1:800)*N/100, 'k--', 'LineWidth', 2)
xlabel('time (days)')
ylabel('Detected cases')
title('UNC: first 8 days')
set(gca,'FontSize',14,'LineWidth',1.5)