library(funModeling) 
## Loading required package: Hmisc
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Loading required package: ggplot2
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
## 
##     format.pval, units
## funModeling v.1.9.4 :)
## Examples and tutorials at livebook.datascienceheroes.com
##  / Now in Spanish: librovivodecienciadedatos.ai
library(tidyverse) 
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ tibble  3.1.7     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ✔ purrr   0.3.4     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter()    masks stats::filter()
## ✖ dplyr::lag()       masks stats::lag()
## ✖ dplyr::src()       masks Hmisc::src()
## ✖ dplyr::summarize() masks Hmisc::summarize()
library(Hmisc)
library(tidyverse)
library(ggpubr)
library(gtable)
library(gt)
## 
## Attaching package: 'gt'
## 
## The following object is masked from 'package:Hmisc':
## 
##     html
library(survival)
library(ggpubr)
library(survminer)
## 
## Attaching package: 'survminer'
## 
## The following object is masked from 'package:survival':
## 
##     myeloma
library(readr)
library(gtsummary)

dbcovid <- read_delim("C:/Users/fidel/OneDrive - CINVESTAV/Proyecto colaboración SSA/base de datos/SISVER/dbcovid.txt", 
                      delim = "|", escape_double = FALSE, trim_ws = TRUE)
## Rows: 429902 Columns: 130
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "|"
## chr (106): ORIGEN, SECTOR, CVEMUNUNI, ENTIDAD, DELEGA, UNIDAD, FECHREG, CLUE...
## dbl  (12): ID_REGISTRO, CVEENTUNI, CVENTINE, CVELOCAL, LATLOCA, LONGLOCA, SE...
## lgl  (12): RESDEFIN2, PAISORI, FINGMEX, PAISTRAN1, PAISTRAN2, PAISTRAN3, PAI...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
covidsin<-dbcovid 

covidsinfilt <-  covidsin %>% filter(RESDEFIN == "SARS-CoV-2" & CLASCOVID19 =="CONF LAB")

covidsinfilt$FECINISI <- strptime(as.character(covidsinfilt$FECINISI), "%d/%m/%Y")

covidsinfilt$FECINISI = as.Date(covidsinfilt$FECINISI)

TOTAL DE CASOS CONFIRMADOS Y POSITIVOS A SARS-CoV-2 de enero 2020 a diciembre 2022

freq(covidsinfilt$RESDEFIN)
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

CURVA EPIDEMIOLOGICA

library(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(epiR); library(ggplot2); library(scales); library(zoo)
## Warning: package 'epiR' was built under R version 4.2.2
## Package epiR 2.0.53 is loaded
## Type help(epi.about) for summary information
## Type browseVignettes(package = 'epiR') to learn how to use epiR for applied epidemiological analyses
## 
## 
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
## 
##     discard
## The following object is masked from 'package:readr':
## 
##     col_factor
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:Hmisc':
## 
##     subplot
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
epiplot <-ggplot(data = covidsinfilt, aes(x = as.Date(FECINISI))) +
  theme_bw() +
  geom_histogram(binwidth = 7, colour = "black", fill = "#3e78d6", size = 0.1) +
  geom_density(aes(y = ..density.. * (nrow(covidsinfilt) * 10)), colour = "red", size=0.8) +
  scale_x_date( labels = date_format("%d/%m/%Y"), 
     name = "Date") +
  scale_y_continuous(breaks = seq(from = 0, to =1500, by = 100), name = "Number of cases") + theme_classic()+
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

  ggplotly(epiplot)

ANALISIS DE SUPERVIVENCIA

PREPARACIÓN DE LOS DATO: LIMPIEZA, FILTRADO

library(gt)
#crear columna de estatus
covidsinfilt <- covidsinfilt %>% mutate(estatus = case_when(is.na(FECDEF) ~ "Sobrevivió"))

covidsinfilt <- covidsinfilt %>% replace_na(list(estatus = "No sobrevivió")) #con la función "remplace_na"

library(lubridate)

covidsinfilt$FECDEF <- strptime(as.character(covidsinfilt$FECDEF), "%d/%m/%Y")

covidsinfilt$FECDEF = as.Date(covidsinfilt$FECDEF)

str(covidsinfilt$FECDEF)
##  Date[1:51921], format: NA NA NA NA "2020-05-17" NA NA "2020-09-09" NA "2020-05-03" NA NA NA ...
covidsinfilt <- covidsinfilt %>% mutate(deftime = as.double(FECDEF-FECINISI)) 

covidsinfilt %>% select(FECDEF,FECINISI, deftime, estatus)
covidsinfilt <- covidsinfilt %>% mutate(evento = ifelse(is.na(estatus) | estatus == "No sobrevivió", 1, 0)) 

covidsinfilt %>% select(evento, estatus,deftime)

ANALISIS DE FRECUENCIAS OVERALL VARIABLES

covidsinfilt %>% select(RESDEFIN,CLASCOVID19,SEXO,EDAD,ESINDIGE,OCUPACIO,TIPACIEN,EVOLUCI,INTUBADO,DIGCLINE,DIAGPROB,FIEBRE:TXANTIVI,ANTIVIRA,
                                     ANTIPIRETICOS,VACUNADO,TIPO_VAC_COV,estatus) %>% freq()
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.
##     RESDEFIN frequency percentage cumulative_perc
## 1 SARS-CoV-2     51921        100             100
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##   CLASCOVID19 frequency percentage cumulative_perc
## 1    CONF LAB     51921        100             100
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##        SEXO frequency percentage cumulative_perc
## 1  FEMENINO     27082      52.16           52.16
## 2 MASCULINO     24839      47.84          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##   ESINDIGE frequency percentage cumulative_perc
## 1       NO     49789      95.89           95.89
## 2     <NA>      1982       3.82           99.71
## 3       SI       150       0.29          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##                                          OCUPACIO frequency percentage
## 1                                       EMPLEADOS     15861      30.55
## 2                                           OTROS      8517      16.40
## 3                                           HOGAR      7207      13.88
## 4                           JUBILADO / PENSIONADO      3418       6.58
## 5                                      ENFERMERAS      2852       5.49
## 6                                     ESTUDIANTES      2615       5.04
## 7                                    DESEMPLEADOS      2489       4.79
## 8                  OTROS TRABAJADORES DE LA SALUD      2294       4.42
## 9                                         MEDICOS      2037       3.92
## 10                                       MAESTROS      1116       2.15
## 11                           OTROS PROFESIONISTAS      1102       2.12
## 12    COMERCIANTES DE MERCADOS FIJOS O AMBULANTES       707       1.36
## 13                                     CAMPESINOS       511       0.98
## 14                                       CHOFERES       383       0.74
## 15                                        OBREROS       316       0.61
## 16                                 LABORATORISTAS       187       0.36
## 17 GERENTES O PROPIETARIOS DE EMPRESAS O NEGOCIOS       186       0.36
## 18                                      DENTISTAS       123       0.24
##    cumulative_perc
## 1            30.55
## 2            46.95
## 3            60.83
## 4            67.41
## 5            72.90
## 6            77.94
## 7            82.73
## 8            87.15
## 9            91.07
## 10           93.22
## 11           95.34
## 12           96.70
## 13           97.68
## 14           98.42
## 15           99.03
## 16           99.39
## 17           99.75
## 18          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##        TIPACIEN frequency percentage cumulative_perc
## 1   AMBULATORIO     36345         70              70
## 2 HOSPITALIZADO     15576         30             100
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##                     EVOLUCI frequency percentage cumulative_perc
## 1     SEGUIMIENTO TERMINADO     36726      70.73           70.73
## 2                 DEFUNCION      7627      14.69           85.42
## 3            ALTA - MEJORIA      6720      12.94           98.36
## 4         ALTA - VOLUNTARIA       329       0.63           98.99
## 5           ALTA - TRASLADO       200       0.39           99.38
## 6           ALTA - CURACION       152       0.29           99.67
## 7  SEGUIMIENTO DOMICILIARIO        78       0.15           99.82
## 8            EN TRATAMIENTO        45       0.09           99.91
## 9              CASO GRAVE -        16       0.03           99.94
## 10            CASO NO GRAVE        16       0.03           99.97
## 11               REFERENCIA        11       0.02           99.99
## 12    CASO GRAVE - TRASLADO         1       0.00          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##   INTUBADO frequency percentage cumulative_perc
## 1     <NA>     37155      71.56           71.56
## 2       NO     12772      24.60           96.16
## 3       SI      1994       3.84          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##   DIGCLINE frequency percentage cumulative_perc
## 1       NO     40832      78.64           78.64
## 2       SI     11089      21.36          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##                                    DIAGPROB frequency percentage
## 1           ENFERMEDAD TIPO INFLUENZA (ETI)     37331       71.9
## 2 INFECCION RESPIRATORIA AGUDA GRAVE (IRAG)     14590       28.1
##   cumulative_perc
## 1            71.9
## 2           100.0
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##      FIEBRE frequency percentage cumulative_perc
## 1        SI     38433      74.02           74.02
## 2        NO     13467      25.94           99.96
## 3 SE IGNORA        21       0.04          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##         TOS frequency percentage cumulative_perc
## 1        SI     40651      78.29           78.29
## 2        NO     11253      21.67           99.96
## 3 SE IGNORA        17       0.03          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    ODINOGIA frequency percentage cumulative_perc
## 1        NO     29052      55.95           55.95
## 2        SI     22762      43.84           99.79
## 3 SE IGNORA       107       0.21          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##      DISNEA frequency percentage cumulative_perc
## 1        NO     34258      65.98           65.98
## 2        SI     17653      34.00           99.98
## 3 SE IGNORA        10       0.02          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    IRRITABI frequency percentage cumulative_perc
## 1        NO     35195      67.79           67.79
## 2        SI     16688      32.14           99.93
## 3 SE IGNORA        38       0.07          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##     DIARREA frequency percentage cumulative_perc
## 1        NO     42489      81.83           81.83
## 2        SI      9395      18.09           99.92
## 3 SE IGNORA        37       0.07          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    DOTORACI frequency percentage cumulative_perc
## 1        NO     37627      72.47           72.47
## 2        SI     14190      27.33           99.80
## 3 SE IGNORA       104       0.20          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##   CALOFRIOS frequency percentage cumulative_perc
## 1        NO     35428      68.23           68.23
## 2        SI     16399      31.58           99.81
## 3 SE IGNORA        94       0.18          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##     CEFALEA frequency percentage cumulative_perc
## 1        SI     40789      78.56           78.56
## 2        NO     11094      21.37           99.93
## 3 SE IGNORA        38       0.07          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    MIALGIAS frequency percentage cumulative_perc
## 1        SI     31037      59.78           59.78
## 2        NO     20777      40.02           99.80
## 3 SE IGNORA       107       0.21          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##      ARTRAL frequency percentage cumulative_perc
## 1        SI     28609      55.10           55.10
## 2        NO     23199      44.68           99.78
## 3 SE IGNORA       113       0.22          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    ATAEDOGE frequency percentage cumulative_perc
## 1        NO     29458      56.74           56.74
## 2        SI     22340      43.03           99.77
## 3 SE IGNORA       123       0.24          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    RINORREA frequency percentage cumulative_perc
## 1        NO     33149      63.85           63.85
## 2        SI     18649      35.92           99.77
## 3 SE IGNORA       123       0.24          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    POLIPNEA frequency percentage cumulative_perc
## 1        NO     46594      89.74           89.74
## 2        SI      5194      10.00           99.74
## 3 SE IGNORA       133       0.26          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##      VOMITO frequency percentage cumulative_perc
## 1        NO     48088      92.62           92.62
## 2        SI      3695       7.12           99.74
## 3 SE IGNORA       138       0.27          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##     DOLABDO frequency percentage cumulative_perc
## 1        NO     46229      89.04           89.04
## 2        SI      5545      10.68           99.72
## 3 SE IGNORA       147       0.28          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##      CONJUN frequency percentage cumulative_perc
## 1        NO     46816      90.17           90.17
## 2        SI      4951       9.54           99.71
## 3 SE IGNORA       154       0.30          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    CIANOSIS frequency percentage cumulative_perc
## 1        NO     50714      97.68           97.68
## 2        SI      1058       2.04           99.72
## 3 SE IGNORA       149       0.29          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    INISUBIS frequency percentage cumulative_perc
## 1        NO     38524      74.20           74.20
## 2        SI     13197      25.42           99.62
## 3 SE IGNORA       200       0.39          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##     ANOSMIA frequency percentage cumulative_perc
## 1        NO     37419      72.07           72.07
## 2        SI      8782      16.91           88.98
## 3 SE IGNORA      5720      11.02          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##   DISGEUSIA frequency percentage cumulative_perc
## 1        NO     38385      73.93           73.93
## 2        SI      7721      14.87           88.80
## 3 SE IGNORA      5815      11.20          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##   ASINTOMATICO frequency percentage cumulative_perc
## 1           NO     51391      98.98           98.98
## 2           SI       496       0.96           99.94
## 3    SE IGNORA        34       0.07          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    DIABETES frequency percentage cumulative_perc
## 1        NO     44610      85.92           85.92
## 2        SI      7195      13.86           99.78
## 3 SE IGNORA       116       0.22          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##        EPOC frequency percentage cumulative_perc
## 1        NO     51138      98.49           98.49
## 2        SI       704       1.36           99.85
## 3 SE IGNORA        79       0.15          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##        ASMA frequency percentage cumulative_perc
## 1        NO     50696      97.64           97.64
## 2        SI      1139       2.19           99.83
## 3 SE IGNORA        86       0.17          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    INMUSUPR frequency percentage cumulative_perc
## 1        NO     51270      98.75           98.75
## 2        SI       553       1.07           99.82
## 3 SE IGNORA        98       0.19          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    HIPERTEN frequency percentage cumulative_perc
## 1        NO     40685      78.36           78.36
## 2        SI     11129      21.43           99.79
## 3 SE IGNORA       107       0.21          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    VIH.SIDA frequency percentage cumulative_perc
## 1        NO     51658      99.49           99.49
## 2        SI       167       0.32           99.81
## 3 SE IGNORA        96       0.18          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##     OTRACON frequency percentage cumulative_perc
## 1        NO     50306      96.89           96.89
## 2        SI      1489       2.87           99.76
## 3 SE IGNORA       126       0.24          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    ENFCARDI frequency percentage cumulative_perc
## 1        NO     50544      97.35           97.35
## 2        SI      1279       2.46           99.81
## 3 SE IGNORA        98       0.19          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    OBESIDAD frequency percentage cumulative_perc
## 1        NO     43706      84.18           84.18
## 2        SI      8118      15.64           99.82
## 3 SE IGNORA        97       0.19          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    INSRENCR frequency percentage cumulative_perc
## 1        NO     50897      98.03           98.03
## 2        SI       932       1.80           99.83
## 3 SE IGNORA        92       0.18          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    TABAQUIS frequency percentage cumulative_perc
## 1        NO     48985      94.35           94.35
## 2        SI      2827       5.44           99.79
## 3 SE IGNORA       109       0.21          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##   RECTRATA frequency percentage cumulative_perc
## 1       NO     47724      91.92           91.92
## 2       SI      3961       7.63           99.55
## 3     <NA>       236       0.45          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##   TXCROBIA frequency percentage cumulative_perc
## 1     <NA>     24225      46.66           46.66
## 2       NO     18279      35.21           81.87
## 3       SI      9417      18.14          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##   TXANTIVI frequency percentage cumulative_perc
## 1       NO     44617      85.93           85.93
## 2       SI      6020      11.59           97.52
## 3     <NA>      1284       2.47          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##                      ANTIVIRA frequency percentage cumulative_perc
## 1                        <NA>     45896      88.40           88.40
## 2                 OSELTAMIVIR      5828      11.22           99.62
## 3                  AMANTADINA       128       0.25           99.87
## 4                   ZAVAMIVIR        21       0.04           99.91
## 5                  RIMNTADINA         9       0.02           99.93
## 6                AZITROMICINA         5       0.01           99.94
## 7                  RIBAVIRINA         5       0.01           99.95
## 8                 IVERMECTINA         4       0.01           99.96
## 9                  CLOROQUINA         3       0.01           99.97
## 10                 LORATADINA         3       0.01           99.98
## 11                    KALETRA         2       0.00           99.98
## 12                 REMDESIVIR         2       0.00           99.98
## 13                   VIRAZIDE         2       0.00           99.98
## 14                 AMPICILINA         1       0.00           99.98
## 15                 ANTIFLUD D         1       0.00           99.98
## 16               azitromicina         1       0.00           99.98
## 17             CLARITROMICINA         1       0.00           99.98
## 18                 cloroquina         1       0.00           99.98
## 19 cloroquina, azitrominicina         1       0.00           99.98
## 20         INVAZ, FLUCONAZOL,         1       0.00           99.98
## 21                 IVERMECTIN         1       0.00           99.98
## 22               IVERTMENTINA         1       0.00           99.98
## 23              LEVOFLOXACINO         1       0.00           99.98
## 24                 rivabarina         1       0.00           99.98
## 25                VIBRAMICINA         1       0.00           99.98
## 26                         XX         1       0.00          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##   ANTIPIRETICOS frequency percentage cumulative_perc
## 1            SI     28225      54.36           54.36
## 2            NO     23603      45.46           99.82
## 3          <NA>        93       0.18          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##    VACUNADO frequency percentage cumulative_perc
## 1        NO     44097      84.93           84.93
## 2        SI      7700      14.83           99.76
## 3 SE IGNORA        80       0.15           99.91
## 4      <NA>        44       0.08          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##                   TIPO_VAC_COV frequency percentage cumulative_perc
## 1                         <NA>     43344      83.48           83.48
## 2                  AstraZeneca      3329       6.41           89.89
## 3              Pfizer BioNTech      2125       4.09           93.98
## 4                      Sinovac      1992       3.84           97.82
## 5                      CanSino       533       1.03           98.85
## 6                 Se desconoce       243       0.47           99.32
## 7                      Moderna       240       0.46           99.78
## 8  Janssen (Johnson & Johnson)        85       0.16           99.94
## 9                   Sinopharma        26       0.05           99.99
## 10                     Novavax         3       0.01          100.00
## 11                    Gamaleya         1       0.00          100.00
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

##         estatus frequency percentage cumulative_perc
## 1    Sobrevivió     44294      85.31           85.31
## 2 No sobrevivió      7627      14.69          100.00
## [1] "Variables processed: RESDEFIN, CLASCOVID19, SEXO, ESINDIGE, OCUPACIO, TIPACIEN, EVOLUCI, INTUBADO, DIGCLINE, DIAGPROB, FIEBRE, TOS, ODINOGIA, DISNEA, IRRITABI, DIARREA, DOTORACI, CALOFRIOS, CEFALEA, MIALGIAS, ARTRAL, ATAEDOGE, RINORREA, POLIPNEA, VOMITO, DOLABDO, CONJUN, CIANOSIS, INISUBIS, ANOSMIA, DISGEUSIA, ASINTOMATICO, DIABETES, EPOC, ASMA, INMUSUPR, HIPERTEN, VIH.SIDA, OTRACON, ENFCARDI, OBESIDAD, INSRENCR, TABAQUIS, RECTRATA, TXCROBIA, TXANTIVI, ANTIVIRA, ANTIPIRETICOS, VACUNADO, TIPO_VAC_COV, estatus"

TABLA EDA AGRUPADA EN PACIENTES QUE SOBREVIVIERON Y QUE NO SOBREVIVIERON

tabla1covisin<-covidsinfilt %>% select(RESDEFIN,CLASCOVID19,SEXO,EDAD,ESINDIGE,OCUPACIO,TIPACIEN,EVOLUCI,INTUBADO,DIGCLINE,DIAGPROB,FIEBRE:TXANTIVI,ANTIVIRA,
                                     ANTIPIRETICOS,VACUNADO,TIPO_VAC_COV,estatus) %>% tbl_summary(by=estatus) %>% add_p() %>% add_overall()
## There was an error in 'add_p()/add_difference()' for variable 'RESDEFIN', p-value omitted:
## Error in stats::chisq.test(x = c("SARS-CoV-2", "SARS-CoV-2", "SARS-CoV-2", : 'x' and 'y' must have at least 2 levels
## There was an error in 'add_p()/add_difference()' for variable 'CLASCOVID19', p-value omitted:
## Error in stats::chisq.test(x = c("CONF LAB", "CONF LAB", "CONF LAB", "CONF LAB", : 'x' and 'y' must have at least 2 levels
## There was an error in 'add_p()/add_difference()' for variable 'EVOLUCI', p-value omitted:
## Error in stats::fisher.test(c("SEGUIMIENTO TERMINADO", "SEGUIMIENTO TERMINADO", : FEXACT error 6.  LDKEY=295 is too small for this problem,
##   (ii := key2[itp=545] = 333427243, ldstp=8850)
## Try increasing the size of the workspace and possibly 'mult'
## There was an error in 'add_p()/add_difference()' for variable 'ANTIVIRA', p-value omitted:
## Error in stats::fisher.test(c("OSELTAMIVIR", NA, NA, NA, "OSELTAMIVIR", : FEXACT error 7(location). LDSTP=17460 is too small for this problem,
##   (pastp=9.24648, ipn_0:=ipoin[itp=94]=8061, stp[ipn_0]=15.1783).
## Increase workspace or consider using 'simulate.p.value=TRUE'
## There was an error in 'add_p()/add_difference()' for variable 'TIPO_VAC_COV', p-value omitted:
## Error in stats::fisher.test(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, : FEXACT error 7(location). LDSTP=17040 is too small for this problem,
##   (pastp=65.5472, ipn_0:=ipoin[itp=388]=1331, stp[ipn_0]=91.525).
## Increase workspace or consider using 'simulate.p.value=TRUE'
tabla1covisin
Characteristic Overall, N = 51,9211 No sobrevivió, N = 7,6271 Sobrevivió, N = 44,2941 p-value2
RESDEFIN
SARS-CoV-2 51,921 (100%) 7,627 (100%) 44,294 (100%)
CLASCOVID19
CONF LAB 51,921 (100%) 7,627 (100%) 44,294 (100%)
SEXO <0.001
FEMENINO 27,082 (52%) 3,171 (42%) 23,911 (54%)
MASCULINO 24,839 (48%) 4,456 (58%) 20,383 (46%)
EDAD 43 (31, 58) 67 (56, 76) 40 (29, 52) <0.001
ESINDIGE 0.10
NO 49,789 (100%) 7,232 (100%) 42,557 (100%)
SI 150 (0.3%) 29 (0.4%) 121 (0.3%)
Unknown 1,982 366 1,616
OCUPACIO <0.001
CAMPESINOS 511 (1.0%) 177 (2.3%) 334 (0.8%)
CHOFERES 383 (0.7%) 74 (1.0%) 309 (0.7%)
COMERCIANTES DE MERCADOS FIJOS O AMBULANTES 707 (1.4%) 128 (1.7%) 579 (1.3%)
DENTISTAS 123 (0.2%) 3 (<0.1%) 120 (0.3%)
DESEMPLEADOS 2,489 (4.8%) 860 (11%) 1,629 (3.7%)
EMPLEADOS 15,861 (31%) 1,003 (13%) 14,858 (34%)
ENFERMERAS 2,852 (5.5%) 16 (0.2%) 2,836 (6.4%)
ESTUDIANTES 2,615 (5.0%) 37 (0.5%) 2,578 (5.8%)
GERENTES O PROPIETARIOS DE EMPRESAS O NEGOCIOS 186 (0.4%) 37 (0.5%) 149 (0.3%)
HOGAR 7,207 (14%) 2,274 (30%) 4,933 (11%)
JUBILADO / PENSIONADO 3,418 (6.6%) 1,769 (23%) 1,649 (3.7%)
LABORATORISTAS 187 (0.4%) 2 (<0.1%) 185 (0.4%)
MAESTROS 1,116 (2.1%) 97 (1.3%) 1,019 (2.3%)
MEDICOS 2,037 (3.9%) 59 (0.8%) 1,978 (4.5%)
OBREROS 316 (0.6%) 66 (0.9%) 250 (0.6%)
OTROS 8,517 (16%) 946 (12%) 7,571 (17%)
OTROS PROFESIONISTAS 1,102 (2.1%) 58 (0.8%) 1,044 (2.4%)
OTROS TRABAJADORES DE LA SALUD 2,294 (4.4%) 21 (0.3%) 2,273 (5.1%)
TIPACIEN <0.001
AMBULATORIO 36,345 (70%) 51 (0.7%) 36,294 (82%)
HOSPITALIZADO 15,576 (30%) 7,576 (99%) 8,000 (18%)
EVOLUCI
ALTA - CURACION 152 (0.3%) 0 (0%) 152 (0.3%)
ALTA - MEJORIA 6,720 (13%) 0 (0%) 6,720 (15%)
ALTA - TRASLADO 200 (0.4%) 0 (0%) 200 (0.5%)
ALTA - VOLUNTARIA 329 (0.6%) 0 (0%) 329 (0.7%)
CASO GRAVE - 16 (<0.1%) 0 (0%) 16 (<0.1%)
CASO GRAVE - TRASLADO 1 (<0.1%) 0 (0%) 1 (<0.1%)
CASO NO GRAVE 16 (<0.1%) 0 (0%) 16 (<0.1%)
DEFUNCION 7,627 (15%) 7,627 (100%) 0 (0%)
EN TRATAMIENTO 45 (<0.1%) 0 (0%) 45 (0.1%)
REFERENCIA 11 (<0.1%) 0 (0%) 11 (<0.1%)
SEGUIMIENTO DOMICILIARIO 78 (0.2%) 0 (0%) 78 (0.2%)
SEGUIMIENTO TERMINADO 36,726 (71%) 0 (0%) 36,726 (83%)
INTUBADO <0.001
NO 12,772 (86%) 5,670 (77%) 7,102 (96%)
SI 1,994 (14%) 1,662 (23%) 332 (4.5%)
Unknown 37,155 295 36,860
DIGCLINE <0.001
NO 40,832 (79%) 1,974 (26%) 38,858 (88%)
SI 11,089 (21%) 5,653 (74%) 5,436 (12%)
DIAGPROB <0.001
ENFERMEDAD TIPO INFLUENZA (ETI) 37,331 (72%) 69 (0.9%) 37,262 (84%)
INFECCION RESPIRATORIA AGUDA GRAVE (IRAG) 14,590 (28%) 7,558 (99%) 7,032 (16%)
FIEBRE 0.2
NO 13,467 (26%) 1,934 (25%) 11,533 (26%)
SE IGNORA 21 (<0.1%) 5 (<0.1%) 16 (<0.1%)
SI 38,433 (74%) 5,688 (75%) 32,745 (74%)
TOS 0.5
NO 11,253 (22%) 1,643 (22%) 9,610 (22%)
SE IGNORA 17 (<0.1%) 4 (<0.1%) 13 (<0.1%)
SI 40,651 (78%) 5,980 (78%) 34,671 (78%)
ODINOGIA <0.001
NO 29,052 (56%) 5,395 (71%) 23,657 (53%)
SE IGNORA 107 (0.2%) 18 (0.2%) 89 (0.2%)
SI 22,762 (44%) 2,214 (29%) 20,548 (46%)
DISNEA <0.001
NO 34,258 (66%) 646 (8.5%) 33,612 (76%)
SE IGNORA 10 (<0.1%) 0 (0%) 10 (<0.1%)
SI 17,653 (34%) 6,981 (92%) 10,672 (24%)
IRRITABI <0.001
NO 35,195 (68%) 5,393 (71%) 29,802 (67%)
SE IGNORA 38 (<0.1%) 8 (0.1%) 30 (<0.1%)
SI 16,688 (32%) 2,226 (29%) 14,462 (33%)
DIARREA <0.001
NO 42,489 (82%) 6,031 (79%) 36,458 (82%)
SE IGNORA 37 (<0.1%) 11 (0.1%) 26 (<0.1%)
SI 9,395 (18%) 1,585 (21%) 7,810 (18%)
DOTORACI <0.001
NO 37,627 (72%) 4,232 (55%) 33,395 (75%)
SE IGNORA 104 (0.2%) 12 (0.2%) 92 (0.2%)
SI 14,190 (27%) 3,383 (44%) 10,807 (24%)
CALOFRIOS <0.001
NO 35,428 (68%) 5,450 (71%) 29,978 (68%)
SE IGNORA 94 (0.2%) 12 (0.2%) 82 (0.2%)
SI 16,399 (32%) 2,165 (28%) 14,234 (32%)
CEFALEA <0.001
NO 11,094 (21%) 2,755 (36%) 8,339 (19%)
SE IGNORA 38 (<0.1%) 9 (0.1%) 29 (<0.1%)
SI 40,789 (79%) 4,863 (64%) 35,926 (81%)
MIALGIAS 0.012
NO 20,777 (40%) 2,943 (39%) 17,834 (40%)
SE IGNORA 107 (0.2%) 12 (0.2%) 95 (0.2%)
SI 31,037 (60%) 4,672 (61%) 26,365 (60%)
ARTRAL <0.001
NO 23,199 (45%) 3,198 (42%) 20,001 (45%)
SE IGNORA 113 (0.2%) 14 (0.2%) 99 (0.2%)
SI 28,609 (55%) 4,415 (58%) 24,194 (55%)
ATAEDOGE <0.001
NO 29,458 (57%) 2,824 (37%) 26,634 (60%)
SE IGNORA 123 (0.2%) 15 (0.2%) 108 (0.2%)
SI 22,340 (43%) 4,788 (63%) 17,552 (40%)
RINORREA <0.001
NO 33,149 (64%) 5,826 (76%) 27,323 (62%)
SE IGNORA 123 (0.2%) 18 (0.2%) 105 (0.2%)
SI 18,649 (36%) 1,783 (23%) 16,866 (38%)
POLIPNEA <0.001
NO 46,594 (90%) 5,437 (71%) 41,157 (93%)
SE IGNORA 133 (0.3%) 14 (0.2%) 119 (0.3%)
SI 5,194 (10%) 2,176 (29%) 3,018 (6.8%)
VOMITO <0.001
NO 48,088 (93%) 6,881 (90%) 41,207 (93%)
SE IGNORA 138 (0.3%) 19 (0.2%) 119 (0.3%)
SI 3,695 (7.1%) 727 (9.5%) 2,968 (6.7%)
DOLABDO <0.001
NO 46,229 (89%) 6,558 (86%) 39,671 (90%)
SE IGNORA 147 (0.3%) 20 (0.3%) 127 (0.3%)
SI 5,545 (11%) 1,049 (14%) 4,496 (10%)
CONJUN <0.001
NO 46,816 (90%) 7,133 (94%) 39,683 (90%)
SE IGNORA 154 (0.3%) 22 (0.3%) 132 (0.3%)
SI 4,951 (9.5%) 472 (6.2%) 4,479 (10%)
CIANOSIS <0.001
NO 50,714 (98%) 7,124 (93%) 43,590 (98%)
SE IGNORA 149 (0.3%) 21 (0.3%) 128 (0.3%)
SI 1,058 (2.0%) 482 (6.3%) 576 (1.3%)
INISUBIS <0.001
NO 38,524 (74%) 5,200 (68%) 33,324 (75%)
SE IGNORA 200 (0.4%) 40 (0.5%) 160 (0.4%)
SI 13,197 (25%) 2,387 (31%) 10,810 (24%)
ANOSMIA <0.001
NO 37,419 (72%) 5,552 (73%) 31,867 (72%)
SE IGNORA 5,720 (11%) 1,195 (16%) 4,525 (10%)
SI 8,782 (17%) 880 (12%) 7,902 (18%)
DISGEUSIA <0.001
NO 38,385 (74%) 5,636 (74%) 32,749 (74%)
SE IGNORA 5,815 (11%) 1,196 (16%) 4,619 (10%)
SI 7,721 (15%) 795 (10%) 6,926 (16%)
ASINTOMATICO <0.001
NO 51,391 (99%) 7,620 (100%) 43,771 (99%)
SE IGNORA 34 (<0.1%) 1 (<0.1%) 33 (<0.1%)
SI 496 (1.0%) 6 (<0.1%) 490 (1.1%)
DIABETES <0.001
NO 44,610 (86%) 4,896 (64%) 39,714 (90%)
SE IGNORA 116 (0.2%) 46 (0.6%) 70 (0.2%)
SI 7,195 (14%) 2,685 (35%) 4,510 (10%)
EPOC <0.001
NO 51,138 (98%) 7,314 (96%) 43,824 (99%)
SE IGNORA 79 (0.2%) 30 (0.4%) 49 (0.1%)
SI 704 (1.4%) 283 (3.7%) 421 (1.0%)
ASMA <0.001
NO 50,696 (98%) 7,419 (97%) 43,277 (98%)
SE IGNORA 86 (0.2%) 32 (0.4%) 54 (0.1%)
SI 1,139 (2.2%) 176 (2.3%) 963 (2.2%)
INMUSUPR <0.001
NO 51,270 (99%) 7,400 (97%) 43,870 (99%)
SE IGNORA 98 (0.2%) 38 (0.5%) 60 (0.1%)
SI 553 (1.1%) 189 (2.5%) 364 (0.8%)
HIPERTEN <0.001
NO 40,685 (78%) 3,581 (47%) 37,104 (84%)
SE IGNORA 107 (0.2%) 43 (0.6%) 64 (0.1%)
SI 11,129 (21%) 4,003 (52%) 7,126 (16%)
VIH/SIDA <0.001
NO 51,658 (99%) 7,549 (99%) 44,109 (100%)
SE IGNORA 96 (0.2%) 34 (0.4%) 62 (0.1%)
SI 167 (0.3%) 44 (0.6%) 123 (0.3%)
OTRACON <0.001
NO 50,306 (97%) 7,169 (94%) 43,137 (97%)
SE IGNORA 126 (0.2%) 41 (0.5%) 85 (0.2%)
SI 1,489 (2.9%) 417 (5.5%) 1,072 (2.4%)
ENFCARDI <0.001
NO 50,544 (97%) 7,063 (93%) 43,481 (98%)
SE IGNORA 98 (0.2%) 37 (0.5%) 61 (0.1%)
SI 1,279 (2.5%) 527 (6.9%) 752 (1.7%)
OBESIDAD <0.001
NO 43,706 (84%) 5,793 (76%) 37,913 (86%)
SE IGNORA 97 (0.2%) 38 (0.5%) 59 (0.1%)
SI 8,118 (16%) 1,796 (24%) 6,322 (14%)
INSRENCR <0.001
NO 50,897 (98%) 7,135 (94%) 43,762 (99%)
SE IGNORA 92 (0.2%) 35 (0.5%) 57 (0.1%)
SI 932 (1.8%) 457 (6.0%) 475 (1.1%)
TABAQUIS <0.001
NO 48,985 (94%) 6,936 (91%) 42,049 (95%)
SE IGNORA 109 (0.2%) 43 (0.6%) 66 (0.1%)
SI 2,827 (5.4%) 648 (8.5%) 2,179 (4.9%)
RECTRATA <0.001
NO 47,724 (92%) 6,730 (89%) 40,994 (93%)
SI 3,961 (7.7%) 815 (11%) 3,146 (7.1%)
Unknown 236 82 154
TXCROBIA <0.001
NO 18,279 (66%) 1,152 (34%) 17,127 (70%)
SI 9,417 (34%) 2,209 (66%) 7,208 (30%)
Unknown 24,225 4,266 19,959
TXANTIVI <0.001
NO 44,617 (88%) 5,716 (77%) 38,901 (90%)
SI 6,020 (12%) 1,661 (23%) 4,359 (10%)
Unknown 1,284 250 1,034
ANTIVIRA
AMANTADINA 128 (2.1%) 5 (0.3%) 123 (2.8%)
AMPICILINA 1 (<0.1%) 0 (0%) 1 (<0.1%)
ANTIFLUD D 1 (<0.1%) 1 (<0.1%) 0 (0%)
azitromicina 1 (<0.1%) 0 (0%) 1 (<0.1%)
AZITROMICINA 5 (<0.1%) 0 (0%) 5 (0.1%)
CLARITROMICINA 1 (<0.1%) 0 (0%) 1 (<0.1%)
cloroquina 1 (<0.1%) 0 (0%) 1 (<0.1%)
CLOROQUINA 3 (<0.1%) 0 (0%) 3 (<0.1%)
cloroquina, azitrominicina 1 (<0.1%) 0 (0%) 1 (<0.1%)
INVAZ, FLUCONAZOL, 1 (<0.1%) 1 (<0.1%) 0 (0%)
IVERMECTIN 1 (<0.1%) 0 (0%) 1 (<0.1%)
IVERMECTINA 4 (<0.1%) 2 (0.1%) 2 (<0.1%)
IVERTMENTINA 1 (<0.1%) 0 (0%) 1 (<0.1%)
KALETRA 2 (<0.1%) 0 (0%) 2 (<0.1%)
LEVOFLOXACINO 1 (<0.1%) 0 (0%) 1 (<0.1%)
LORATADINA 3 (<0.1%) 0 (0%) 3 (<0.1%)
OSELTAMIVIR 5,828 (97%) 1,643 (99%) 4,185 (96%)
REMDESIVIR 2 (<0.1%) 1 (<0.1%) 1 (<0.1%)
RIBAVIRINA 5 (<0.1%) 3 (0.2%) 2 (<0.1%)
RIMNTADINA 9 (0.1%) 2 (0.1%) 7 (0.2%)
rivabarina 1 (<0.1%) 0 (0%) 1 (<0.1%)
VIBRAMICINA 1 (<0.1%) 0 (0%) 1 (<0.1%)
VIRAZIDE 2 (<0.1%) 0 (0%) 2 (<0.1%)
XX 1 (<0.1%) 0 (0%) 1 (<0.1%)
ZAVAMIVIR 21 (0.3%) 4 (0.2%) 17 (0.4%)
Unknown 45,896 5,965 39,931
ANTIPIRETICOS <0.001
NO 23,603 (46%) 3,147 (41%) 20,456 (46%)
SI 28,225 (54%) 4,444 (59%) 23,781 (54%)
Unknown 93 36 57
VACUNADO <0.001
NO 44,097 (85%) 7,003 (92%) 37,094 (84%)
SE IGNORA 80 (0.2%) 23 (0.3%) 57 (0.1%)
SI 7,700 (15%) 590 (7.7%) 7,110 (16%)
Unknown 44 11 33
TIPO_VAC_COV
AstraZeneca 3,329 (39%) 264 (44%) 3,065 (38%)
CanSino 533 (6.2%) 46 (7.7%) 487 (6.1%)
Gamaleya 1 (<0.1%) 1 (0.2%) 0 (0%)
Janssen (Johnson & Johnson) 85 (1.0%) 2 (0.3%) 83 (1.0%)
Moderna 240 (2.8%) 1 (0.2%) 239 (3.0%)
Novavax 3 (<0.1%) 0 (0%) 3 (<0.1%)
Pfizer BioNTech 2,125 (25%) 127 (21%) 1,998 (25%)
Se desconoce 243 (2.8%) 60 (10%) 183 (2.3%)
Sinopharma 26 (0.3%) 4 (0.7%) 22 (0.3%)
Sinovac 1,992 (23%) 93 (16%) 1,899 (24%)
Unknown 43,344 7,029 36,315
1 n (%); Median (IQR)
2 Pearson's Chi-squared test; Wilcoxon rank sum test; Fisher's exact test

#Podemos definir que probabilidad existion a no sobrevivir si los pacientes se encontraban con diferentes condiciones

Utilizando gtsummary

Clinica

library(gtsummary)

clinicm <- coxph(Surv(deftime, evento) ~ SEXO+EDAD+TOS+ODINOGIA+DISNEA+IRRITABI+DIARREA+DOTORACI+CALOFRIOS+CEFALEA+ARTRAL+RINORREA+POLIPNEA+CONJUN+CIANOSIS+INISUBIS+ANOSMIA+DISGEUSIA, data = covidsinfilt)

cm_table <- tbl_regression(clinicm, exponentiate = TRUE) 

cm_table
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic HR1 95% CI1 p-value
SEXO
FEMENINO — —
MASCULINO 1.02 0.97, 1.07 0.4
EDAD 1.01 1.01, 1.01 <0.001
TOS
NO — —
SE IGNORA 0.04 0.01, 0.21 <0.001
SI 0.96 0.91, 1.01 0.14
ODINOGIA
NO — —
SE IGNORA 0.99 0.43, 2.28 >0.9
SI 0.99 0.94, 1.04 0.7
DISNEA
NO — —
SI 1.00 0.92, 1.08 >0.9
IRRITABI
NO — —
SE IGNORA 0.52 0.16, 1.71 0.3
SI 1.03 0.98, 1.09 0.3
DIARREA
NO — —
SE IGNORA 1.83 0.41, 8.20 0.4
SI 0.97 0.92, 1.03 0.3
DOTORACI
NO — —
SE IGNORA 0.74 0.30, 1.87 0.5
SI 1.06 1.01, 1.11 0.020
CALOFRIOS
NO — —
SE IGNORA 2.85 0.68, 12.0 0.2
SI 0.99 0.94, 1.05 0.9
CEFALEA
NO — —
SE IGNORA 3.70 0.92, 14.8 0.065
SI 0.94 0.90, 0.99 0.019
ARTRAL
NO — —
SE IGNORA 0.86 0.39, 1.90 0.7
SI 0.97 0.92, 1.02 0.2
RINORREA
NO — —
SE IGNORA 2.37 0.59, 9.51 0.2
SI 0.92 0.87, 0.97 0.003
POLIPNEA
NO — —
SE IGNORA 0.72 0.36, 1.42 0.3
SI 1.05 1.00, 1.11 0.053
CONJUN
NO — —
SE IGNORA 0.46 0.17, 1.22 0.12
SI 0.97 0.88, 1.07 0.6
CIANOSIS
NO — —
SE IGNORA 1.29 0.43, 3.93 0.6
SI 1.08 0.98, 1.19 0.11
INISUBIS
NO — —
SE IGNORA 1.07 0.77, 1.47 0.7
SI 1.02 0.97, 1.08 0.3
ANOSMIA
NO — —
SE IGNORA 1.14 0.79, 1.64 0.5
SI 0.87 0.79, 0.96 0.005
DISGEUSIA
NO — —
SE IGNORA 0.96 0.67, 1.38 0.8
SI 0.92 0.83, 1.02 0.10
1 HR = Hazard Ratio, CI = Confidence Interval

comorbilidades

#sinfiltro
coxph(Surv(deftime, evento) ~DIABETES+EPOC+ASMA+INMUSUPR+HIPERTEN+ENFCARDI+OBESIDAD+INSRENCR+TABAQUIS+RECTRATA+TXCROBIA+TIPACIEN+VACUNADO, data = covidsinfilt)
## Call:
## coxph(formula = Surv(deftime, evento) ~ DIABETES + EPOC + ASMA + 
##     INMUSUPR + HIPERTEN + ENFCARDI + OBESIDAD + INSRENCR + TABAQUIS + 
##     RECTRATA + TXCROBIA + TIPACIEN + VACUNADO, data = covidsinfilt)
## 
##                            coef exp(coef)  se(coef)      z        p
## DIABETESSE IGNORA      1.146387  3.146804  0.364145  3.148  0.00164
## DIABETESSI             0.095667  1.100393  0.038645  2.476  0.01330
## EPOCSE IGNORA         -1.035340  0.355106  1.033234 -1.002  0.31633
## EPOCSI                 0.241843  1.273594  0.106991  2.260  0.02380
## ASMASE IGNORA         -2.599773  0.074290  1.464112 -1.776  0.07579
## ASMASI                 0.064475  1.066599  0.117929  0.547  0.58457
## INMUSUPRSE IGNORA      0.371861  1.450431  0.610118  0.609  0.54220
## INMUSUPRSI            -0.049718  0.951498  0.115539 -0.430  0.66697
## HIPERTENSE IGNORA      0.389513  1.476262  0.418170  0.931  0.35161
## HIPERTENSI             0.076544  1.079550  0.037282  2.053  0.04006
## ENFCARDISE IGNORA      0.662666  1.939958  0.465427  1.424  0.15451
## ENFCARDISI             0.083379  1.086954  0.072130  1.156  0.24770
## OBESIDADSE IGNORA      0.640214  1.896887  0.415831  1.540  0.12366
## OBESIDADSI            -0.012988  0.987096  0.040758 -0.319  0.74998
## INSRENCRSE IGNORA      1.015707  2.761316  0.579607  1.752  0.07970
## INSRENCRSI             0.356799  1.428749  0.087146  4.094 4.23e-05
## TABAQUISSE IGNORA     -0.117538  0.889107  0.334301 -0.352  0.72514
## TABAQUISSI            -0.087471  0.916245  0.062014 -1.410  0.15839
## RECTRATASI             0.045472  1.046521  0.050894  0.893  0.37161
## TXCROBIASI            -0.087650  0.916081  0.037941 -2.310  0.02088
## TIPACIENHOSPITALIZADO  0.508555  1.662887  0.310109  1.640  0.10102
## VACUNADOSI            -0.002949  0.997055  0.054811 -0.054  0.95709
## 
## Likelihood ratio test=86.7  on 22 df, p=1.24e-09
## n= 3294, number of events= 3294 
##    (48627 observations deleted due to missingness)
comorbcm <- coxph(Surv(deftime, evento) ~DIABETES+EPOC+ASMA+INMUSUPR+HIPERTEN+ENFCARDI+OBESIDAD+INSRENCR+TABAQUIS+RECTRATA+TXCROBIA+TIPACIEN+VACUNADO, data = covidsinfilt)

cm_table <- tbl_regression(comorbcm, exponentiate = TRUE) 

cm_table
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic HR1 95% CI1 p-value
DIABETES
NO — —
SE IGNORA 3.15 1.54, 6.42 0.002
SI 1.10 1.02, 1.19 0.013
EPOC
NO — —
SE IGNORA 0.36 0.05, 2.69 0.3
SI 1.27 1.03, 1.57 0.024
ASMA
NO — —
SE IGNORA 0.07 0.00, 1.31 0.076
SI 1.07 0.85, 1.34 0.6
INMUSUPR
NO — —
SE IGNORA 1.45 0.44, 4.80 0.5
SI 0.95 0.76, 1.19 0.7
HIPERTEN
NO — —
SE IGNORA 1.48 0.65, 3.35 0.4
SI 1.08 1.00, 1.16 0.040
ENFCARDI
NO — —
SE IGNORA 1.94 0.78, 4.83 0.2
SI 1.09 0.94, 1.25 0.2
OBESIDAD
NO — —
SE IGNORA 1.90 0.84, 4.29 0.12
SI 0.99 0.91, 1.07 0.7
INSRENCR
NO — —
SE IGNORA 2.76 0.89, 8.60 0.080
SI 1.43 1.20, 1.69 <0.001
TABAQUIS
NO — —
SE IGNORA 0.89 0.46, 1.71 0.7
SI 0.92 0.81, 1.03 0.2
RECTRATA
NO — —
SI 1.05 0.95, 1.16 0.4
TXCROBIA
NO — —
SI 0.92 0.85, 0.99 0.021
TIPACIEN
AMBULATORIO — —
HOSPITALIZADO 1.66 0.91, 3.05 0.10
VACUNADO
NO — —
SI 1.00 0.90, 1.11 >0.9
1 HR = Hazard Ratio, CI = Confidence Interval

KM curves and survival analysis

Sexo

library(ggthemes)

sexo<-survfit(Surv(deftime, evento) ~SEXO, data = covidsinfilt)


sexkmplot<-ggsurvplot(sexo, 
  xlab = "Days",
  ylab = "Survival Probability", xlim = c(0, 120),conf.int=T, risk.table = T,
  pval= TRUE, pval.coord = c(100, 0.25),fontsize = 5, break.time.by = 20, legend.title = "Sex", legend.labs = c("Female", "Male"))

sexkmplot

sexhr <- coxph(Surv(deftime, evento) ~SEXO, data = covidsinfilt)

sexhr_table <- tbl_regression(sexhr, exponentiate = TRUE) 

sexhr_table
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic HR1 95% CI1 p-value
SEXO
FEMENINO — —
MASCULINO 1.03 0.98, 1.08 0.2
1 HR = Hazard Ratio, CI = Confidence Interval

AGE

#stratificar edad

covidsinfilt<-covidsinfilt %>% 
  mutate(
    # para crear las categorias requeridas
    age_group = dplyr::case_when(
      EDAD <= 18            ~ "<18",
      EDAD >= 18 & EDAD <= 40 ~ "18-40",
      EDAD >= 40 & EDAD <= 60 ~ "40-60",
      EDAD >= 60 & EDAD <= 80 ~ "60-80",
      EDAD > 80             ~ ">80"
    ),
    # Convertimos a factor
    age_group = factor(
      age_group,
      level = c("<18","60-80","18-40", "40-60",">80")))


covidsinfilt %>% select(age_group,EDAD,estatus) %>%  tbl_summary(by=estatus) %>% add_p() %>%  add_overall()
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic Overall, N = 51,9211 No sobrevivió, N = 7,6271 Sobrevivió, N = 44,2941 p-value2
age_group <0.001
<18 2,028 (3.9%) 23 (0.3%) 2,005 (4.5%)
60-80 9,100 (18%) 3,841 (50%) 5,259 (12%)
18-40 21,377 (41%) 457 (6.0%) 20,920 (47%)
40-60 17,461 (34%) 2,157 (28%) 15,304 (35%)
>80 1,955 (3.8%) 1,149 (15%) 806 (1.8%)
EDAD 43 (31, 58) 67 (56, 76) 40 (29, 52) <0.001
1 n (%); Median (IQR)
2 Pearson's Chi-squared test; Wilcoxon rank sum test
agegr <- survfit(Surv(deftime, evento) ~age_group, data = covidsinfilt)

tbl_survfit(
  covidsinfilt, y = Surv(deftime, evento),
  include = c(age_group),
  probs = 0.5,
  label_header = "**Median Survival**"
  ) %>% 
  add_p()
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic Median Survival p-value1
age_group <0.001
<18 8.0 (5.0, 18)
60-80 14 (14, 15)
18-40 15 (15, 17)
40-60 15 (15, 16)
>80 12 (11, 12)
1 Log-rank test
agegrkmplot<-ggsurvplot(agegr, 
  xlab = "Days",
  ylab = "Survival Probability", xlim = c(0, 120),conf.int=T, risk.table = T,
  pval= TRUE, pval.coord = c(100, 0.25),fontsize = 5, break.time.by = 20, legend.title = "Age Group")

agegrkmplot

agestrat<-covidsinfilt %>% filter(age_group == "<18" | age_group == "60-80") 

agestrata<- survfit(Surv(deftime, evento) ~ age_group, data = agestrat)

ggsurvplot(agestrata, 
  xlab = "Days",
  ylab = "Survival Probability", xlim = c(0, 120), conf.int=T, risk.table = T,
  pval= TRUE, pval.coord = c(100, 0.25),fontsize = 5, break.time.by = 20, legend.title = "Age Group")

agerh <- coxph(Surv(deftime, evento) ~age_group, data = agestrat)

tbl_regression(agerh, exponentiate = TRUE) 
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic HR1 95% CI1 p-value
age_group
<18 — —
60-80 0.63 0.42, 0.95 0.028
18-40
40-60
>80
1 HR = Hazard Ratio, CI = Confidence Interval

TIPO DE PACIENTE

#TIPO DE PACIENTE
 
tippax <- survfit(Surv(deftime, evento) ~ TIPACIEN, data = covidsinfilt)

tbl_survfit(
  covidsinfilt, y = Surv(deftime, evento),
  include = c(TIPACIEN),
  probs = 0.5,
  label_header = "**Median Survival**"
  ) %>% add_p()
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic Median Survival p-value1
TIPACIEN 0.001
AMBULATORIO 16 (12, 22)
HOSPITALIZADO 14 (14, 15)
1 Log-rank test
tippaxkmplot<-ggsurvplot(tippax, 
  xlab = "Days",
  ylab = "Survival Probability", xlim = c(0, 120),conf.int=T, risk.table = T,
  pval= TRUE, pval.coord = c(100, 0.25),fontsize = 5, break.time.by = 20, legend.title = "Patient:",
  legend.labs = c("Outpatient", "Hospitalized"))

tippaxkmplot

tippaxcox <- coxph(Surv(deftime, evento) ~TIPACIEN, data = agestrat)

tbl_regression(tippaxcox, exponentiate = TRUE) 
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic HR1 95% CI1 p-value
TIPACIEN
AMBULATORIO — —
HOSPITALIZADO 1.28 0.84, 1.95 0.2
1 HR = Hazard Ratio, CI = Confidence Interval

Intubated

#INTUBADO

intub <- survfit(Surv(deftime, evento) ~INTUBADO, data = covidsinfilt)

tbl_survfit(
  covidsinfilt, y = Surv(deftime, evento),
  include = c(INTUBADO),
  probs = 0.5,
  label_header = "**Median Survival**"
  ) %>% 
  add_p()
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic Median Survival p-value1
INTUBADO <0.001
NO 14 (14, 14)
SI 16 (15, 16)
1 Log-rank test
intubkmplot<-ggsurvplot(intub, 
  xlab = "Days",
  ylab = "Survival Probability", xlim = c(0, 120),conf.int=T, risk.table = T,
  pval= TRUE, pval.coord = c(100, 0.25),fontsize = 5, break.time.by = 20, legend.title = "Intubated:",
  legend.labs = c("Not", "Yes"))

intubkmplot

intubcox <- coxph(Surv(deftime, evento) ~INTUBADO, data = agestrat)

tbl_regression(intubcox, exponentiate = TRUE)
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic HR1 95% CI1 p-value
INTUBADO
NO — —
SI 0.88 0.81, 0.95 <0.001
1 HR = Hazard Ratio, CI = Confidence Interval

DIAGNOSTICO PROBABLE (SEVERIDAD)

#DIAGPROB


sev <- survfit(Surv(deftime, evento) ~DIAGPROB, data = covidsinfilt)

tbl_survfit(
  covidsinfilt, y = Surv(deftime, evento),
  include = c(DIAGPROB),
  probs = 0.5,
  label_header = "**Median Survival**"
  ) %>% 
  add_p()
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic Median Survival p-value1
DIAGPROB 0.008
ENFERMEDAD TIPO INFLUENZA (ETI) 14 (12, 19)
INFECCION RESPIRATORIA AGUDA GRAVE (IRAG) 14 (14, 15)
1 Log-rank test
sevkmplot<-ggsurvplot(sev, 
  xlab = "Days",
  ylab = "Survival Probability", xlim = c(0, 120),conf.int=T, risk.table = T,
  pval= TRUE, pval.coord = c(100, 0.25),fontsize = 5, break.time.by = 20, legend.title = "Severity",
  legend.labs = c("ETI", "SARI"))

sevkmplot

clasicox <- coxph(Surv(deftime, evento) ~DIAGPROB, data = agestrat)

tbl_regression(clasicox, exponentiate = TRUE)
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic HR1 95% CI1 p-value
DIAGPROB
ENFERMEDAD TIPO INFLUENZA (ETI) — —
INFECCION RESPIRATORIA AGUDA GRAVE (IRAG) 1.26 0.89, 1.77 0.2
1 HR = Hazard Ratio, CI = Confidence Interval

COX-REGRESSION ANALISIS WITH CLINIC AND MORTALITY COVID-19

library(survminer)
library(survival)

covidsincox <-covidsinfilt %>% filter(if_all(c(SEXO, TIPACIEN, INTUBADO, DIAGPROB), ~ .x != "SE IGNORA"))

DEMO <- coxph(Surv(deftime, evento) ~ SEXO +  INTUBADO + DIAGPROB , data = covidsincox)

cm_table <- tbl_regression(DEMO, exponentiate = TRUE) 

cm_table
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead

## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic HR1 95% CI1 p-value
SEXO
FEMENINO — —
MASCULINO 1.03 0.99, 1.08 0.15
INTUBADO
NO — —
SI 0.89 0.84, 0.94 <0.001
DIAGPROB
ENFERMEDAD TIPO INFLUENZA (ETI) — —
INFECCION RESPIRATORIA AGUDA GRAVE (IRAG) 0.88 0.55, 1.40 0.6
1 HR = Hazard Ratio, CI = Confidence Interval
library(forestmodel)


print(forest_model(coxph(Surv(deftime, evento) ~ SEXO +  INTUBADO + DIAGPROB , data = covidsincox)))
## Warning in recalculate_width_panels(panel_positions, mapped_text =
## mapped_text, : Unable to resize forest panel to be smaller than its heading;
## consider a smaller text size