library(readxl)
## Warning: package 'readxl' was built under R version 4.5.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.5.3
##
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyr)
## Warning: package 'tidyr' was built under R version 4.5.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.5.3
library(randomizr)
## Warning: package 'randomizr' was built under R version 4.5.3
library(survival)
## Warning: package 'survival' was built under R version 4.5.3
library(survminer)
## Warning: package 'survminer' was built under R version 4.5.3
## Cargando paquete requerido: ggpubr
## Warning: package 'ggpubr' was built under R version 4.5.2
##
## Adjuntando el paquete: 'survminer'
## The following object is masked from 'package:survival':
##
## myeloma
library(haven)
## Warning: package 'haven' was built under R version 4.5.2
library(stats)
library(epitools)
##
## Adjuntando el paquete: 'epitools'
## The following object is masked from 'package:survival':
##
## ratetable
library(table1)
## Warning: package 'table1' was built under R version 4.5.3
##
## Adjuntando el paquete: 'table1'
## The following objects are masked from 'package:base':
##
## units, units<-
library(ggfortify)
## Warning: package 'ggfortify' was built under R version 4.5.3
setwd("~/MAESTRIA EPIDEMIOLOGIA ICESI/analisis_iterino")
library(readxl)
BD_HIFLO_análisis_interino_y_final <- read_excel("BD HIFLO análisis interino y final.xlsx")
View(BD_HIFLO_análisis_interino_y_final)
names(BD_HIFLO_análisis_interino_y_final)
## [1] "record_id" "Terapia" "edad"
## [4] "sexo" "peso" "talla"
## [7] "imc" "dias_sintomas" "ingreso_spo2"
## [10] "sop_res_pre_pao2fio2" "Interleuquina 6" "Ventilación mecánica"
## [13] "Ingreso a UCI" "Muerte" "Duración de la terapia"
## [16] "Tiempo a la intubación"
str(BD_HIFLO_análisis_interino_y_final)
## tibble [100 × 16] (S3: tbl_df/tbl/data.frame)
## $ record_id : chr [1:100] "74-1" "74-2" "74-3" "74-4" ...
## $ Terapia : num [1:100] 1 0 0 1 0 1 0 1 1 1 ...
## $ edad : num [1:100] 60 74 55 36 42 65 51 36 63 54 ...
## $ sexo : num [1:100] 1 1 1 1 1 1 0 1 1 1 ...
## $ peso : num [1:100] 71 85 96 75 99 ...
## $ talla : num [1:100] 175 176 168 157 168 173 166 174 165 165 ...
## $ imc : num [1:100] 23.2 27.4 34 30.4 35.1 25.4 30.6 35.8 25 32 ...
## $ dias_sintomas : num [1:100] 14 3 9 3 9 5 8 11 10 2 ...
## $ ingreso_spo2 : num [1:100] 85 95 92 85 91 85 92 90 76 77 ...
## $ sop_res_pre_pao2fio2 : num [1:100] 137.6 95.4 131.8 128.2 101.2 ...
## $ Interleuquina 6 : num [1:100] 7.26 23.29 NA 59.33 77.42 ...
## $ Ventilación mecánica : num [1:100] 0 0 0 0 1 1 1 0 0 0 ...
## $ Ingreso a UCI : num [1:100] 0 1 1 1 1 1 1 1 1 1 ...
## $ Muerte : num [1:100] 0 0 0 0 0 0 0 0 0 0 ...
## $ Duración de la terapia: num [1:100] 8 12 11 8 1 9 1 10 13 11 ...
## $ Tiempo a la intubación: num [1:100] 0 0 0 0 13 32 5 0 0 0 ...
colSums(is.na(BD_HIFLO_análisis_interino_y_final))
## record_id Terapia edad
## 0 0 0
## sexo peso talla
## 0 0 0
## imc dias_sintomas ingreso_spo2
## 0 0 0
## sop_res_pre_pao2fio2 Interleuquina 6 Ventilación mecánica
## 0 5 0
## Ingreso a UCI Muerte Duración de la terapia
## 0 0 0
## Tiempo a la intubación
## 0
colSums(is.na(BD_HIFLO_análisis_interino_y_final))
## record_id Terapia edad
## 0 0 0
## sexo peso talla
## 0 0 0
## imc dias_sintomas ingreso_spo2
## 0 0 0
## sop_res_pre_pao2fio2 Interleuquina 6 Ventilación mecánica
## 0 5 0
## Ingreso a UCI Muerte Duración de la terapia
## 0 0 0
## Tiempo a la intubación
## 0
#crear igual o mayor a 150
BD_HIFLO <- BD_HIFLO_análisis_interino_y_final %>%
mutate(
terapia_hiflo = factor(
Terapia,
levels = c(0, 1),
labels = c("Control", "HIFLO")
),
ventilacion_mecanica = factor(
`Ventilación mecánica`,
levels = c(0, 1),
labels = c("No", "Sí")
),
subgrupo_pafi = case_when(
sop_res_pre_pao2fio2 < 150 ~ "<150",
sop_res_pre_pao2fio2 >= 150 ~ ">=150",
TRUE ~ NA_character_
),
subgrupo_pafi = factor(
subgrupo_pafi,
levels = c(">=150", "<150")
)
)
tabla_2x2 <- table(BD_HIFLO$terapia_hiflo, BD_HIFLO$ventilacion_mecanica)
tabla_2x2
##
## No Sí
## Control 26 25
## HIFLO 35 14
oddsratio(tabla_2x2)
## $data
##
## No Sí Total
## Control 26 25 51
## HIFLO 35 14 49
## Total 61 39 100
##
## $measure
## odds ratio with 95% C.I.
## estimate lower upper
## Control 1.0000000 NA NA
## HIFLO 0.4213131 0.179393 0.9590893
##
## $p.value
## two-sided
## midp.exact fisher.exact chi.square
## Control NA NA NA
## HIFLO 0.03934013 0.04223363 0.03610391
##
## $correction
## [1] FALSE
##
## attr(,"method")
## [1] "median-unbiased estimate & mid-p exact CI"
#INTERPRETACIÓN ESTADÍSTICA: # (OR 0.421; IC 95%: 0.179 - 0.59) (p=0.0362) Chi-cuadrado. La terapia HIFLO se asoció con una reducción aproximada del 58% en las odds de ventilación mecánica frente al Control
#INTERPRETACIÓN CLÍNICA #En el grupo Control, 25 de 51 pacientes tuvieron ventilación mecánica. Mientras que en el grupo HIFLO, 14 de 49 pacientes tuvieron ventilación mecánica. Se evalúo el OR (OR 0.421; IC 95%: 0.179 - 0.59) (p=0.0362) Chi-cuadrado, La terapia HIFLO se asoció con una reducción aproximada del 58% en las odds de ventilación mecánica frente al Control. La asociación fue estadísticamente significativa, ya que el IC 95% no incluye 1 y los valores p fueron menores de 0.05.
#creamos el subgrupo de Pafi a partir de la base de datos original, ya que no encontramos la de finalizar el tratamiento
library(dplyr)
BD_HIFLO <- BD_HIFLO %>%
mutate(
subgrupo_pafi = case_when(
sop_res_pre_pao2fio2 < 150 ~ "<150",
sop_res_pre_pao2fio2 >= 150 ~ ">=150",
TRUE ~ NA_character_
),
subgrupo_pafi = factor(
subgrupo_pafi,
levels = c(">=150", "<150")
)
)
#contamos cuantos pacientes quedaron en cada subgrupo de PaO2/FiO2
BD_HIFLO %>%
count(subgrupo_pafi)
## # A tibble: 2 × 2
## subgrupo_pafi n
## <fct> <int>
## 1 >=150 18
## 2 <150 82
#Hacemos 3 columnas con Mutate de Terapia hiflo, Ventilación mecánica y el subgrupo de PaO2/FiO2
BD_HIFLO <- BD_HIFLO %>%
mutate(
terapia_hiflo = factor(
Terapia,
levels = c(0, 1),
labels = c("Control", "HIFLO")
),
ventilacion_mecanica = factor(
`Ventilación mecánica`,
levels = c(0, 1),
labels = c("No", "Sí")
),
subgrupo_pafi = case_when(
sop_res_pre_pao2fio2 < 150 ~ "<150",
sop_res_pre_pao2fio2 >= 150 ~ ">=150",
TRUE ~ NA_character_
),
subgrupo_pafi = factor(subgrupo_pafi, levels = c(">=150", "<150"))
)
BD_HIFLO
## # A tibble: 100 × 19
## record_id Terapia edad sexo peso talla imc dias_sintomas ingreso_spo2
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 74-1 1 60 1 71 175 23.2 14 85
## 2 74-2 0 74 1 85 176 27.4 3 95
## 3 74-3 0 55 1 96 168 34 9 92
## 4 74-4 1 36 1 75 157 30.4 3 85
## 5 74-5 0 42 1 99 168 35.1 9 91
## 6 74-6 1 65 1 76 173 25.4 5 85
## 7 74-7 0 51 0 84.4 166 30.6 8 92
## 8 74-8 1 36 1 108. 174 35.8 11 90
## 9 74-9 1 63 1 68 165 25 10 76
## 10 74-10 1 54 1 87 165 32 2 77
## # ℹ 90 more rows
## # ℹ 10 more variables: sop_res_pre_pao2fio2 <dbl>, `Interleuquina 6` <dbl>,
## # `Ventilación mecánica` <dbl>, `Ingreso a UCI` <dbl>, Muerte <dbl>,
## # `Duración de la terapia` <dbl>, `Tiempo a la intubación` <dbl>,
## # terapia_hiflo <fct>, ventilacion_mecanica <fct>, subgrupo_pafi <fct>
#Se realiza la tabla de análisis estratificado descriptivo de los pacientes con los 2 subgrupos de PaO2/FiO2, uso de terapia convencional o Hiflo y necesidad de Ventilación mecánica.
tabla_estratificada <- BD_HIFLO %>%
group_by(subgrupo_pafi, terapia_hiflo) %>%
summarise(
total_pacientes = n(),
ventilacion_si_n = sum(ventilacion_mecanica == "Sí", na.rm = TRUE),
ventilacion_si_pct = round(mean(ventilacion_mecanica == "Sí", na.rm = TRUE) * 100, 1),
ventilacion_no_n = sum(ventilacion_mecanica == "No", na.rm = TRUE),
ventilacion_no_pct = round(mean(ventilacion_mecanica == "No", na.rm = TRUE) * 100, 1),
.groups = "drop"
)
tabla_estratificada
## # A tibble: 4 × 7
## subgrupo_pafi terapia_hiflo total_pacientes ventilacion_si_n
## <fct> <fct> <int> <int>
## 1 >=150 Control 9 4
## 2 >=150 HIFLO 9 1
## 3 <150 Control 42 21
## 4 <150 HIFLO 40 13
## # ℹ 3 more variables: ventilacion_si_pct <dbl>, ventilacion_no_n <int>,
## # ventilacion_no_pct <dbl>
#Según estos resultados preliminares descriptivos, se observa que en ambos subgrupos con PaO2/FiO2 menor y mayor de 150, aquellos con terapia a alto flujo tuvieron menor porcentaje de necesidad de ventilación mecánica en contraste a aquellos que siguieron terapia convencional. Para el grupo con PaO2/FiO2 mayor a 150, únicamente uno tuvo necesidad de ventilación mecánica (11.1%), y en aquellos con PaO2/FiO2 menor a 150, aquellos con terapia de alto flujo únicamente 13(32.5%), tuvieron necesidad de Ventilación mecánica en contraste a 21 (50%) con terapia convencional. Este análisis preliminar de subgrupos nos puede llevar a pensar que la terapia con cánula de alto flujo es beneficiosa sobre la convencional. Sine embargo, estos hallazgos son netamente descriptivos por lo cual es necesario evaluar la interacción entre el subgrupo y el desenlace de manera formal.
#La pregunta a resolver es:
#Convertimos Ventilacion mecánica a número nuevamente para poder realizar el modelo
BD_HIFLO <- BD_HIFLO %>%
mutate(
vm_evento = case_when(
ventilacion_mecanica == "Sí" ~ 1,
ventilacion_mecanica == "No" ~ 0,
TRUE ~ NA_real_
)
)
modelo_interaccion <- glm(
vm_evento ~ terapia_hiflo * subgrupo_pafi,
data = BD_HIFLO,
family = binomial
)
summary(modelo_interaccion)
##
## Call:
## glm(formula = vm_evento ~ terapia_hiflo * subgrupo_pafi, family = binomial,
## data = BD_HIFLO)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.2231 0.6708 -0.333 0.739
## terapia_hifloHIFLO -1.8563 1.2550 -1.479 0.139
## subgrupo_pafi<150 0.2231 0.7384 0.302 0.763
## terapia_hifloHIFLO:subgrupo_pafi<150 1.1254 1.3357 0.843 0.399
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 133.75 on 99 degrees of freedom
## Residual deviance: 127.32 on 96 degrees of freedom
## AIC: 135.32
##
## Number of Fisher Scoring iterations: 4
#El valor p=0.399, lo que nos da un valor no estadísticamente significativo. Es decir, no hay suficietne evidencia para asegurar que el efecto la terapia con canula nasal sobre la necesidad de ventilación mecánica sea diferente en ambos grupos.
resultado_interaccion <- data.frame(
termino = names(coef(modelo_interaccion)),
OR = round(exp(coef(modelo_interaccion)), 3),
IC_95_inf = round(exp(confint(modelo_interaccion))[, 1], 3),
IC_95_sup = round(exp(confint(modelo_interaccion))[, 2], 3),
p_valor = round(summary(modelo_interaccion)$coefficients[, 4], 4)
)
## Waiting for profiling to be done...
## Waiting for profiling to be done...
resultado_interaccion
## termino OR
## (Intercept) (Intercept) 0.800
## terapia_hifloHIFLO terapia_hifloHIFLO 0.156
## subgrupo_pafi<150 subgrupo_pafi<150 1.250
## terapia_hifloHIFLO:subgrupo_pafi<150 terapia_hifloHIFLO:subgrupo_pafi<150 3.081
## IC_95_inf IC_95_sup p_valor
## (Intercept) 0.198 3.024 0.7394
## terapia_hifloHIFLO 0.007 1.441 0.1391
## subgrupo_pafi<150 0.291 5.673 0.7625
## terapia_hifloHIFLO:subgrupo_pafi<150 0.278 77.501 0.3995