-
Notifications
You must be signed in to change notification settings - Fork 0
/
Analysis_Spatial_Temporal_Vaccination.Rmd
4045 lines (3405 loc) · 154 KB
/
Analysis_Spatial_Temporal_Vaccination.Rmd
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
---
title: "Bayesian hierarchical models for space-temporal modeling of COVID-19 in Catalonia. Vaccination analysis"
#Data d'avui: Surt segons idioma d R
date: "`r format(Sys.time(), '%d %B, %Y')`"
knit: (function(inputFile, encoding) {
rmarkdown::render(inputFile,
encoding=encoding,
output_file="Reports/Analysis_Spatial_Temporal_Vaccination.html") })
output:
html_document:
toc: true
toc_float:
collapsed: true
smooth_scroll: true
theme: cosmo
highlight: tango
number_sections: true
editor_options:
chunk_output_type: console
---
```{r results='hide', echo=FALSE, include=FALSE, warning=FALSE, message=FALSE}
rm(list=ls())
library(gtsummary)
library(INLA)
library(captioner)
library(dplyr)
library(kableExtra)
library(ggplot2)
library(effectsize)
library(tidyr)
library(purrr)
library(lubridate)
library(stringr)
library(sf)
library(patchwork)
library(viridis)
library(GGally)
library(mvtsplot)
library(usdm)
library(tibble)
library(ggridges)
library(plotly)
library(DT)
#Enumerar taules i figures
fig_nums <- captioner(prefix = 'Figure')
tab_nums <- captioner(prefix = 'Table')
citef <- pryr::partial(fig_nums, display = 'cite')
citet <- pryr::partial(tab_nums, display = 'cite')
###############
#Load data by ABS and date
load("Data/dat.Rda")
#Load all incidences from the global of CAT
load("Data/1_Processed/dat_cat.Rda")
#Load all incidences from each sanitary regions
load("Data/1_Processed/dat_rs.Rda")
#Load shapefileT
load("Data/shapefileT.Rda")
#Load population
load("Data/1_Processed/pob_abs.Rda")
#Load cases for each outcome
load("Data/1_Processed/dat_edat.Rda")
load("Data/1_Processed/dat_hosp.Rda")
load("Data/1_Processed/dat_vac.Rda")
#Load covariates
load("Data/1_Processed/dat_covar.Rda")
#We need to compile SAE.R to have the 'dat_70' data and data in the '2_Analysed' folder
load("Data/dat_70.Rda")
#Vaccination effect
load("Data/2_Analysed/Vaccination/ndat_sae_raw.Rda")
load("Data/2_Analysed/Vaccination/ndat_sae_vac.Rda")
load("Data/2_Analysed/Vaccination/ndat_sae_vac_lag2.Rda")
load("Data/2_Analysed/Vaccination/ndat_sae_70.Rda")
load("Data/2_Analysed/Vaccination/ndat_sae_70_raw.Rda")
load("Data/2_Analysed/Vaccination/ndat_sae_70_lag2.Rda")
load("Data/2_Analysed/Vaccination/ndat_sae_vac_nocovar.Rda")
```
# Description
Full vaccination is defined as administrations of second doses or administrations of one shot (J&J) vaccines. For the analysis, we will consider the cumulative percentage of full vaccination individuals as weekly rates don't take in account previous history of vaccines administered. Because administered vaccines in a given time point can have an effect in posterior time outcomes,we have to take in account all the entire vaccination history in that area.
`r tab_nums("tab_vac_cum", "Descriptive table of the cumulative full vaccination counts and percentage of all ABS in the whole period")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
theme_gtsummary_journal(journal = "jama")
list("style_number-arg:big.mark" = "") %>%
set_gtsummary_theme()
dat %>%
filter(data == max(data)) %>%
mutate(
rate_vac = rate_vac*100
) %>%
dplyr::select(n_vac, rate_vac) %>%
tbl_summary(
label = list(n_vac ~ "ABS cumulative full vaccination counts",
rate_vac ~ "ABS cumulative full vaccination percentage (%)"),
type = list(all_continuous() ~ "continuous2"),
statistic = list(all_continuous() ~ c("{mean} ({sd})", "{median} ({p25}, {p75})"),
all_categorical() ~ "{n} ({p}%)"),
digits = list(all_categorical() ~ c(0,2),
all_continuous() ~ 2
)
) %>%
modify_header(label = "") %>%
as_kable_extra() %>%
kable_styling(bootstrap_options = c("striped","hover"))
```
```{r echo=FALSE, warning=FALSE, message=FALSE}
data_inici <- dmy(c("25/02/2020","01/10/2020","07/12/2020","15/03/2021","13/06/2021","02/11/2021"))
#Put the next sunday to get the first week in the wave
data_inici <- case_when(
wday(data_inici) != 1 ~ data_inici + (8-wday(data_inici)),
TRUE ~ data_inici
)
sdat_cat <- dat_cat %>%
rename_all(~ gsub("_vac", "", .x)) %>%
mutate(
xint = case_when(
data %in% data_inici ~ data
)
)
```
`r fig_nums("plot_vac", "Plot of the evolution of the weekly full vaccination rate per 100k habitants across the study period")`
```{r echo = FALSE, warning=FALSE, message=FALSE}
ggplot(data = sdat_cat, aes(x = data, y = rate)) +
geom_bar(stat = "identity",fill="#DD8888", alpha = 0.5)+
scale_x_date(date_breaks = "3 months", date_labels = "%Y-%m") +
geom_vline(aes(xintercept = xint), linetype = "dashed") +
theme_classic() +
theme(axis.line=element_blank(),axis.title.x=element_blank(), axis.ticks.y = element_blank()) +
ylab("Weekly full vaccination rate (x100,000 pop.)")
# png(r"(I:\CTebe\2_Projectes\2023_05TFMPS\4_Productes\2_Figures\evo_vac_weekly.png)",width = 4000,height = 2000,res = 600)
# ggplot(data = sdat_cat, aes(x = data, y = rate)) +
# geom_bar(stat = "identity",fill="#DD8888", alpha = 0.5)+
# scale_x_date(date_breaks = "3 months", date_labels = "%Y-%m") +
# geom_vline(aes(xintercept = xint), linetype = "dashed") +
# theme_classic() +
# theme(axis.line=element_blank(),axis.title.x=element_blank(), axis.ticks.y = element_blank()) +
# ylab("Weekly full vaccination rate (x100,000 pop.)")
# dev.off()
```
The 5th wave is were daily rates of full vaccination have their peak.
`r fig_nums("plot_vac_cum", "Plot of the evolution of the cumulative vaccination rate per 100k habitants across the study period")`
```{r echo = FALSE, warning=FALSE, message=FALSE}
ggplot(data = sdat_cat, aes(x = data, y = Trate)) +
geom_bar(stat = "identity",fill="#DD8888", alpha = 0.5)+
scale_x_date(date_breaks = "3 months", date_labels = "%Y-%m") +
geom_vline(aes(xintercept = xint), linetype = "dashed") +
theme_classic() +
theme(axis.line=element_blank(),axis.title.x=element_blank(), axis.ticks.y = element_blank()) +
ylab("Cumulative full vaccination percentage (%)")
# png(r"(I:\CTebe\2_Projectes\2023_05TFMPS\4_Productes\2_Figures\evo_vac_cum.png)",width = 4000,height = 2000,res = 600)
# ggplot(data = sdat_cat, aes(x = data, y = Trate)) +
# geom_bar(stat = "identity",fill="#DD8888", alpha = 0.5)+
# scale_x_date(date_breaks = "3 months", date_labels = "%Y-%m") +
# geom_vline(aes(xintercept = xint), linetype = "dashed") +
# theme_classic() +
# theme(axis.line=element_blank(),axis.title.x=element_blank(), axis.ticks.y = element_blank()) +
# ylab("Cumulative full vaccination percentage (%)")
# dev.off()
```
`r fig_nums("map_vac", "Map of the total cumulative full vaccination percentage across all the study period for each ABS")`
```{r echo = FALSE, warning=FALSE, message=FALSE}
sdat <- dat %>%
filter(data == ymd("2021-10-31")) %>%
mutate(
rate_vac = rate_vac*100
)
map <- st_as_sf(shapefileT) %>%
left_join(sdat, by = "abs")
cat <- ggplot(map) +
geom_sf(aes(fill = rate_vac)) +
theme_bw() +
theme(
axis.ticks = element_blank(),
axis.text = element_blank()
) +
# ggtitle("Cumulative full vaccination percentage") +
scale_fill_distiller(name = "%", palette = "YlOrRd", direction = 1)
#map of bcn
bcn <- ggplot(map) +
geom_sf(aes(fill = rate_vac)) +
theme_bw() +
theme(
axis.ticks = element_blank(),
axis.text = element_blank()
) +
scale_fill_distiller(name = "%", palette = "YlOrRd", direction = 1, guide = "none") +
coord_sf(
xlim = c(2.1, 2.25),
ylim = c(41.32, 41.475)
) +
theme(plot.margin = margin(0, 0, 0, 0, "cm"),
panel.grid.major = element_blank(), panel.grid.minor = element_blank()
)
m <- cat +
annotation_custom(
grob = ggplotGrob(bcn),
xmin = 2,
xmax = 3.8,
ymin = 40.5,
ymax = 41.4
) +
geom_segment(
x = 2.1,
xend = 2.48,
y = 41.32,
yend = 40.52,
linewidth = 0.1
) +
geom_segment(
x = 2.25,
xend = 3.33,
y = 41.48,
yend = 41.4,
linewidth = 0.1
) +
geom_rect(
xmin = 2.1,
xmax = 2.25,
ymin = 41.32,
ymax = 41.48,
alpha = 0,
color = "black"
)
m
# png(r"(C:\Users\psatorra\Documents\TFM\5_Productes\Figures\map_vac.png)",width = 3000,height = 2000,res = 600)
# m
# dev.off()
```
Percentages of fully vaccinated people in the last available date in the different areas go from 60% to 90%. Most of the areas have a percentage between 80 and 90% but there're some areas with a percentage a little bit lower around 70% and few with a percentage close to 90%.
`r fig_nums("plot_vac_rs", "Plot of the weekly fully vaccinated percentage by each of the sanitary regions along with the median across time")`
```{r echo = FALSE, warning=FALSE, message=FALSE}
#Method for plotting multivariate time series
# https://www.jstatsoft.org/article/view/v025c01
dat_plot <- dat_rs %>%
dplyr::select(data, NOMRS, rate_vac) %>%
pivot_wider(names_from = NOMRS, values_from = rate_vac) %>%
dplyr::select(-data)
mvtsplot(dat_plot, group = NULL, xtime = unique(dat_rs$data), norm = c("global"),
levels = 5, smooth.df = NULL, margin = TRUE,
palette = "YlOrRd", rowstat = "median", right.xlim = c(0, 100))
```
There're no differences in the pattern of each region as we measure a cumulative variable that is more difficult to have variability.
Let's see the distribution of the cumulative full vaccination percentage by age and sex groups.
`r fig_nums("sex_vac", "Cumulative full vaccination percentage in the whole period by sex groups")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
Tpob_vac <- pob_abs %>%
group_by(any, sexe, edat_vac) %>%
summarise(NT = sum(N)) %>%
rename(edat = edat_vac)
plot_vac <- dat_vac %>%
group_by(sexe, edat) %>%
summarise(n = sum(n)) %>%
left_join(Tpob_vac %>% filter(any == 2020), by = c("sexe", "edat")) %>%
group_by(sexe) %>%
summarise(
n = sum(n),
NT = sum(NT)
) %>%
mutate(
Tratio = n/NT
) %>%
dplyr::select(sexe, Tratio)
ggplot(plot_vac, aes(x = sexe, y = Tratio * 100, fill = sexe)) +
geom_bar(stat = "identity") +
scale_y_continuous(breaks = seq(0, 100, by = 20)) +
expand_limits(y = 100) +
ylab("%") +
theme_minimal() +
scale_fill_brewer(palette = "Set2", guide = "none") +
scale_x_discrete(name = "", labels = c("Women", "Men"))
```
The vaccination percentage is very similar between the two sex groups.
`r fig_nums("age_sex_vac", "Cumulative hospitalization percentage in the whole period for every age and sex group")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
Tvac_total <- dat_vac %>%
group_by(sexe, edat) %>%
summarise(n = sum(n)) %>%
left_join(Tpob_vac %>% filter(any == 2020), by = c("sexe", "edat")) %>%
mutate(
Tratio = n/NT
) %>%
dplyr::select(sexe, edat, Tratio)
plot_vac <- Tvac_total %>%
mutate(
Tratio = case_when(
sexe == "Dona" ~ -Tratio,
TRUE ~ Tratio
),
#Put > 1 to 1
Tratio = case_when(
Tratio > 1 ~ 1,
Tratio < -1 ~ -1,
TRUE ~ Tratio
)
)
ggplot(plot_vac, aes(x = Tratio * 100, y = edat, fill = sexe)) +
geom_col() +
scale_x_continuous(breaks = seq(-100, 100, by = 20), labels = abs(seq(-100, 100, by = 20))) +
xlab("%") +
ylab("Age") +
theme_minimal() +
scale_fill_brewer(palette = "Set2", name = "", labels = c("Women", "Men"))
```
The oldest age groups are more vaccinated than the rest. The minimum age for vaccination is of 5 years. There're some groups of age that have a 100% of cumulative full vaccination. This can happen because we're counting J&J vaccines that in some individuals it was given twice after the fully immunization.
`r fig_nums("sex_vac_ts", "Evolution of the daily full vaccination percentage in function of the sex group")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
Tpob_sexe <- pob_abs %>%
group_by(any, sexe) %>%
summarise(N = sum(N))
add_vac_w <- tibble(data = seq(min(sdat_cat$data), min(dat_vac$data) - 1, 1), sexe = "Dona", n = 0)
add_vac_m <- tibble(data = seq(min(sdat_cat$data), min(dat_vac$data) - 1, 1), sexe = "Home", n = 0)
Tdat_vac <- dat_vac %>%
group_by(data, sexe) %>%
summarise(n = sum(n))
plot_vac <- rbind(add_vac_w, add_vac_m, Tdat_vac) %>%
mutate(any = year(data)) %>%
left_join(Tpob_sexe, by = c("any", "sexe")) %>%
mutate(
ratio = n*100000/N,
sexe = factor(sexe, levels = c("Home", "Dona")),
xint = case_when(
data %in% data_inici ~ data
)
)
# ggplot(plot_vac, aes(x = data, y = ratio, fill = sexe)) +
# geom_area() +
# scale_x_date(date_breaks = "3 months", date_labels = "%Y-%m") +
# ylab("Week full vaccination rate (x100k pop.)") +
# xlab("") +
# theme_minimal() +
# scale_fill_brewer(palette = "Set2", name = "", labels = c("Men", "Women"), direction = -1) +
# geom_vline(aes(xintercept = xint), linetype = "dashed")
ggplot(plot_vac, aes(x = data, y = ratio, color = sexe, group = sexe)) +
geom_line(linewidth = 0.8) +
scale_x_date(date_breaks = "3 months", date_labels = "%Y-%m") +
ylab("Week full vaccination rate (x100k pop.)") +
xlab("") +
theme_minimal() +
scale_color_brewer(palette = "Set2", name = "", labels = c("Men", "Women"), direction = -1) +
geom_vline(aes(xintercept = xint), linetype = "dashed")
```
In the beginning of the vaccination campaign the percentage of full vaccination in women was higher than in men while in the 4th wave it was compensated a bit. This might happen because there is more old women than old men and the first vaccinated population were the oldest one.
`r fig_nums("age_vac_ts", "Evolution of the daily full vaccination rate in function of the age group (bigger or lower than 70 years)")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
Tpob_edat <- pob_abs %>%
mutate(
edat_70 = case_when(
edat_cas %in% c("70-79", "80-89", "90+") ~ 1,
TRUE ~ 0
),
edat_70 = factor(edat_70, levels = 0:1, labels = c("<70 years", "≥70 years"))
) %>%
group_by(any, edat_70) %>%
summarise(N = sum(N))
Tdat_vac <- dat_vac %>%
mutate(
edat_70 = case_when(
edat %in% c("70 a 79", "80 o més") ~ 1,
TRUE ~ 0
),
edat_70 = factor(edat_70, levels = 0:1, labels = c("<70 years", "≥70 years"))
) %>%
group_by(data, edat_70) %>%
summarise(n = sum(n))
add_vac_l70 <- tibble(data = seq(min(sdat_cat$data), min(dat_vac$data) - 1, 1), edat_70 = "<70 years", n = 0)
add_vac_u70 <- tibble(data = seq(min(sdat_cat$data), min(dat_vac$data) - 1, 1), edat_70 = "≥70 years", n = 0)
plot_vac <- rbind(add_vac_l70, add_vac_u70, Tdat_vac) %>%
mutate(any = year(data)) %>%
left_join(Tpob_edat, by = c("any", "edat_70")) %>%
mutate(
ratio = n*100000/N,
xint = case_when(
data %in% data_inici ~ data
)
)
# ggplot(plot_vac, aes(x = data, y = ratio, fill = edat_70)) +
# geom_area() +
# scale_x_date(date_breaks = "3 months", date_labels = "%Y-%m") +
# ylab("Daily vaccination rate (x100k pop.)") +
# xlab("") +
# theme_minimal() +
# scale_fill_brewer(palette = "Pastel1", name = "", direction = -1) +
# geom_vline(aes(xintercept = xint), linetype = "dashed")
ggplot(plot_vac, aes(x = data, y = ratio, color = edat_70, group = edat_70)) +
geom_line(linewidth = 0.8) +
scale_x_date(date_breaks = "3 months", date_labels = "%Y-%m") +
ylab("Daily vaccination rate (x100k pop.)") +
xlab("") +
theme_minimal() +
scale_color_brewer(palette = "Pastel1", name = "", direction = -1) +
geom_vline(aes(xintercept = xint), linetype = "dashed")
# png(r"(C:\Users\psatorra\Documents\TFM\5_Productes\Figures\evo_vac_age.png)",width = 5000,height = 2000,res = 600)
# ggplot(plot_vac, aes(x = data, y = ratio, color = edat_70, group = edat_70)) +
# geom_line(linewidth = 0.8) +
# scale_x_date(date_breaks = "3 months", date_labels = "%Y-%m") +
# ylab("Daily vaccination rate (x100k pop.)") +
# xlab("") +
# theme_minimal() +
# scale_color_brewer(palette = "Pastel1", name = "", direction = -1) +
# geom_vline(aes(xintercept = xint), linetype = "dashed")
# dev.off()
```
In the first weeks of the vaccination campaign the full vaccination percentage of the oldest group is a lot bigger than in the youngest group (3th-4th wave) as they were vaccination before the younger population. In fact, from the 5th wave the rate of full vaccination of people older than 70 years old is nearly zero.
`r fig_nums("vac_urban", "Boxplot of cumulated full vaccination coverage in function of urban/rural areas")`
```{r echo = FALSE, warning=FALSE, message=FALSE}
sdat <- dat %>%
group_by(urban, abs) %>%
summarise(
n_vac = tail(n_vac, 1),
N = mean(N)
) %>%
mutate(
rate_vac = n_vac*100/N
)
ggplot(sdat, aes(x = urban, y = rate_vac, fill = urban)) +
geom_boxplot(outlier.shape = NA, na.rm = TRUE) +
geom_point(shape=21,position=position_jitterdodge()) +
ylab("Cumulative full vaccinations %") +
scale_fill_manual(name = "", values = c("#CCEBC5", "#DECBE4"), guide = "none") +
xlab("") +
theme_minimal()
```
We see that in general urban areas have a a little bit percentage of cumulative vaccinations.
# Analysis
We would like to assess the effect of the fully vaccinated weekly percentage in each area and each time. We will consider lagged values of the weekly percentage of vaccination, as being fully vaccinated doesn't give you inmediate inmutity and also the virus has an incubation time.
Furthermore, this is a complicated task as we're trying the assess a causal effect of a temporal variable and the conditions of the pandemic changes in time (testing efforts, covid-19 variants, restrictions in place...) so there can be many potential confounders. Because of this, we will try to stratify the period of analysis considering waves that have similar pandemic conditions. Nevertheless, we think that taking the expected values calculated at each week we're intrinsically controlling by the temporal conditions of the pandemic in all the territory although differences between the areas that change across time might still have a confounding role in the effect of study.
First, we will consider all the period. We will take one week more from the start because we want to study the effect of the lagged vaccination. Thus, we will start at the week of 2021-01-24.
Second, we will consider only the period between the beginning of the vaccination campaign (2021-01-03) in the 3rd wave until the end of the 4th wave (2021-06-13). This period is pretty homogeneous as the delta variant comes in the beginning of the 5th wave, the testing effort is the same and the restrictions in this period doesn't change much, dominated by the night curfew and the restrictions on meetings. Only in the beginning of may the night curfew restriction is lifted with the end of alarm state. The limitation of taking this period is that the percentage of fully vaccinated population is low in the beginning so it won't have a big effect on the outcomes.
Third, we will consider only the period in the 5th wave where the delta variant is predominant and the restrictions are not very tight (only midnight curfew is imposed in a short period in the incidence pick). The limitation of this period is that the variability of the vaccination percentage across the areas drops a lot in the 5th wave as most of the areas have a similar fully vaccinated percentage.
Finally, as we have seen the majority of people with 70 years old or more are vaccinated in the 3rd-4th wave. Thus, in this period we will study the effect of the full vaccination on the hospitalization outcome only taking in account the population older than 70 years old. In this group of age it is believed that vaccination has a bigger effect.
The models that have been considered in each scenario are the following:
- Raw spatio-temporal model
- Model adjusted only by the lagged vaccine effect
- Model adjusted by the lagged vaccine effect + Spatial covariates
- Model adjusted by the non-lagged vaccine effect + Spatial covariates
- Model adjusted by the SIR of the lagged vaccine effect + Spatial covariates
We will see that the results show that if we estimate the models with the SIR calculated in the whole period we generally see a strong effect of the vaccination, whereas if we calculate the SIR by week we also see a protective effect but it is close to significance. I think that because there is not enough variability on the vaccination in the different areas it's difficult for this variable to explaine the spatial variance of the outcomes, but it has more of an effect explaining the temporal variance. Thus, it's more complicated to get a effect on the model on the SIR by each week because it already incorporates intrinsically the temporal effect introducing the expected values of each week as an offset. Nevertheless, the results on the SIR with expected values in the whole period might still be confounded, although stratifying by waves, because we are trying to explain a quadratic effect of the vaccination in the geenral temporal trend with a linear one.
## All period
`r fig_nums("plot_evo_vac_all", "Plot of the evolution of the distribution of fully vaccinated percentage between areas (the median along with the interquantile range is represented) across all the period")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
sdat <- dat %>%
filter(data >= ymd("2021-01-24")) %>%
rename_all(~ gsub("_vac", "", .x))
ggplot(sdat, aes(x = data, y = rate*100, group = data)) +
geom_boxplot() +
ylab("Full vaccination %") +
scale_x_date(date_breaks = "3 months", date_labels = "%Y-%m")
```
### SIR by week
```{r echo=FALSE, warning=FALSE, message=FALSE}
sdat_sae <- rbind(
ndat_sae_raw %>%
filter(period == "All", effect == "sir") %>%
mutate(model = "Raw"),
ndat_sae_vac_nocovar %>%
filter(period == "All", effect == "sir") %>%
mutate(model = "Vaccination"),
ndat_sae_vac %>%
filter(period == "All", effect == "sir") %>%
mutate(model = "Vaccination + Covariates"),
ndat_sae_vac_lag2 %>%
filter(period == "All", effect == "sir") %>%
mutate(model = "Vaccination (2-week lag)")
)
```
First, let's illustrate the differences in the cumulative full vaccination percentage in all the period between the hot/cold spots estimated by the raw model on the hospitalization outcome.
`r fig_nums("hot_cold_spatial", "Difference on the vaccination rates between hot/mild/cold spots given by the residual spatial effect of the raw model on hospitalizations")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
p_spatial <- sdat_sae %>%
filter(model == "Raw", outcomes == "hosp") %>%
mutate(
p = map(res, ~ sapply(.x$marginals.random$idarea[unique(dat$idarea)], function(x) {1-inla.pmarginal(0, x)}))
) %>%
dplyr::select(p) %>%
unnest(p) %>%
mutate(p_cat = case_when(
p <= 0.2 ~ 1,
p < 0.8 ~ 2,
TRUE ~ 3
),
p_cat = factor(p_cat, levels = 1:3, labels = c("Cold spot", "Mild spot", "Hot spot"))) %>%
rownames_to_column("idarea") %>%
mutate(idarea = as.integer(idarea))
plot_vac <- sdat %>%
filter(data == max(data)) %>%
full_join(p_spatial, by = "idarea")
ggplot(plot_vac, aes(x = p_cat, y = rate*100, fill = p_cat)) +
geom_boxplot(outlier.shape=NA,na.rm=T) +
geom_point(shape=21,position=position_jitterdodge()) +
ylab("Full vaccination (%)") +
scale_fill_manual(values = c("#42e7e9", "white", "#bd1816"), guide = FALSE) +
xlab("") +
theme_minimal()
```
Hot spots have lower full vaccination percentages than cold spots, so we might think that the vaccination could explain some of the spatial effect.
Let's show the differences on the cumulative full vaccination percentage of the previous week between the estimated hot/cold spots of the actual week, for all the weeks of the study period.
`r fig_nums("hot_cold_spatial_temp", "Difference on the vaccination rates between hot/cold spots given by the residual spatio-temporal effect of the raw model on hospitalizations")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
data_inici <- dmy(c("25/02/2020","01/10/2020","07/12/2020","15/03/2021","13/06/2021","02/11/2021"))
p_spatial_temp <- sdat_sae %>%
filter(model == "Raw", outcomes == "hosp") %>%
mutate(
p = map(res, ~ sapply(.x$marginals.random$idareatime, function(x) {1-inla.pmarginal(0, x)}))
) %>%
dplyr::select(p) %>%
unnest(p) %>%
mutate(p_cat = case_when(
p <= 0.2 ~ 1,
p < 0.8 ~ 2,
TRUE ~ 3
),
p_cat = factor(p_cat, levels = 1:3, labels = c("Cold spot", "Mild spot", "Hot spot"))) %>%
rownames_to_column("id") %>%
mutate(id = as.integer(id))
plot_vac <- sdat %>%
mutate(id = row_number()) %>%
full_join(p_spatial_temp, by = "id") %>%
filter(p_cat != "Mild spot") %>%
mutate(p_cat = droplevels(p_cat),
group = as.numeric(factor(paste(data, p_cat))),
wave = case_when(
data < data_inici[2] ~ 1,
data < data_inici[3] ~ 2,
data < data_inici[4] ~ 3,
data < data_inici[5] ~ 4,
data < data_inici[6] ~ 5,
TRUE ~ 6
)
)
ggplot(plot_vac, aes(x = data, y = lag_rate1*100, fill = p_cat, group = group)) +
facet_wrap(~wave, ncol = 2, scales = "free") +
geom_boxplot(outlier.shape = NA, color = "#D3D3D3") +
ylab("Lagged full vaccination (%)") +
scale_fill_manual(name = "", values = c("#42e7e9", "#bd1816")) +
theme_minimal()
```
We can't see clear differences on the lagged cumulative full vaccination percentage between hot and cold spots.
`r fig_nums("hot_cold_all", "Difference on the vaccination rates between hot/cold spots given by the posterior RR effect of the raw model on hospitalizations")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
p_rr <- sdat_sae %>%
filter(model == "Raw", outcomes == "hosp") %>%
mutate(
p = map(res, ~ sapply(.x$summary.fitted.values$`1 cdf`, function(x) {1-x}))
) %>%
dplyr::select(p) %>%
unnest(p) %>%
mutate(p_cat = case_when(
p <= 0.2 ~ 1,
p < 0.8 ~ 2,
TRUE ~ 3
),
p_cat = factor(p_cat, levels = 1:3, labels = c("Cold spot", "Mild spot", "Hot spot"))) %>%
rownames_to_column("id") %>%
mutate(id = as.integer(id))
plot_vac <- sdat %>%
mutate(id = row_number()) %>%
full_join(p_rr, by = "id") %>%
filter(p_cat != "Mild spot") %>%
mutate(p_cat = droplevels(p_cat),
group = as.numeric(factor(paste(data, p_cat))),
wave = case_when(
data < data_inici[2] ~ 1,
data < data_inici[3] ~ 2,
data < data_inici[4] ~ 3,
data < data_inici[5] ~ 4,
data < data_inici[6] ~ 5,
TRUE ~ 6
))
ggplot(plot_vac, aes(x = data, y = lag_rate1*100, fill = p_cat, group = group)) +
facet_wrap(~wave, ncol = 2, scales = "free") +
geom_boxplot(outlier.shape = NA, color = "#D3D3D3") +
ylab("Lagged full vaccination (%)") +
scale_fill_manual(name = "", values = c("#42e7e9", "#bd1816")) +
theme_minimal()
```
It seems that across all period hot spots have systematically lower lagged cumulative values of full vaccination percentages than cold spots.
`r tab_nums("dic_waic_vac_all", "Description of estimated DIC and WAIC for all the models")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
taula <- sdat_sae %>%
mutate(
dic = map_dbl(res, ~.x$dic$dic),
waic = map_dbl(res, ~.x$waic$waic)
) %>%
dplyr::select(model, outcomes, dic, waic) %>%
pivot_wider(names_from = outcomes, values_from = c(dic, waic)) %>%
dplyr::select(model, dic_cas, waic_cas, dic_hosp, waic_hosp)
names(taula) <- c("", rep(c("DIC", "WAIC"), 2))
options(knitr.kable.NA = '')
kable(taula) %>%
kable_styling(bootstrap_options = c("striped", "hover")) %>%
add_header_above(c(" " = 1, "Cases" = 2, "Hospitalization" = 2))
```
For the cases outcome, adjusted models improve the model. For the hospitalization outcome, vaccination model alone fits better the data but adjusting by covariates doesn't fit better the data.
Let's explore the linearity of the relationships between the cumulative vaccination at the end of the studied period and the estimated spatial RR by the raw model.
`r fig_nums("lin_vac_cas", "Plot of the estimated spatial RR of the raw model on cases for each ABS in function of each one of the cumulative fully vaccination percentage at the end of the studied period")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
dat_rr <- sdat_sae %>%
filter(outcomes == "cas", model == "Raw") %>%
mutate(
rr = map(res, ~exp(.x$summary.random$idarea$mean[unique(dat$idarea)])),
p = map(res, ~ sapply(.x$marginals.random$idarea[unique(dat$idarea)], function(x) {1-inla.pmarginal(0, x)}))
)
spatial <- tibble(rr = dat_rr$rr[[1]], p = dat_rr$p[[1]]) %>%
unnest(p) %>%
mutate(p_cat = case_when(
p <= 0.2 ~ 1,
p < 0.8 ~ 2,
TRUE ~ 3
),
p_cat = factor(p_cat, levels = c(1, 3), labels = c("Coldspot", "Hotspot"))) %>%
rownames_to_column("idarea") %>%
mutate(idarea = as.integer(idarea))
plot_vac <- sdat %>%
filter(data == max(data)) %>%
full_join(spatial, by = "idarea")
ggplot(plot_vac, aes(x = rate, y = rr)) +
geom_point(shape=21,aes(fill = p_cat)) +
geom_smooth(color = alpha("black", 0.4)) +
geom_hline(yintercept = 1, linetype = "dotted") +
scale_y_continuous(trans = "log10") +
xlab("Fully vaccination (%)") +
ylab("RR") +
scale_fill_manual(name = "", values = c("#42e7e9", "#bd1816"), labels = c("Coldspots", "Hotspots"), na.value = "white", na.translate = FALSE) +
theme_minimal() +
theme(legend.position="top")
```
`r fig_nums("lin_vac_hosp", "Plot of the estimated spatial RR of the raw model on hospitalisations for each ABS in function of the fully vaccination that we will include in the model")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
dat_rr <- sdat_sae %>%
filter(outcomes == "hosp", model == "Raw") %>%
mutate(
rr = map(res, ~exp(.x$summary.random$idarea$mean[unique(dat$idarea)])),
p = map(res, ~ sapply(.x$marginals.random$idarea[unique(dat$idarea)], function(x) {1-inla.pmarginal(0, x)}))
)
spatial <- tibble(rr = dat_rr$rr[[1]], p = dat_rr$p[[1]]) %>%
unnest(p) %>%
mutate(p_cat = case_when(
p <= 0.2 ~ 1,
p < 0.8 ~ 2,
TRUE ~ 3
),
p_cat = factor(p_cat, levels = c(1, 3), labels = c("Coldspot", "Hotspot"))) %>%
rownames_to_column("idarea") %>%
mutate(idarea = as.integer(idarea))
plot_vac <- sdat %>%
filter(data == max(data)) %>%
full_join(spatial, by = "idarea")
ggplot(plot_vac, aes(x = rate, y = rr)) +
geom_point(shape=21,aes(fill = p_cat)) +
geom_smooth(color = alpha("black", 0.4)) +
geom_hline(yintercept = 1, linetype = "dotted") +
scale_y_continuous(trans = "log10") +
xlab("Fully vaccination (%)") +
ylab("RR") +
scale_fill_manual(name = "", values = c("#42e7e9", "#bd1816"), labels = c("Coldspots", "Hotspots"), na.value = "white", na.translate = FALSE) +
theme_minimal() +
theme(legend.position="top")
```
`r tab_nums("hp_vac_cases_all", "Estimated fixed effects and hyperparameters for each model on the cases outcome")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
#Estimated model hyperparameters mean and credible interval:
taula <- sdat_sae %>%
filter(outcomes == "cas") %>%
mutate(
hp = map2(model, res, function(x, y) {
est <- summary(y)$fixed %>%
as.data.frame() %>%
mutate(est = str_glue("{round(exp(mean), 2)} ({round(exp(`0.025quant`), 2)}, {round(exp(`0.975quant`), 2)})")) %>%
dplyr::select(est) %>%
rownames_to_column(var = "var") %>%
mutate(
var = factor(var, levels = c("(Intercept)", "lag_rate_vac1", "urbanUrban", "isc", "lag_rate_vac2"), labels = c("(Intercept)", "Full vaccination (1-week lag)", "Urban vs Rural", "Socioeconomic Index (SI)", "Full vaccination (2-week lags)"))
) %>%
mutate(
order = 1
)
hp <- y$summary.hyperpar %>%
as.data.frame() %>%
mutate(
id = row_number(),
est = case_when(
id == 2 ~ str_glue("{round(mean, 2)} ({round(`0.025quant`, 2)}, {round(`0.975quant`, 2)})"),
TRUE ~ str_glue("{round(1/sqrt(mean), 2)} ({round(1/sqrt(`0.025quant`), 2)}, {round(1/sqrt(`0.975quant`), 2)})")
)
) %>%
dplyr::select(est) %>%
rownames_to_column(var = "var") %>%
mutate(
order = 2
)
rbind(est, hp)
})
) %>%
dplyr::select(model, hp) %>%
unnest(hp) %>%
pivot_wider(names_from = "model", values_from = c("est")) %>%
arrange(order) %>%
dplyr::select(-order)
taula$var <- gsub("Precision for (.*)", "SD (\\1)", taula$var)
names(taula)[1] <- ""
kable(taula) %>%
kable_styling(bootstrap_options = c("striped", "hover")) %>%
pack_rows(
"Fixed effects", 1, 5
) %>%
pack_rows(
"Random effects", 6, 9
)
```
The vaccination has a protective effect of 6% at the significance limit. Considering 2-week lags this effect disappears.
$\phi$ values increase for adjusted models.
`r tab_nums("var_exp_vac_cases_all", "Percentage of explained variability by the spatial, temporal and spatio-temporal patterns of every model on the cases outcome")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
taula <- sdat_sae %>%
filter(outcomes == "cas") %>%
mutate(
var = map(res, ~as.data.frame(inla.hyperpar.sample(10000, .x)) %>%
dplyr::select(contains("Precision")) %>%
mutate_all(~1/.x) %>%
mutate(tvar = rowSums(.),
`Precision for idarea` = `Precision for idarea`/tvar,
`Precision for idtime` = `Precision for idtime`/tvar,
`Precision for idareatime` = `Precision for idareatime`/tvar
) %>%
summarise(across(-tvar, ~round(mean(.x)*100, 2)))
)
) %>%
unnest(var) %>%
dplyr::select(model, contains("Precision"))
names(taula) <- c("", "Variance Spatial (%)", "Variance Temporal (%)", "Variance Spatio-Temporal (%)")
kable(taula) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
```
The spatial variance increases in detriment of the temporal and spatio-temporal variance.
`r tab_nums("hp_vac_hosp_all", "Estimated fixed effects and hyperparameters for each model on the hospitalization outcome")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
#Estimated model hyperparameters mean and credible interval:
taula <- sdat_sae %>%
filter(outcomes == "hosp") %>%
mutate(
hp = map2(model, res, function(x, y) {
est <- summary(y)$fixed %>%
as.data.frame() %>%
mutate(est = str_glue("{round(exp(mean), 2)} ({round(exp(`0.025quant`), 2)}, {round(exp(`0.975quant`), 2)})")) %>%
dplyr::select(est) %>%
rownames_to_column(var = "var") %>%
mutate(
var = factor(var, levels = c("(Intercept)", "lag_rate_vac1", "urbanUrban", "isc", "lag_rate_vac2"), labels = c("(Intercept)", "Full vaccination (1-week lag)", "Urban vs Rural", "Socioeconomic Index (SI)", "Full vaccination (2-week lags)"))
) %>%
mutate(
order = 1
)
hp <- y$summary.hyperpar %>%
as.data.frame() %>%
mutate(
id = row_number(),
est = case_when(
id == 2 ~ str_glue("{round(mean, 2)} ({round(`0.025quant`, 2)}, {round(`0.975quant`, 2)})"),
TRUE ~ str_glue("{round(1/sqrt(mean), 2)} ({round(1/sqrt(`0.025quant`), 2)}, {round(1/sqrt(`0.975quant`), 2)})")
)
) %>%
dplyr::select(est) %>%
rownames_to_column(var = "var") %>%
mutate(
order = 2
)
rbind(est, hp)
})
) %>%
dplyr::select(model, hp) %>%
unnest(hp) %>%
pivot_wider(names_from = "model", values_from = c("est")) %>%
arrange(order) %>%
dplyr::select(-order)
taula$var <- gsub("Precision for (.*)", "SD (\\1)", taula$var)
names(taula)[1] <- ""
kable(taula) %>%
kable_styling(bootstrap_options = c("striped", "hover")) %>%
pack_rows(
"Fixed effects", 1, 5
) %>%
pack_rows(
"Random effects", 6, 9
)
```
The vaccination has a protective effect of 6% on the risk of hospitalization very at limit of significance and when adjusting by covariates the effect decreases slightly to 4% and is at limit of significance. Moreover, considering 2-week lags it decreases to 3%.
The role of the structural spatial effect increases a little bit when adjusted by the vaccination and decreases when adjusting further by covariates.
`r tab_nums("var_exp_vac_hosp_all", "Percentage of explained variability by the spatial, temporal and spatio-temporal patterns of every model on the hospitalization outcome")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
taula <- sdat_sae %>%
filter(outcomes == "hosp") %>%
mutate(
var = map(res, ~as.data.frame(inla.hyperpar.sample(10000, .x)) %>%
dplyr::select(contains("Precision")) %>%
mutate_all(~1/.x) %>%
mutate(tvar = rowSums(.),
`Precision for idarea` = `Precision for idarea`/tvar,
`Precision for idtime` = `Precision for idtime`/tvar,
`Precision for idareatime` = `Precision for idareatime`/tvar
) %>%
summarise(across(-tvar, ~round(mean(.x)*100, 2)))
)
) %>%
unnest(var) %>%
dplyr::select(model, contains("Precision"))
names(taula) <- c("", "Variance Spatial (%)", "Variance Temporal (%)", "Variance Spatio-Temporal (%)")
kable(taula) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
```
The spatial variance decreases for the adjusted models in benefit of the spatio-temporal variance.
### SIR whole period
```{r echo=FALSE, warning=FALSE, message=FALSE}
sdat_sae <- rbind(sdat_sae <- rbind(
ndat_sae_raw %>%
filter(period == "All", effect == "sir2") %>%
mutate(model = "Raw"),
ndat_sae_vac_nocovar %>%
filter(period == "All", effect == "sir2") %>%
mutate(model = "Vaccination"),
ndat_sae_vac %>%
filter(period == "All", effect == "sir2") %>%
mutate(model = "Vaccination + Covariates"),
ndat_sae_vac_lag2 %>%
filter(period == "All", effect == "sir2") %>%
mutate(model = "Vaccination (2-week lag)")
)
)
```
First, let's illustrate the differences in the cumulative full vaccination percentage in all the period between the hot/cold spots estimated by the raw model on the hospitalization outcome.
`r fig_nums("hot_cold_spatial_2", "Difference on the vaccination rates between hot/mild/cold spots given by the residual spatial effect of the raw model on hospitalizations")`
```{r echo=FALSE, warning=FALSE, message=FALSE}
p_spatial <- sdat_sae %>%
filter(model == "Raw", outcomes == "hosp") %>%
mutate(