-
Notifications
You must be signed in to change notification settings - Fork 0
/
sup_mat_COVID-19-vaccines-confer-protection-in-hospitalized-pregnant-and-postpartum-women-with-severe-COVID-19.Rmd
1359 lines (1037 loc) · 42.3 KB
/
sup_mat_COVID-19-vaccines-confer-protection-in-hospitalized-pregnant-and-postpartum-women-with-severe-COVID-19.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: "Documentation of the article 'COVID-19 vaccines confer protection in hospitalized pregnant and postpartum women with severe COVID-19'"
author: 'Codes and outputs'
date: "Feb 10, 2022"
header-includes:
- \usepackage{float}
- \renewcommand{\contentsname}{Sumário}
output:
html_document:
self_contained: no
word_document: default
pdf_document:
toc: yes
toc_depth: '1'
keep_tex: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
\newpage
# Description
This file presents the documentation of the analysis of article "COVID-19 vaccines confer protection in hospitalized pregnant and postpartum women with severe COVID-19".
# About the database and R packages used
The data are analyzed using the free-software R (https://www.R-project.org) in version 4.0.3. Next, we present and load the libraries used in the data analysis process.
```{r pacotes, echo=TRUE, message=FALSE, warning =FALSE,error=FALSE, results='hide'}
#load packages
loadlibrary <- function(x) {
if (!require(x, character.only = TRUE)) {
install.packages(x, dependencies = T)
if (!require(x, character.only = TRUE))
stop("Package not found")
}
}
packages <-
c(
"readr",
"readxl",
"janitor",
"dplyr",
"forcats",
"stringr",
"lubridate",
"summarytools",
"magrittr",
"questionr",
"knitr",
"data.table",
"modelsummary",
"kableExtra",
"DescTools",
"effectsize",
"WeightIt",
"MatchIt",
"ggplot2",
"ggpubr",
"naniar",
"mice",
"miceafter",
"VIM",
"miceadds"
)
lapply(packages, loadlibrary)
```
One can see below the functions that will be used in the data analysis.
```{r,echo=TRUE, eval=TRUE, message=FALSE,warning =FALSE,error=FALSE,results='hide'}
#functions for summary measures
media <- function(x)
mean(x, na.rm = TRUE)
mediana <- function(x)
median(x, na.rm = TRUE)
DP <- function(x)
sd(x, na.rm = TRUE)
minimo <- function(x)
base::min(x, na.rm = TRUE)
maximo <- function(x)
base::max(x, na.rm = TRUE)
q25 <- function(x)
stats::quantile(x, p = 0.25, na.rm = TRUE)
q75 <- function(x)
stats::quantile(x, p = 0.75, na.rm = TRUE)
IQR <- function(x)
round(q75(x) - q25(x), 2)
n <- function(x)
sum(!is.na(x))
```
This is a retrospective cohort study using the data from the Influenza Epidemiological Surveillance Information System, SIVEP-Gripe (Sistema de Informação de Vigilância Epidemiológica da Gripe) database.
The SIVEP-Gripe is a nationwide surveillance database created to monitor severe acute respiratory infections and data on virus circulation and respiratory infections in Brazil.
The period analyzed comprises epidemiological data from 2021, with a database obtained on December 2, 2021 on the website https://opendatasus.saude.gov.br. The dataset can be obtained at https://www.kaggle.com/agatharodrigues/covid19-vaccine-maternal-population. It is loaded below:
```{r,echo=FALSE, eval=TRUE, message=FALSE,warning =FALSE,error=FALSE,results='hide'}
memory.limit(999999)
```
```{r,echo=TRUE,message=FALSE,warning =FALSE,error=FALSE,results='hide'}
#loading the datasets
#2021
dados <- read_delim(
"INFLUD21-29-11-2021.csv",
";",
escape_double = FALSE,
locale = locale(encoding = "ISO-8859-2"),
trim_ws = TRUE
)
#Create case year variable
dados <- dados %>%
dplyr::mutate(
dt_sint = as.Date(DT_SIN_PRI, format = "%d/%m/%Y"), #date of first symptoms
dt_nasc = as.Date(DT_NASC, format = "%d/%m/%Y"), #date of birth
dt_vac_gripe = as.Date(DT_UT_DOSE, format = "%d/%m/%Y"), #date of Influenza vaccine
ano = lubridate::year(dt_sint), #year of the case
)
```
There are `r dim(dados)[1]` observations in the database. To see the dictionary of variables, access (in Portuguese):
https://opendatasus.saude.gov.br/dataset/ae90fa8f-3e94-467e-a33f-94adbb66edf8/resource/8f571374-c555-4ec0-8e44-00b1e8b11c25/download/dicionario-de-dados-srag-hospitalizado-27.07.2020-final.pdf
# Case selection and data treatment
The first filter is to select cases from May 02, 2021 (18th epidemiological week of symptoms of 2021) to November 27, 2021 (epidemiological week 47 of 2021).
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#selection of cases from 18th epidemiological week of symptoms (May 2, 2021)
#to November 27, 2021 (week 43 of 2021).
sem1 <- 18
sem2 <- 47
dados1 <- dados %>%
filter(SEM_PRI >= sem1 & SEM_PRI <= sem2)
```
There are `r dim(dados1)[1]` observations in the database after selection of valid years.
The next selection is female:
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#filtering F
dados2 <- filter(dados1, CS_SEXO == "F")
```
There are `r dim(dados2)[1]` observations in the database.
Selection of women of childbearing age (10 to 55 years):
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#creating the age variable as the difference between dt_sint and dt_nasc.
#In cases without dt_nasc, we consider
#the NU_AGE_N field
dados2 <- dados2 %>%
mutate(
idade = as.period(interval(start = dt_nasc, end = dt_sint))$year,
age = ifelse(is.na(idade), NU_IDADE_N, idade)
)
#Filtering of cases aged 55 and under
dados3 <- dados2 %>%
filter(age > 9 & age <= 55)
```
There are `r dim(dados3)[1]` observations in the database.
The next step is to identify pregnant and postpartum people (variable `classi_gesta_puerp`) and then select only those cases.
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#Creating the classification variable if pregnant, postpartum and
##neither pregnant nor postpartum
dados3 <- dados3 %>%
mutate(
classi_gesta_puerp = case_when(
CS_GESTANT == 1 ~ "1tri",
CS_GESTANT == 2 ~ "2tri",
CS_GESTANT == 3 ~ "3tri",
CS_GESTANT == 4 ~ "IG_ig",
CS_GESTANT == 5 &
PUERPERA == 1 ~ "puerp",
CS_GESTANT == 9 & PUERPERA == 1 ~ "puerp",
TRUE ~ "no"
)
)
freq(dados3$classi_gesta_puerp)
#filtering only pregnant and postpartum women
dados4 <- dados3 %>%
filter(classi_gesta_puerp != "no")
```
There are `r dim(dados4)[1]` observations in the database.
We selected only confirmed cases of COVID-19.
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
dados4 <- dados4 %>%
mutate(
classi_fin = case_when(
CLASSI_FIN == 5 ~ "covid",
TRUE ~ "no"
)
)
#filtering only covid cases
dados5 <- dados4 %>%
filter(CLASSI_FIN == 5)
```
There are `r dim(dados5)[1]` observations in the database.
Now let's select the cases of COVID by PCR or antigen, but which are also not positive for Influenza.
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#COVID case diagnosed by PCR
dados5 <- dados5 %>%
mutate(pcr_covid_SN = case_when(
(PCR_SARS2 == 1) |
(
str_detect(DS_PCR_OUT, "SARS|COVID|COV|CORONA|CIVID")
) ~ "yes",
TRUE ~ "no"
))
#Influenza case diagnosed by PCR
dados5 <- dados5 %>%
mutate(pcr_influenza_SN = case_when(
(POS_PCRFLU == 1) |
(
str_detect(DS_PCR_OUT, "INFLU|INFLUENZA")
) ~ "yes",
TRUE ~ "no"
))
with(dados5, table(pcr_influenza_SN, pcr_covid_SN))
```
There is no case that is positive for COVID and for Influenza by PCR.
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#Case of COVID diagnosed by antigen
dados5 <- dados5 %>%
mutate(antigenio_covid_SN = case_when(
(AN_SARS2 == 1) |
(
str_detect(DS_AN_OUT, "SARS|COVID|COV|CORONA|CIVID")
) ~ "yes",
TRUE ~ "no"
))
#Influenza case diagnosed by antigen
dados5 <- dados5 %>%
mutate(antigenio_influenza_SN = case_when(
(POS_AN_FLU == 1) |
(
str_detect(DS_AN_OUT, "INFLU|INFLUENZA")
) ~ "yes",
TRUE ~ "no"
))
with(dados5, table(antigenio_influenza_SN, antigenio_covid_SN))
```
There is one positive case for COVID and for Influenza by antigen.
We will now select the cases of COVID confirmed by PCR or antigen.
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
with(dados5, table(pcr_covid_SN, antigenio_covid_SN))
#filtering only covid cases by PCR or antigen
dados6 <- dados5 %>%
filter(pcr_covid_SN == "yes" | antigenio_covid_SN == "yes")
```
There are `r dim(dados6)[1]` observations in the database.
Now it's time to remove cases that are also positive for Influenza.
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
with(dados6, table(pcr_influenza_SN, antigenio_influenza_SN))
#filtering only negative cases of Influenza by PCR or antigen
dados7 <- dados6 %>%
filter(pcr_influenza_SN != "yes" & antigenio_influenza_SN != "yes")
```
There are `r dim(dados7)[1]` observations in the database.
We will only select the finalized cases (death or cure). The variable that indicates the outcome is `EVOLUCAO`, with the categories: 1-Cure; 2-Death; 3- Death from other causes; 9-Ignored.
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
with(dados7, freq(EVOLUCAO))
```
Let's select only the finalized cases:
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#filtering only completed cases
dados8 <- dados7 %>%
filter((EVOLUCAO == 1 | EVOLUCAO == 2 | EVOLUCAO == 3) & !is.na(EVOLUCAO))
#creating the evolution variable
dados8 <- dados8 %>%
mutate(death = case_when(
EVOLUCAO == 1 ~ "cure",
EVOLUCAO == 2 ~ "death",
EVOLUCAO == 3 ~ "death"
))
with(dados8, freq(death))
```
There are `r dim(dados8)[1]` observations in the database.
The variable that indicates whether the person received a vaccine against COVID-19 is `VACINA_COV`, with categories: 1-yes; 2-no; 9-ignored.
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#Frequency table for VACINA_COV
with(dados8, freq(VACINA_COV))
```
Let's now group "NA" and "9" in the same category (NA - missing data) and label the valid categories.
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#recoding the vaccine_cov variable
dados8 <- dados8 %>%
mutate(vaccine_cov = case_when(
VACINA_COV == 1 ~ "yes",
VACINA_COV == 2 ~ "no",
TRUE ~ NA_character_
))
#frequency table for vaccine_cov
with(dados8, freq(vaccine_cov))
```
The next step is filtering cases that we have information about COVID-19 vaccination. These data are analyzed in the following.
```{r,echo=TRUE, eval=TRUE, message=FALSE,warning =FALSE,error=FALSE,results='hide'}
#Filtering cases with information about vaccination
data_final <- dados8 %>%
filter(!is.na(vaccine_cov))
```
```{r,echo=TRUE, eval=TRUE, message=FALSE,warning =FALSE,error=FALSE}
with(data_final, freq(vaccine_cov))
```
The variable `vaccine_cov` only indicates if the pregnant or postpartum women took the vaccine, regardless of the dose. There is no information on whether the person only took the first dose or the second. The closest we come to this is to consider the column `DOSE_2_COV`, which indicates the date of the second dose.
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#Create second dose date variable
data_final <- data_final %>%
dplyr::mutate(
dt_dose2_cov = as.Date(DOSE_2_COV, format = "%d/%m/%Y")
)
#Create variable that indicates that it has the date of the second dose
data_final <- data_final%>%
dplyr::mutate(
indic_dt_dose2_cov = ifelse(is.na(dt_dose2_cov) & !is.na(vaccine_cov), 0, ifelse(is.na(vaccine_cov), NA, 1))
)
# first dose date frequency table
with(data_final, freq(indic_dt_dose2_cov, total = TRUE))
```
There is only information on the date of the second dose for `r dim(data_final[data_final$indic_dt_dose2_cov == 1, ])[1]` cases of `r dim(data_final[data_final$vaccine_cov == "yes", ])[1]` cases indicated as "yes" for COVID-19 vaccine.
Now we will analyze the not vaccinated group versus two dose vaccinated group.
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#Create second dose date variable
data_final <- data_final %>%
filter(vaccine_cov == "no" | (vaccine_cov == "yes" & indic_dt_dose2_cov == 1))
with(data_final, freq(vaccine_cov))
```
```{r, echo=FALSE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
require(writexl)
write_xlsx(data_final, "final_dataset.xlsx")
```
#Analysis
## Epidemiologic characteristics
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
# Ethnicity
data_final <- data_final %>%
mutate(
ethnicity = case_when(
CS_RACA == 1 ~ "white",
CS_RACA == 2 ~ "black",
CS_RACA == 3 ~ "yellow",
CS_RACA == 4 ~ "brown",
CS_RACA == 5 ~ "indigenous",
TRUE ~ NA_character_
),
white_color = case_when(
ethnicity == "white" ~ "yes",
is.na(ethnicity) ~ NA_character_,
TRUE ~ "no"
)
)
# Education
data_final <- data_final %>%
mutate(
education2 = case_when(
CS_ESCOL_N <= 2 ~ "up to 9 years",
CS_ESCOL_N == 3 ~ "from 9 to 12 years",
CS_ESCOL_N == 4 ~ "over 12 years",
TRUE ~ NA_character_
)
)
data_final$education2 <-
factor(data_final$education2, levels = c("up to 9 years", "from 9 to 12 years", "over 12 years"))
# residence area
data_final <- data_final %>%
mutate(
residence = case_when(
CS_ZONA == 1 ~ "urban",
CS_ZONA == 2 ~ "rural",
CS_ZONA == 3 ~ "periurban",
TRUE ~ NA_character_
)
)
# residence area 2 (grouping the categories urban and periurban)
data_final <- data_final %>%
mutate(
residence2 = case_when(
CS_ZONA == 1 ~ "urban/periurban",
CS_ZONA == 2 ~ "rural",
CS_ZONA == 3 ~ "urban/periurban",
TRUE ~ NA_character_
)
)
data_final$residence2 <-
factor(data_final$residence2, levels = c("rural", "urban/periurban"))
```
### Ethnicity
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
with(data_final, ctable(ethnicity, vaccine_cov, prop = "c", useNA = "no", chisq = FALSE, OR = FALSE))
```
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
fisher.test(data_final$ethnicity, data_final$vaccine_cov)
```
### White color
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
with(data_final, ctable(white_color, vaccine_cov, prop = "c", useNA = "no", chisq = TRUE, OR = TRUE))
```
### Education (years)
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
with(data_final, ctable(education2, vaccine_cov, prop = "c", useNA = "no", chisq = TRUE))
```
### Age
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
datasummary((vaccine_cov) ~ age*(n+media+DP+mediana+q25+q75+IQR),
data = data_final, output = 'markdown')
```
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#t-test
t.test(age ~ vaccine_cov, data = data_final)
```
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#effect size
c_cohen <- cohens_d(age ~ as.factor(vaccine_cov), data=data_final)
c_cohen
interpret_d(c_cohen$Cohens_d,rules="cohen1988")
```
### Residence area
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
with(data_final, ctable(residence, vaccine_cov, prop = "c", useNA = "no", chisq = FALSE))
```
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
fisher.test(data_final$residence, data_final$vaccine_cov)
```
### Residence area 2 (grouping the categories urban and periurban)
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
with(data_final, ctable(residence2, vaccine_cov, prop = "c", useNA = "no", chisq = TRUE, OR = TRUE))
```
## Comorbities
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#Cardiac
data_final <- data_final %>%
mutate(cardiac = case_when(CARDIOPATI == 1 ~ "yes",
CARDIOPATI == 2 ~ "no",
TRUE ~ NA_character_))
#Hematologic
data_final <- data_final %>%
mutate(hematologic = case_when(HEMATOLOGI == 1 ~ "yes",
HEMATOLOGI == 2 ~ "no",
TRUE ~ NA_character_))
#Hepatic
data_final <- data_final %>%
mutate(hepatic = case_when(HEPATICA == 1 ~ "yes",
HEPATICA == 2 ~ "no",
TRUE ~ NA_character_))
#Asthma
data_final <- data_final %>%
mutate(asthma = case_when(ASMA == 1 ~ "yes",
ASMA == 2 ~ "no",
TRUE ~ NA_character_))
#Diabetes
data_final <- data_final %>%
mutate(diabetes = case_when(DIABETES == 1 ~ "yes",
DIABETES == 2 ~ "no",
TRUE ~ NA_character_))
#Neurologic
data_final <- data_final %>%
mutate(neurologic = case_when(NEUROLOGIC == 1 ~ "yes",
NEUROLOGIC == 2 ~ "no",
TRUE ~ NA_character_))
#Pneumologic
data_final <- data_final %>%
mutate(pneumologic = case_when(PNEUMOPATI == 1 ~ "yes",
PNEUMOPATI == 2 ~ "no",
TRUE ~ NA_character_))
#Imunossupression
data_final <- data_final %>%
mutate(imuno = case_when(IMUNODEPRE == 1 ~ "yes",
IMUNODEPRE == 2 ~ "no",
TRUE ~ NA_character_))
#Renal
data_final <- data_final %>%
mutate(renal = case_when(RENAL == 1 ~ "yes",
RENAL == 2 ~ "no",
TRUE ~ NA_character_))
#Obesity
data_final <- data_final %>%
mutate(obesity = case_when(OBESIDADE == 1 ~ "yes",
OBESIDADE == 2 ~ "no",
TRUE ~ NA_character_))
```
### Cardiac
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, cardiac, prop = "r", useNA = "no", chisq = TRUE, OR = TRUE))
```
### Hematologic
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, hematologic, prop = "r", useNA = "no", chisq = FALSE, OR = TRUE))
```
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
fisher.test(data_final$hematologic, data_final$vaccine_cov)
```
### Diabetes
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
ctable(data_final$vaccine_cov, data_final$diabetes, chisq=TRUE, prop="r", useNA = "no", OR = TRUE)
```
### Obesity
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
ctable(data_final$vaccine_cov, data_final$obesity, chisq=TRUE, prop="r", useNA = "no", OR = TRUE)
```
### Asthma
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
ctable(data_final$vaccine_cov, data_final$asthma, chisq=TRUE, prop="r", useNA = "no", OR = TRUE)
```
### Hepatic
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
ctable(data_final$vaccine_cov, data_final$hepatic, chisq=FALSE, prop="r", useNA = "no", OR = TRUE)
```
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
fisher.test(data_final$vaccine_cov, data_final$hepatic)
```
### Neurologic
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
ctable(data_final$vaccine_cov, data_final$neurologic, chisq=FALSE, prop="r", useNA = "no", OR = TRUE)
```
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
fisher.test(data_final$vaccine_cov, data_final$neurologic)
```
### Pneumologic
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
ctable(data_final$vaccine_cov, data_final$pneumologic, chisq=FALSE, prop="r", useNA = "no", OR = TRUE)
```
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
fisher.test(data_final$vaccine_cov, data_final$pneumologic)
```
### Imunossupression
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
ctable(data_final$vaccine_cov, data_final$imuno, chisq=FALSE, prop="r", useNA = "no", OR = TRUE)
```
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
fisher.test(data_final$imuno, data_final$vaccine_cov)
```
### Renal
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
ctable(data_final$vaccine_cov, data_final$renal, chisq=FALSE, prop="r", useNA = "no", OR = TRUE)
```
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
fisher.test(data_final$renal, data_final$vaccine_cov)
```
## Symptoms
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
# Fever
data_final <- data_final %>%
mutate(fever = case_when(FEBRE == 1 ~ "yes",
FEBRE == 2 ~ "no",
TRUE ~ NA_character_))
# Cough
data_final <- data_final %>%
mutate(cough = case_when(TOSSE == 1 ~ "yes",
TOSSE == 2 ~ "no",
TRUE ~ NA_character_))
# Sore throat
data_final <- data_final %>%
mutate(sore_throat = case_when(GARGANTA == 1 ~ "yes",
GARGANTA == 2 ~ "no",
TRUE ~ NA_character_))
# Dyspnea
data_final <- data_final %>%
mutate(dyspnea = case_when(DISPNEIA == 1 ~ "yes",
DISPNEIA == 2 ~ "no",
TRUE ~ NA_character_))
# Respiratory discomfort
data_final <- data_final %>%
mutate(resp_disc = case_when(DESC_RESP == 1 ~ "yes",
DESC_RESP == 2 ~ "no",
TRUE ~ NA_character_))
# Desaturation
data_final <- data_final %>%
mutate(desaturation = case_when(SATURACAO == 1 ~ "yes",
SATURACAO == 2 ~ "no",
TRUE ~ NA_character_))
# Diarrhea
data_final <- data_final %>%
mutate(diarrhea = case_when(DIARREIA == 1 ~ "yes",
DIARREIA == 2 ~ "no",
TRUE ~ NA_character_))
# Vomit
data_final <- data_final %>%
mutate(vomit = case_when(VOMITO == 1 ~ "yes",
VOMITO == 2 ~ "no",
TRUE ~ NA_character_))
# Abdominal pain
data_final <- data_final %>%
mutate(abd_pain = case_when(DOR_ABD == 1 ~ "yes",
DOR_ABD == 2 ~ "no",
TRUE ~ NA_character_))
# Fatigue
data_final <- data_final %>%
mutate(fatigue = case_when(FADIGA == 1 ~ "yes",
FADIGA == 2 ~ "no",
TRUE ~ NA_character_))
# Olfactory loss
data_final <- data_final %>%
mutate(olfac_loss = case_when(PERD_OLFT == 1 ~ "yes",
PERD_OLFT == 2 ~ "no",
TRUE ~ NA_character_))
# Loss of taste
data_final <- data_final %>%
mutate(loss_taste = case_when(PERD_PALA == 1 ~ "yes",
PERD_PALA == 2 ~ "no",
TRUE ~ NA_character_))
# Any respiratory symptom
df <- data_final %>%
select(dyspnea,fatigue,desaturation,resp_disc)
soma <- function(x){
if (sum(is.na(x))==4)
return(NA_character_)
else
return(sum(!is.na(x) & x=="yes"))
}
data_final$qt_sintomas_resp_aux <- apply(df,1,soma)
data_final <- data_final %>%
mutate(resp_symp = case_when(qt_sintomas_resp_aux >=1 ~ "yes",
qt_sintomas_resp_aux ==0 ~ "no",
TRUE ~ NA_character_))
# Any symptom
df <- data_final %>%
select(dyspnea,fatigue,desaturation,resp_disc,
fever,cough,sore_throat,diarrhea,vomit,abd_pain,olfac_loss,loss_taste)
soma <- function(x){
if (sum(is.na(x))==12)
return(NA_character_)
else
return(sum(!is.na(x) & x=="yes"))
}
data_final$qt_sintomas_aux <- apply(df,1,soma)
data_final <- data_final %>%
mutate(symptom = case_when(qt_sintomas_aux >= 1 ~ "yes",
qt_sintomas_aux == 0 ~ "no",
TRUE ~ NA_character_))
```
### Fever
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, fever, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Cough
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, cough, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Sore throat
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, sore_throat, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Dyspnea
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, dyspnea, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Respiratory discomfort
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, resp_disc, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Desaturation
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, desaturation, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Diarrhea
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, diarrhea, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Vomit
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, vomit, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Abdominal pain
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, abd_pain, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Fatigue
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, fatigue, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Olfactory loss
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, olfac_loss, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Loss of taste
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, loss_taste, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Any respiratory symptom
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, resp_symp, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Any symptom
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, symptom, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
## Outcome
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
# ICU
data_final <- data_final %>%
mutate(icu = case_when(UTI == 1 ~ "yes",
UTI == 2 ~ "no",
TRUE ~ NA_character_))
# Length time in ICU
data_final<- data_final%>%
mutate(dt_enticu = as.Date(DT_ENTUTI, format = "%d/%m/%Y"),
dt_exicu = as.Date(DT_SAIDUTI, format = "%d/%m/%Y"),
time_icu = as.numeric(dt_exicu - dt_enticu)
)
# ventilatory support
data_final <- data_final %>%
mutate(ventilatory_support = case_when(SUPORT_VEN == 1 ~ "invasive",
SUPORT_VEN == 2 ~ "non-invasive",
SUPORT_VEN == 3 ~ "no",
TRUE ~ NA_character_))
# Intubation
data_final <- data_final %>%
mutate(intubation = case_when(SUPORT_VEN == 1 ~ "yes",
SUPORT_VEN == 2 | SUPORT_VEN == 3 ~ "no",
TRUE ~ NA_character_))
```
### ICU
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, icu, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Length time in ICU
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
data_final_aux <- data_final %>%
filter (icu == "yes")
```
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
datasummary((vaccine_cov) ~ time_icu*(n+media+DP+mediana+q25+q75+IQR),
data = data_final_aux, output = 'markdown')
```
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
#t-test
t.test(time_icu ~ vaccine_cov, data = data_final_aux)
```
### Ventilatory support
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, ventilatory_support, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Intubation
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, intubation, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Death
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_final, ctable(vaccine_cov, death, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
# Propensity Scoring Method (PSM) - information about date of second dose
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}
data_final <- data_final %>%
mutate(vaccine1 = ifelse(vaccine_cov == "yes", 1, 0),
id = 1:dim(data_final)[1])
data_final1 <- data_final %>%
select(id, vaccine1, age, cardiac)
data_final1 <- data_final1 %>%
mutate(
cardiac1 = ifelse(is.na(cardiac) == TRUE, "na", cardiac)
)
#PSM
psm1 <- matchit(vaccine1 ~ age + cardiac1, data = data_final1, method = "nearest", ratio =1)
summary(psm1)
plot(psm1, type = "jitter", interactive = FALSE)
plot(psm1, type = "qq", interactive = FALSE,
which.xs = c("age", "cardiac1"))
plot(summary(psm1))
```
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
#Selecting only the selected observations
data_aux <- data_final1[psm1$weights==1, ]
#Now let's join data_aux with data_final
data_psm <- right_join(data_final, data_aux, by= c("id", "vaccine1", "age", "cardiac"))
freq(data_psm$vaccine_cov)
```
## For outcomes
### ICU
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
with(data_psm, ctable(vaccine_cov, icu, prop = "r", useNA = "no", chisq = TRUE, OR=TRUE))
```
### Length time in ICU
```{r, echo=TRUE,message=FALSE,warning =FALSE,error=FALSE}
data_psm_aux <- data_psm %>%
filter (icu == "yes")
```
```{r, echo=TRUE, eval= TRUE, message=FALSE, warning =FALSE, error=FALSE}