Carga de base
Carga de librerías
library(tidyverse)
## Warning: package 'ggplot2' was built under R version 4.4.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 4.0.0 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(knitr)
library(tableone)
library(lme4)
## Cargando paquete requerido: Matrix
##
## Adjuntando el paquete: 'Matrix'
##
## The following objects are masked from 'package:tidyr':
##
## expand, pack, unpack
library(sjPlot)
##
## Adjuntando el paquete: 'sjPlot'
##
## The following object is masked from 'package:ggplot2':
##
## set_theme
library(performance)
## Warning: package 'performance' was built under R version 4.4.3
library(lmerTest)
## Warning: package 'lmerTest' was built under R version 4.4.3
##
## Adjuntando el paquete: 'lmerTest'
##
## The following object is masked from 'package:lme4':
##
## lmer
##
## The following object is masked from 'package:stats':
##
## step
#library(rworldmap) # no es necesario
#library(countrycode) # no es necesario
library(dplyr)
library(performance)
library(DHARMa)
## Warning: package 'DHARMa' was built under R version 4.4.3
## This is DHARMa 0.4.7. For overview type '?DHARMa'. For recent changes, type news(package = 'DHARMa')
library(ggeffects)
library(naniar)
## Warning: package 'naniar' was built under R version 4.4.3
library(marginaleffects)
## Warning: package 'marginaleffects' was built under R version 4.4.3
library(data.table)
## Warning: package 'data.table' was built under R version 4.4.3
##
## Adjuntando el paquete: 'data.table'
##
## The following objects are masked from 'package:lubridate':
##
## hour, isoweek, mday, minute, month, quarter, second, wday, week,
## yday, year
##
## The following objects are masked from 'package:dplyr':
##
## between, first, last
##
## The following object is masked from 'package:purrr':
##
## transpose
library(haven)
library(lme4)
library(geepack)
## Warning: package 'geepack' was built under R version 4.4.3
library(performance)
library(psych)
##
## Adjuntando el paquete: 'psych'
##
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
library(sjstats)
##
## Adjuntando el paquete: 'sjstats'
##
## The following object is masked from 'package:psych':
##
## phi
##
## The following objects are masked from 'package:performance':
##
## icc, r2
options(scipen=999, digits=2)
Datos faltantes
vis_miss(TES)
Eliminar datos faltantes de las columnas de caract del pie
TES <- TES %>%
filter(!if_any(16:25, is.na))
Pasar variables nuéricas a factor
TES[sapply(TES, is.character)] <- lapply(TES[sapply(TES, is.character)], as.factor)
TES$Cicatrización <- as.factor(TES$Cicatrización)
TES <- TES %>%
mutate(across(16:25, as.factor))
TES <- TES %>%
mutate(across(5:13, as.factor))
TES <- TES %>%
mutate(across(OM, as.factor))
Evaluar cuántos pacientes cicatrizaron
table1<-table(TES$Cicatrización)
table1
##
## 0 1
## 124 175
prop.table(table1)
##
## 0 1
## 0.41 0.59
Distribución de variables según outcomes
TES$cicat=TES$Cicatrización
#Isquemia
TES%>%
dplyr::group_by(isq) %>%
dplyr::summarise(tar = mean (as.numeric(cicat)-1)) %>%
ggplot(aes(x = isq, y = tar)) +
geom_point() +
geom_smooth(method = "lm", col = "blue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.5)
## `geom_smooth()` using formula = 'y ~ x'
TES %>%
dplyr::group_by(isq) %>%
dplyr::summarise(tar = mean(as.numeric(cicat)-1)) %>%
ggplot(aes(x = isq, y = tar)) +
geom_col(fill = "steelblue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.3) +
labs(x = "isquemia", y = "Proporción de cicatrizados") +
theme_minimal()
#localizacion
TES%>%
dplyr::group_by(loca) %>%
dplyr::summarise(tar = mean (as.numeric(cicat)-1)) %>%
ggplot(aes(x = loca, y = tar)) +
geom_point() +
geom_smooth(method = "lm", col = "blue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.5)
## `geom_smooth()` using formula = 'y ~ x'
TES %>%
dplyr::group_by(loca) %>%
dplyr::summarise(tar = mean(as.numeric(cicat)-1)) %>%
ggplot(aes(x = loca, y = tar)) +
geom_col(fill = "steelblue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.3) +
labs(x = "localizacion", y = "Proporción de cicatrizados") +
theme_minimal()
#topo
TES%>%
dplyr::group_by(topo) %>%
dplyr::summarise(tar = mean (as.numeric(cicat)-1)) %>%
ggplot(aes(x = topo, y = tar)) +
geom_point() +
geom_smooth(method = "lm", col = "blue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.5)
## `geom_smooth()` using formula = 'y ~ x'
TES %>%
dplyr::group_by(topo) %>%
dplyr::summarise(tar = mean(as.numeric(cicat)-1)) %>%
ggplot(aes(x = topo, y = tar)) +
geom_col(fill = "steelblue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.3) +
labs(x = "topografia", y = "Proporción de cicatrizados") +
theme_minimal()
#numero
TES%>%
dplyr::group_by(nume) %>%
dplyr::summarise(tar = mean (as.numeric(cicat)-1)) %>%
ggplot(aes(x = nume, y = tar)) +
geom_point() +
geom_smooth(method = "lm", col = "blue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.5)
## `geom_smooth()` using formula = 'y ~ x'
TES %>%
dplyr::group_by(nume) %>%
dplyr::summarise(tar = mean(as.numeric(cicat)-1)) %>%
ggplot(aes(x = nume, y = tar)) +
geom_col(fill = "steelblue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.3) +
labs(x = "numero de zonas", y = "Proporción de cicatrizados") +
theme_minimal()
#infeccion
TES%>%
dplyr::group_by(infe) %>%
dplyr::summarise(tar = mean (as.numeric(cicat)-1)) %>%
ggplot(aes(x = infe, y = tar)) +
geom_point() +
geom_smooth(method = "lm", col = "blue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.5)
## `geom_smooth()` using formula = 'y ~ x'
TES %>%
dplyr::group_by(infe) %>%
dplyr::summarise(tar = mean(as.numeric(cicat)-1)) %>%
ggplot(aes(x = infe, y = tar)) +
geom_col(fill = "steelblue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.3) +
labs(x = "infeccion", y = "Proporción de cicatrizados") +
theme_minimal()
#edema
TES%>%
dplyr::group_by(ede) %>%
dplyr::summarise(tar = mean (as.numeric(cicat)-1)) %>%
ggplot(aes(x = ede, y = tar)) +
geom_point() +
geom_smooth(method = "lm", col = "blue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.5)
## `geom_smooth()` using formula = 'y ~ x'
TES %>%
dplyr::group_by(ede) %>%
dplyr::summarise(tar = mean(as.numeric(cicat)-1)) %>%
ggplot(aes(x = ede, y = tar)) +
geom_col(fill = "steelblue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.3) +
labs(x = "edema", y = "Proporción de cicatrizados") +
theme_minimal()
#neuropatia
TES%>%
dplyr::group_by(neur) %>%
dplyr::summarise(tar = mean (as.numeric(cicat)-1)) %>%
ggplot(aes(x = neur, y = tar)) +
geom_point() +
geom_smooth(method = "lm", col = "blue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.5)
## `geom_smooth()` using formula = 'y ~ x'
TES %>%
dplyr::group_by(neur) %>%
dplyr::summarise(tar = mean(as.numeric(cicat)-1)) %>%
ggplot(aes(x = neur, y = tar)) +
geom_col(fill = "steelblue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.3) +
labs(x = "Neuropatia", y = "Proporción de cicatrizados") +
theme_minimal()
#tisu profundidad
TES%>%
dplyr::group_by(tisu) %>%
dplyr::summarise(tar = mean (as.numeric(cicat)-1)) %>%
ggplot(aes(x = tisu, y = tar)) +
geom_point() +
geom_smooth(method = "lm", col = "blue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.5)
## `geom_smooth()` using formula = 'y ~ x'
TES %>%
dplyr::group_by(tisu) %>%
dplyr::summarise(tar = mean(as.numeric(cicat)-1)) %>%
ggplot(aes(x = tisu, y = tar)) +
geom_col(fill = "steelblue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.3) +
labs(x = "Profundidad", y = "Proporción de cicatrizados") +
theme_minimal()
#area
TES%>%
dplyr::group_by(area) %>%
dplyr::summarise(tar = mean (as.numeric(cicat)-1)) %>%
ggplot(aes(x = area, y = tar)) +
geom_point() +
geom_smooth(method = "lm", col = "blue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.5)
## `geom_smooth()` using formula = 'y ~ x'
TES %>%
dplyr::group_by(area) %>%
dplyr::summarise(tar = mean(as.numeric(cicat)-1)) %>%
ggplot(aes(x = area, y = tar)) +
geom_col(fill = "steelblue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.3) +
labs(x = "Area", y = "Proporción de cicatrizados") +
theme_minimal()
#cicat
TES%>%
dplyr::group_by(cica) %>%
dplyr::summarise(tar = mean (as.numeric(cicat)-1)) %>%
ggplot(aes(x = cica, y = tar)) +
geom_point() +
geom_smooth(method = "lm", col = "blue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.5)
## `geom_smooth()` using formula = 'y ~ x'
TES %>%
dplyr::group_by(cica) %>%
dplyr::summarise(tar = mean(as.numeric(cicat)-1)) %>%
ggplot(aes(x = cica, y = tar)) +
geom_col(fill = "steelblue") +
geom_text(aes(label = round(tar, 2)), vjust = -0.3) +
labs(x = "Fase de cicatrizacion", y = "Proporción de cicatrizados") +
theme_minimal()
table(TES$cicat)
##
## 0 1
## 124 175
Categorización de las variables
#ISQuEMIA
TES <- TES %>%
mutate(isq_factor = factor(if_else(isq %in% c(2, 3), "SI", "NO/leve")),
isq_factor = factor(isq_factor, levels = rev(levels(isq_factor))))
table(TES$isq)
##
## 0 1 2 3
## 157 56 50 36
table(TES$isq_factor)
##
## SI NO/leve
## 86 213
#localizacion
TES <- TES %>%
mutate(loca_factor = factor(if_else(loca %in% c(2, 3), "Met/Tar", "Fal")),
loca_factor = factor(loca_factor, levels = rev(levels(loca_factor))))
table(TES$loca)
##
## 1 2 3
## 166 99 34
table(TES$loca_factor)
##
## Met/Tar Fal
## 133 166
#topog
TES <- TES %>%
mutate(topo_factor = factor(if_else(topo %in% c(1,2), "dor/plan/lat", "Mas de dos")))
TES <- TES %>%
mutate(topo_factor = factor(if_else(topo %in% c(1, 2), "dor/plan/lat", "Mas de dos")),
topo_factor = factor(topo_factor, levels = rev(levels(topo_factor))))
table(TES$topo)
##
## 1 2 3
## 136 60 103
table(TES$topo_factor)
##
## Mas de dos dor/plan/lat
## 103 196
#nume
TES <- TES %>%
mutate(nume_factor = factor(if_else(nume %in% c(2, 3), "Dos o mas", "Una")))
table(TES$nume)
##
## 1 2 3
## 211 59 29
table(TES$nume_factor)
##
## Dos o mas Una
## 88 211
#infe
TES <- TES %>%
mutate(infe_factor = case_when(
infe == 0 ~ "No",
infe %in% c(1, 2) ~ "Leve/Mod",
infe == 3 ~ "Grave",
TRUE ~ NA_character_ # conserva los NA originales
)) %>%
mutate(infe_factor = factor(infe_factor, levels = c("No", "Leve/Mod", "Grave")))
TES$infe_factor <- factor (TES$infe_factor, levels= c ("Grave","Leve/Mod","No"))
table(TES$infe)
##
## 0 1 2 3
## 67 43 152 37
table(TES$infe_factor)
##
## Grave Leve/Mod No
## 37 195 67
#edema
TES <- TES %>%
mutate(ede_factor = case_when(
ede == 2 ~ "Unilateral",
ede %in% c(0, 1) ~ "Sin/local",
ede == 3 ~ "Bilateral",
TRUE ~ NA_character_ # conserva los NA originales
)) %>%
mutate(ede_factor = factor(ede_factor, levels = c("Sin/local", "Unilateral", "Bilateral")))
TES$ede_factor <- factor (TES$ede_factor, levels= c ("Bilateral","Unilateral","Sin/local"))
table(TES$ede)
##
## 0 1 2 3
## 92 98 89 20
table(TES$ede_factor)
##
## Bilateral Unilateral Sin/local
## 20 89 190
#neur
TES <- TES %>%
mutate(neur_factor = factor(
if_else(neur %in% c(1, 2, 3), "Leve/mod/charcot", "No"),
levels = c("No", "Leve/mod/charcot")
))
table(TES$neur)
##
## 0 1 2 3
## 10 57 216 16
table(TES$neur_factor)
##
## No Leve/mod/charcot
## 10 289
#tisu (prof)
TES <- TES %>%
mutate(tisu_factor = factor(if_else(tisu %in% c(2, 3), "parcial/total", "Piel")))
table(TES$tisu)
##
## 1 2 3
## 52 98 149
table(TES$tisu_factor)
##
## parcial/total Piel
## 247 52
#area
TES$area_factor <- with(TES, ifelse(area == 1, "Menor a 10",
ifelse(area %in% c(1, 2), "10 a 40",
ifelse(area == 3, "Mas de 40", NA))))
TES$area_factor <- factor(TES$area_factor, levels = c("Menor a 10", "10 a 40", "Mas de 40"))
table(TES$area)
##
## 1 2 3
## 169 103 27
table(TES$area_factor)
##
## Menor a 10 10 a 40 Mas de 40
## 169 103 27
#cica(fase)
TES <- TES %>%
mutate(cica_factor = factor(if_else(cica %in% c(2, 3), "Granu/infla", "Epit")))
TES$cica_factor <- factor (TES$cica_factor, levels= c ("Granu/infla","Epit"))
table(TES$cica)
##
## 1 2 3
## 14 48 237
table(TES$cica_factor)
##
## Granu/infla Epit
## 285 14
Tabla 1
#Creo variable muerte 1 si/no para que la tabla se vea mejor
TES$cicat1 <- factor(TES$cicat,
levels = c(0, 1),
labels = c("No cicatrizo", "Cicatrizo"))
catvars = c( "isq_factor", "loca_factor", "topo_factor", "nume_factor", "infe_factor", "ede_factor", "neur_factor", "tisu_factor", "area_factor", "cica_factor", "OM","tbq", "aamen", "aamay", "dial", "ICC", "HTA", "CV", "sexo1fem")
vars = c("isq_factor", "loca_factor", "topo_factor", "nume_factor", "infe_factor", "ede_factor", "neur_factor", "tisu_factor", "area_factor", "cica_factor", "OM", "sanelian","SINBAD","tbq", "aamen", "aamay", "dial", "ICC", "HTA", "CV","Edad", "sexo1fem" )
tabla_1a <- CreateTableOne(vars = vars, strata = "cicat1", factorVars = catvars, data = TES)
print(tabla_1a)
## Stratified by cicat1
## No cicatrizo Cicatrizo p test
## n 124 175
## isq_factor = NO/leve (%) 70 (56.5) 143 (81.7) <0.001
## loca_factor = Fal (%) 59 (47.6) 107 (61.1) 0.027
## topo_factor = dor/plan/lat (%) 70 (56.5) 126 (72.0) 0.008
## nume_factor = Una (%) 62 (50.0) 149 (85.1) <0.001
## infe_factor (%) 0.002
## Grave 23 (18.5) 14 ( 8.0)
## Leve/Mod 83 (66.9) 112 (64.0)
## No 18 (14.5) 49 (28.0)
## ede_factor (%) <0.001
## Bilateral 14 (11.3) 6 ( 3.4)
## Unilateral 46 (37.1) 43 (24.6)
## Sin/local 64 (51.6) 126 (72.0)
## neur_factor = Leve/mod/charcot (%) 123 (99.2) 166 (94.9) 0.084
## tisu_factor = Piel (%) 9 ( 7.3) 43 (24.6) <0.001
## area_factor (%) 0.002
## Menor a 10 57 (46.0) 112 (64.0)
## 10 a 40 49 (39.5) 54 (30.9)
## Mas de 40 18 (14.5) 9 ( 5.1)
## cica_factor = Epit (%) 1 ( 0.8) 13 ( 7.4) 0.017
## OM = 1 (%) 65 (52.4) 74 (42.3) 0.107
## sanelian (mean (SD)) 18.59 (4.03) 15.49 (3.96) <0.001
## SINBAD (mean (SD)) 4.40 (1.12) 3.62 (1.15) <0.001
## tbq (%) 0.414
## 0 3 ( 2.4) 11 ( 6.3)
## 1 29 (23.4) 34 (19.5)
## 2 61 (49.2) 86 (49.4)
## 3 31 (25.0) 43 (24.7)
## aamen = 1 (%) 40 (32.3) 41 (23.4) 0.119
## aamay = 1 (%) 11 ( 8.9) 6 ( 3.4) 0.080
## dial = 1 (%) 13 (10.5) 13 ( 7.4) 0.474
## ICC = 1 (%) 20 (16.1) 20 (11.4) 0.315
## HTA = 1 (%) 95 (76.6) 120 (68.6) 0.163
## CV = 1 (%) 30 (24.2) 43 (24.6) 1.000
## Edad (mean (SD)) 59.00 (12.98) 56.98 (11.36) 0.154
## sexo1fem = 1 (%) 29 (23.4) 36 (20.6) 0.660
kableone(tabla_1a)
| No cicatrizo | Cicatrizo | p | test | |
|---|---|---|---|---|
| n | 124 | 175 | ||
| isq_factor = NO/leve (%) | 70 (56.5) | 143 (81.7) | <0.001 | |
| loca_factor = Fal (%) | 59 (47.6) | 107 (61.1) | 0.027 | |
| topo_factor = dor/plan/lat (%) | 70 (56.5) | 126 (72.0) | 0.008 | |
| nume_factor = Una (%) | 62 (50.0) | 149 (85.1) | <0.001 | |
| infe_factor (%) | 0.002 | |||
| Grave | 23 (18.5) | 14 ( 8.0) | ||
| Leve/Mod | 83 (66.9) | 112 (64.0) | ||
| No | 18 (14.5) | 49 (28.0) | ||
| ede_factor (%) | <0.001 | |||
| Bilateral | 14 (11.3) | 6 ( 3.4) | ||
| Unilateral | 46 (37.1) | 43 (24.6) | ||
| Sin/local | 64 (51.6) | 126 (72.0) | ||
| neur_factor = Leve/mod/charcot (%) | 123 (99.2) | 166 (94.9) | 0.084 | |
| tisu_factor = Piel (%) | 9 ( 7.3) | 43 (24.6) | <0.001 | |
| area_factor (%) | 0.002 | |||
| Menor a 10 | 57 (46.0) | 112 (64.0) | ||
| 10 a 40 | 49 (39.5) | 54 (30.9) | ||
| Mas de 40 | 18 (14.5) | 9 ( 5.1) | ||
| cica_factor = Epit (%) | 1 ( 0.8) | 13 ( 7.4) | 0.017 | |
| OM = 1 (%) | 65 (52.4) | 74 (42.3) | 0.107 | |
| sanelian (mean (SD)) | 18.59 (4.03) | 15.49 (3.96) | <0.001 | |
| SINBAD (mean (SD)) | 4.40 (1.12) | 3.62 (1.15) | <0.001 | |
| tbq (%) | 0.414 | |||
| 0 | 3 ( 2.4) | 11 ( 6.3) | ||
| 1 | 29 (23.4) | 34 (19.5) | ||
| 2 | 61 (49.2) | 86 (49.4) | ||
| 3 | 31 (25.0) | 43 (24.7) | ||
| aamen = 1 (%) | 40 (32.3) | 41 (23.4) | 0.119 | |
| aamay = 1 (%) | 11 ( 8.9) | 6 ( 3.4) | 0.080 | |
| dial = 1 (%) | 13 (10.5) | 13 ( 7.4) | 0.474 | |
| ICC = 1 (%) | 20 (16.1) | 20 (11.4) | 0.315 | |
| HTA = 1 (%) | 95 (76.6) | 120 (68.6) | 0.163 | |
| CV = 1 (%) | 30 (24.2) | 43 (24.6) | 1.000 | |
| Edad (mean (SD)) | 59.00 (12.98) | 56.98 (11.36) | 0.154 | |
| sexo1fem = 1 (%) | 29 (23.4) | 36 (20.6) | 0.660 |
table(TES$cicat1)
##
## No cicatrizo Cicatrizo
## 124 175
UNIVARIADO
TES$cicat=TES$Cicatrización
modelo1 <- glm(cicat ~ loca_factor+ topo_factor+nume_factor+ isq_factor+ infe_factor+ ede_factor+ neur_factor+ tisu_factor+ area_factor+ cica_factor , family = "binomial", data = TES)
t1<-tab_model(modelo1, show.se = T, show.dev = T, show.loglik = T, show.intercept = F,show.stat = F, show.reflvl = T, digits = 2, digits.p = 3, show.r2 = F,collapse.ci = F, title = "Cicatrización")
knitr::asis_output(t1$knitr)
| cicat | ||||
|---|---|---|---|---|
| Predictors | Odds Ratios | std. Error | CI | p |
| Met/Tar | Reference | |||
| Fal | 1.89 | 0.55 | 1.08 – 3.35 | 0.027 |
| Mas de dos | Reference | |||
| dor/plan/lat | 0.94 | 0.33 | 0.47 – 1.85 | 0.852 |
| Dos o mas | Reference | |||
| Una | 5.53 | 2.06 | 2.72 – 11.75 | <0.001 |
| SI | Reference | |||
| NO/leve | 3.44 | 1.07 | 1.89 – 6.38 | <0.001 |
| Grave | Reference | |||
| Leve/Mod | 2.31 | 1.07 | 0.94 – 5.85 | 0.070 |
| No | 2.56 | 1.53 | 0.80 – 8.41 | 0.115 |
| Bilateral | Reference | |||
| Unilateral | 1.98 | 1.19 | 0.63 – 6.76 | 0.256 |
| Sin/local | 2.45 | 1.40 | 0.82 – 7.96 | 0.116 |
| No | Reference | |||
| Leve/mod/charcot | 0.30 | 0.34 | 0.02 – 1.90 | 0.284 |
| parcial/total | Reference | |||
| Piel | 1.89 | 0.90 | 0.76 – 4.99 | 0.183 |
| Menor a 10 | Reference | |||
| 10 a 40 | 1.75 | 0.64 | 0.87 – 3.66 | 0.127 |
| Mas de 40 | 1.96 | 1.23 | 0.57 – 6.88 | 0.286 |
| Granu/infla | Reference | |||
| Epit | 4.18 | 4.60 | 0.68 – 80.84 | 0.194 |
| Observations | 299 | |||
| Deviance | 321.666 | |||
| log-Likelihood | -160.833 | |||
modelo2 <- glm(cicat ~ loca_factor , family = "binomial", data = TES)
modelo3 <- glm(cicat ~ topo_factor , family = "binomial", data = TES)
modelo4 <- glm(cicat ~ nume_factor , family = "binomial", data = TES)
modelo5 <- glm(cicat ~ isq_factor , family = "binomial", data = TES)
modelo6<- glm(cicat ~ infe_factor, family = "binomial", data = TES)
modelo7<- glm(cicat ~ ede_factor , family = "binomial", data = TES)
modelo8<- glm(cicat ~ neur_factor , family = "binomial", data = TES)
modelo9<- glm(cicat ~ tisu_factor , family = "binomial", data = TES)
modelo10<- glm(cicat ~ area_factor , family = "binomial", data = TES)
modelo11<- glm(cicat ~ cica_factor, family = "binomial", data = TES)
modelo12<- glm(cicat ~ evol, family = "binomial", data = TES)
library(broom)
##
## Adjuntando el paquete: 'broom'
## The following object is masked from 'package:sjstats':
##
## bootstrap
library(dplyr)
# Crear una lista con los modelos
modelos <- list(
modelo2, modelo3, modelo4, modelo5,
modelo6, modelo7, modelo8, modelo9,
modelo10, modelo11, modelo12
)
# Convertir a tabla ordenada
tabla_coef <- lapply(modelos, tidy) %>%
bind_rows(.id = "modelo")
# Ver la tabla
tabla_coef
## # A tibble: 25 × 6
## modelo term estimate std.error statistic p.value
## <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 1 (Intercept) 0.0451 0.173 0.260 7.95e- 1
## 2 1 loca_factorFal 0.550 0.237 2.32 2.05e- 2
## 3 2 (Intercept) -0.0972 0.197 -0.492 6.22e- 1
## 4 2 topo_factordor/plan/lat 0.685 0.247 2.77 5.61e- 3
## 5 3 (Intercept) -0.869 0.234 -3.72 2.00e- 4
## 6 3 nume_factorUna 1.75 0.278 6.27 3.52e-10
## 7 4 (Intercept) -0.523 0.223 -2.35 1.90e- 2
## 8 4 isq_factorNO/leve 1.24 0.267 4.64 3.43e- 6
## 9 5 (Intercept) -0.496 0.339 -1.46 1.43e- 1
## 10 5 infe_factorLeve/Mod 0.796 0.369 2.16 3.08e- 2
## # ℹ 15 more rows
#ordenar p valor
tabla_coef_ordenada <- tabla_coef %>%
arrange(p.value)
# Ver la tabla
tabla_coef_ordenada
## # A tibble: 25 × 6
## modelo term estimate std.error statistic p.value
## <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 3 nume_factorUna 1.75 0.278 6.27 3.52e-10
## 2 4 isq_factorNO/leve 1.24 0.267 4.64 3.43e- 6
## 3 9 (Intercept) 0.675 0.163 4.15 3.30e- 5
## 4 3 (Intercept) -0.869 0.234 -3.72 2.00e- 4
## 5 8 tisu_factorPiel 1.43 0.388 3.67 2.38e- 4
## 6 11 (Intercept) 0.511 0.141 3.63 2.82e- 4
## 7 5 infe_factorNo 1.50 0.437 3.43 6.07e- 4
## 8 9 area_factorMas de 40 -1.37 0.439 -3.11 1.84e- 3
## 9 6 ede_factorSin/local 1.52 0.512 2.98 2.88e- 3
## 10 2 topo_factordor/plan/lat 0.685 0.247 2.77 5.61e- 3
## # ℹ 15 more rows
evaluación del ICC Aquí va una explicación clara y directa de por qué pasa esto y cómo se interpreta:
1. Modelo nulo (solo intercepto) En el modelo nulo, el ICC refleja qué proporción de la variabilidad total del desenlace se debe a las diferencias entre grupos (por ejemplo, pacientes, hospitales, operadores, etc.). Si el ICC es 0.04, significa que solo el 4% de la variabilidad está explicada por el efecto aleatorio (las diferencias entre sujetos/grupos). 👉 Interpretación: El agrupamiento explica muy poco antes de ajustar por predictores.
2. Modelo mixto con variables fijas Cuando agregás variables explicativas (factores fijos), parte de la variabilidad dentro de los grupos (intra-grupo) se explica por esas covariables.
Eso puede provocar dos cosas:
Entonces, el ICC del modelo ajustado es:
[ ICC = ]
Si el ICC sube de 0.04 a 0.11, significa que:
Esto puede ocurrir por varios motivos:
Las diferencias entre los grupos explican muy poco del desenlace.
Una vez que tenés en cuenta factores como isquemia, infección, neuropatía, etc., los grupos (por ejemplo pacientes/operadores/hospitales, según tu modelo) pasan a explicar más variabilidad del outcome.
➡️ El agrupamiento adquiere más importancia relativa después del ajuste. ➡️ Las variables fijas están explicando variabilidad dentro de los grupos, dejando más clara la contribución del efecto aleatorio. ➡️ No es un error y no significa que los grupos estén “más correlacionados”, sino que su aporte es mayor en relación al total reducido.
ICC
TES$cicat_num <- as.numeric(as.character(TES$cicat))
mod_aleatorio_NULO <- lmer(cicat_num ~ (1 | NOMBRE), REML = T, data = TES)
tab_model(mod_aleatorio_NULO)
| cicat_num | |||
|---|---|---|---|
| Predictors | Estimates | CI | p |
| (Intercept) | 0.60 | 0.51 – 0.68 | <0.001 |
| Random Effects | |||
| σ2 | 0.24 | ||
| τ00 NOMBRE | 0.01 | ||
| ICC | 0.04 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.000 / 0.037 | ||
performance::icc(mod_aleatorio_NULO)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.037
## Unadjusted ICC: 0.037
library(broom.mixed)
## Warning: package 'broom.mixed' was built under R version 4.4.3
tidy(mod_aleatorio_NULO)
## # A tibble: 3 × 8
## effect group term estimate std.error statistic df p.value
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 fixed <NA> (Intercept) 0.597 0.0418 14.3 5.63 1.24e-5
## 2 ran_pars NOMBRE sd__(Intercept) 0.0961 NA NA NA NA
## 3 ran_pars Residual sd__Observation 0.488 NA NA NA NA
MODELO MIXTO 1
mod_mixto <- glmer(cicat ~ nume_factor + (1 | NOMBRE),
family = binomial,
data = TES)
## boundary (singular) fit: see help('isSingular')
tab_model(mod_mixto)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.42 | 0.27 – 0.66 | <0.001 |
| nume factor [Una] | 5.73 | 3.32 – 9.89 | <0.001 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.00 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.162 / NA | ||
MODELO MIXTO 2
mod_mixto2 <- glmer(cicat ~ nume_factor + isq_factor + (1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto2)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.17 | 0.09 – 0.34 | <0.001 |
| nume factor [Una] | 5.79 | 3.24 – 10.33 | <0.001 |
| isq factor [NO/leve] | 3.46 | 1.95 – 6.13 | <0.001 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.03 | ||
| ICC | 0.01 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.242 / 0.248 | ||
MODELO MIXTO 3
mod_mixto3 <- glmer(cicat ~ nume_factor + isq_factor +infe_factor +(1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto3)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.08 | 0.03 – 0.24 | <0.001 |
| nume factor [Una] | 5.12 | 2.81 – 9.30 | <0.001 |
| isq factor [NO/leve] | 3.73 | 2.06 – 6.74 | <0.001 |
| infe factor [Leve/Mod] | 2.19 | 0.90 – 5.36 | 0.086 |
| infe factor [No] | 3.31 | 1.16 – 9.47 | 0.025 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.13 | ||
| ICC | 0.04 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.270 / 0.297 | ||
MODELO MIXTO 4
mod_mixto4 <- glmer(cicat ~ nume_factor + isq_factor + tisu_factor + infe_factor+(1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto4)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.09 | 0.03 – 0.27 | <0.001 |
| nume factor [Una] | 5.02 | 2.76 – 9.13 | <0.001 |
| isq factor [NO/leve] | 3.36 | 1.84 – 6.12 | <0.001 |
| tisu factor [Piel] | 2.26 | 0.91 – 5.61 | 0.079 |
| infe factor [Leve/Mod] | 1.96 | 0.82 – 4.71 | 0.130 |
| infe factor [No] | 2.21 | 0.73 – 6.71 | 0.161 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.10 | ||
| ICC | 0.03 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.285 / 0.306 | ||
MATRIZ DE CORRELACION PARA EVALUAR COLINEALIDAD TISU INFE. Impresiona confusión
library(dplyr)
TES %>%
select(tisu_factor, infe_factor) %>%
mutate(across(everything(), ~as.numeric(as.factor(.)))) %>%
cor()
## tisu_factor infe_factor
## tisu_factor 1.00 0.45
## infe_factor 0.45 1.00
#DA COlinealidad MODERADA
MODELO MIXTO 5
mod_mixto5 <- glmer(cicat ~ nume_factor + isq_factor + tisu_factor + infe_factor+ ede_factor+(1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto5)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.04 | 0.01 – 0.18 | <0.001 |
| nume factor [Una] | 4.83 | 2.59 – 9.01 | <0.001 |
| isq factor [NO/leve] | 3.33 | 1.81 – 6.14 | <0.001 |
| tisu factor [Piel] | 2.22 | 0.88 – 5.63 | 0.093 |
| infe factor [Leve/Mod] | 2.02 | 0.81 – 5.02 | 0.130 |
| infe factor [No] | 2.21 | 0.69 – 7.08 | 0.184 |
| ede factor [Unilateral] | 2.64 | 0.78 – 8.93 | 0.119 |
| ede factor [Sin/local] | 2.93 | 0.91 – 9.39 | 0.071 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.17 | ||
| ICC | 0.05 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.305 / 0.338 | ||
MODELO MIXTO 6
mod_mixto6 <- glmer(cicat ~ topo_factor + nume_factor + isq_factor + tisu_factor + infe_factor+ ede_factor+(1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto6)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.04 | 0.01 – 0.20 | <0.001 |
|
topo factor [dor/plan/lat] |
0.73 | 0.37 – 1.45 | 0.369 |
| nume factor [Una] | 5.41 | 2.74 – 10.67 | <0.001 |
| isq factor [NO/leve] | 3.33 | 1.81 – 6.15 | <0.001 |
| tisu factor [Piel] | 2.28 | 0.90 – 5.78 | 0.084 |
| infe factor [Leve/Mod] | 2.02 | 0.81 – 5.06 | 0.132 |
| infe factor [No] | 2.34 | 0.72 – 7.64 | 0.158 |
| ede factor [Unilateral] | 2.54 | 0.75 – 8.58 | 0.134 |
| ede factor [Sin/local] | 3.00 | 0.94 – 9.62 | 0.064 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.17 | ||
| ICC | 0.05 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.307 / 0.341 | ||
MODELO MIXTO 7
mod_mixto7 <- glmer(cicat ~ topo_factor + nume_factor + isq_factor + tisu_factor + infe_factor+ ede_factor+ neur_factor + (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00328887 (tol = 0.002, component 1)
tab_model(mod_mixto7)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.15 | 0.01 – 2.19 | 0.166 |
|
topo factor [dor/plan/lat] |
0.73 | 0.37 – 1.46 | 0.377 |
| nume factor [Una] | 5.35 | 2.70 – 10.61 | <0.001 |
| isq factor [NO/leve] | 3.40 | 1.83 – 6.32 | <0.001 |
| tisu factor [Piel] | 2.07 | 0.80 – 5.33 | 0.133 |
| infe factor [Leve/Mod] | 2.03 | 0.80 – 5.11 | 0.134 |
| infe factor [No] | 2.37 | 0.72 – 7.83 | 0.157 |
| ede factor [Unilateral] | 2.52 | 0.75 – 8.55 | 0.137 |
| ede factor [Sin/local] | 3.00 | 0.93 – 9.63 | 0.065 |
|
neur factor [Leve/mod/charcot] |
0.26 | 0.03 – 2.39 | 0.236 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.21 | ||
| ICC | 0.06 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.318 / 0.359 | ||
MODELO MIXTO 8
mod_mixto8 <- glmer(cicat ~ topo_factor + nume_factor + isq_factor + tisu_factor + infe_factor+ ede_factor+ neur_factor + (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00328887 (tol = 0.002, component 1)
tab_model(mod_mixto8)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.15 | 0.01 – 2.19 | 0.166 |
|
topo factor [dor/plan/lat] |
0.73 | 0.37 – 1.46 | 0.377 |
| nume factor [Una] | 5.35 | 2.70 – 10.61 | <0.001 |
| isq factor [NO/leve] | 3.40 | 1.83 – 6.32 | <0.001 |
| tisu factor [Piel] | 2.07 | 0.80 – 5.33 | 0.133 |
| infe factor [Leve/Mod] | 2.03 | 0.80 – 5.11 | 0.134 |
| infe factor [No] | 2.37 | 0.72 – 7.83 | 0.157 |
| ede factor [Unilateral] | 2.52 | 0.75 – 8.55 | 0.137 |
| ede factor [Sin/local] | 3.00 | 0.93 – 9.63 | 0.065 |
|
neur factor [Leve/mod/charcot] |
0.26 | 0.03 – 2.39 | 0.236 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.21 | ||
| ICC | 0.06 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.318 / 0.359 | ||
MODELO MIXTO 9
mod_mixto9 <- glmer(cicat ~ topo_factor + nume_factor + isq_factor + tisu_factor + infe_factor+ ede_factor+ neur_factor + evol + (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00965086 (tol = 0.002, component 1)
tab_model(mod_mixto9)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.16 | 0.01 – 2.45 | 0.187 |
|
topo factor [dor/plan/lat] |
0.71 | 0.35 – 1.46 | 0.355 |
| nume factor [Una] | 5.56 | 2.75 – 11.22 | <0.001 |
| isq factor [NO/leve] | 3.52 | 1.85 – 6.68 | <0.001 |
| tisu factor [Piel] | 1.83 | 0.68 – 4.89 | 0.230 |
| infe factor [Leve/Mod] | 2.16 | 0.83 – 5.62 | 0.114 |
| infe factor [No] | 3.24 | 0.92 – 11.43 | 0.068 |
| ede factor [Unilateral] | 2.59 | 0.75 – 8.99 | 0.134 |
| ede factor [Sin/local] | 3.30 | 1.00 – 10.84 | 0.049 |
|
neur factor [Leve/mod/charcot] |
0.27 | 0.03 – 2.59 | 0.259 |
| evol | 0.99 | 0.99 – 1.00 | 0.012 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.42 | ||
| ICC | 0.11 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.368 / 0.439 | ||
MODELO MIXTO 10
mod_mixto10 <- glmer(cicat ~ topo_factor + nume_factor + isq_factor + tisu_factor + infe_factor+ ede_factor+ neur_factor + loca_factor+ (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00346577 (tol = 0.002, component 1)
tab_model(mod_mixto10)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.09 | 0.01 – 1.49 | 0.093 |
|
topo factor [dor/plan/lat] |
0.81 | 0.40 – 1.64 | 0.561 |
| nume factor [Una] | 4.78 | 2.39 – 9.58 | <0.001 |
| isq factor [NO/leve] | 3.69 | 1.96 – 6.97 | <0.001 |
| tisu factor [Piel] | 2.08 | 0.80 – 5.39 | 0.132 |
| infe factor [Leve/Mod] | 2.23 | 0.88 – 5.70 | 0.093 |
| infe factor [No] | 2.76 | 0.82 – 9.30 | 0.101 |
| ede factor [Unilateral] | 2.86 | 0.83 – 9.91 | 0.097 |
| ede factor [Sin/local] | 3.14 | 0.97 – 10.16 | 0.056 |
|
neur factor [Leve/mod/charcot] |
0.25 | 0.03 – 2.37 | 0.226 |
| loca factor [Fal] | 1.85 | 1.04 – 3.28 | 0.035 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.24 | ||
| ICC | 0.07 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.341 / 0.386 | ||
Modelo 11
mod_mixto11 <- glmer(cicat ~ topo_factor + nume_factor + isq_factor + tisu_factor + infe_factor+ ede_factor+ neur_factor + loca_factor+ evol+ (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00625735 (tol = 0.002, component 1)
tab_model(mod_mixto11)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.11 | 0.01 – 1.78 | 0.120 |
|
topo factor [dor/plan/lat] |
0.78 | 0.38 – 1.62 | 0.506 |
| nume factor [Una] | 5.06 | 2.49 – 10.31 | <0.001 |
| isq factor [NO/leve] | 3.74 | 1.95 – 7.17 | <0.001 |
| tisu factor [Piel] | 1.86 | 0.70 – 4.99 | 0.215 |
| infe factor [Leve/Mod] | 2.30 | 0.88 – 5.99 | 0.090 |
| infe factor [No] | 3.52 | 0.99 – 12.50 | 0.051 |
| ede factor [Unilateral] | 2.88 | 0.82 – 10.15 | 0.100 |
| ede factor [Sin/local] | 3.41 | 1.03 – 11.22 | 0.044 |
|
neur factor [Leve/mod/charcot] |
0.26 | 0.03 – 2.55 | 0.247 |
| loca factor [Fal] | 1.67 | 0.93 – 3.00 | 0.088 |
| evol | 0.99 | 0.99 – 1.00 | 0.020 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.42 | ||
| ICC | 0.11 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.379 / 0.450 | ||
Modelo 12
mod_mixto12 <- glmer(cicat ~ nume_factor + isq_factor + infe_factor+ ede_factor+ neur_factor + evol+ (1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto12)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.16 | 0.01 – 2.50 | 0.191 |
| nume factor [Una] | 4.93 | 2.59 – 9.41 | <0.001 |
| isq factor [NO/leve] | 3.77 | 2.01 – 7.08 | <0.001 |
| infe factor [Leve/Mod] | 2.28 | 0.88 – 5.92 | 0.090 |
| infe factor [No] | 3.90 | 1.21 – 12.57 | 0.023 |
| ede factor [Unilateral] | 2.64 | 0.76 – 9.20 | 0.127 |
| ede factor [Sin/local] | 3.31 | 1.00 – 10.95 | 0.050 |
|
neur factor [Leve/mod/charcot] |
0.22 | 0.02 – 2.14 | 0.194 |
| evol | 0.99 | 0.99 – 1.00 | 0.010 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.45 | ||
| ICC | 0.12 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.359 / 0.436 | ||
modelo 13
##ELIJO ESTE COMO EFECTOS PRINCIPALES
mod_mixto13 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + nume_factor+ ede_factor + evol + (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00214939 (tol = 0.002, component 1)
tab_model(mod_mixto13)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.02 | 0.00 – 0.14 | <0.001 |
| isq factor [NO/leve] | 3.96 | 2.10 – 7.46 | <0.001 |
| infe factor [Leve/Mod] | 2.46 | 0.94 – 6.39 | 0.066 |
| infe factor [No] | 4.47 | 1.38 – 14.42 | 0.012 |
| loca factor [Fal] | 1.68 | 0.95 – 2.99 | 0.076 |
| nume factor [Una] | 4.71 | 2.47 – 8.99 | <0.001 |
| ede factor [Unilateral] | 2.93 | 0.83 – 10.29 | 0.094 |
| ede factor [Sin/local] | 3.49 | 1.05 – 11.52 | 0.041 |
| evol | 0.99 | 0.99 – 1.00 | 0.015 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.39 | ||
| ICC | 0.11 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.358 / 0.427 | ||
#modmixto13 con factor de confusion tisu ES ESTE EL MODELO!!!
mod_mixto13ti <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + nume_factor+ ede_factor + evol + tisu_factor+ (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00378723 (tol = 0.002, component 1)
tab_model(mod_mixto13ti)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.03 | 0.00 – 0.14 | <0.001 |
| isq factor [NO/leve] | 3.65 | 1.92 – 6.92 | <0.001 |
| infe factor [Leve/Mod] | 2.26 | 0.87 – 5.82 | 0.092 |
| infe factor [No] | 3.26 | 0.95 – 11.20 | 0.061 |
| loca factor [Fal] | 1.70 | 0.95 – 3.02 | 0.072 |
| nume factor [Una] | 4.68 | 2.46 – 8.92 | <0.001 |
| ede factor [Unilateral] | 3.02 | 0.86 – 10.59 | 0.085 |
| ede factor [Sin/local] | 3.38 | 1.03 – 11.12 | 0.045 |
| evol | 0.99 | 0.99 – 1.00 | 0.019 |
| tisu factor [Piel] | 2.00 | 0.76 – 5.26 | 0.160 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.34 | ||
| ICC | 0.09 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.370 / 0.429 | ||
modelo 14
mod_mixto14 <- glmer(cicat ~ topo_factor + nume_factor + isq_factor + infe_factor+ ede_factor+ neur_factor + loca_factor+ evol+ (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00561179 (tol = 0.002, component 1)
tab_model(mod_mixto14)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.12 | 0.01 – 2.00 | 0.139 |
|
topo factor [dor/plan/lat] |
0.79 | 0.38 – 1.65 | 0.532 |
| nume factor [Una] | 5.06 | 2.48 – 10.31 | <0.001 |
| isq factor [NO/leve] | 4.04 | 2.12 – 7.68 | <0.001 |
| infe factor [Leve/Mod] | 2.48 | 0.94 – 6.50 | 0.066 |
| infe factor [No] | 4.66 | 1.40 – 15.50 | 0.012 |
| ede factor [Unilateral] | 2.80 | 0.79 – 9.90 | 0.110 |
| ede factor [Sin/local] | 3.50 | 1.06 – 11.59 | 0.041 |
|
neur factor [Leve/mod/charcot] |
0.22 | 0.02 – 2.14 | 0.192 |
| loca factor [Fal] | 1.65 | 0.92 – 2.97 | 0.093 |
| evol | 0.99 | 0.99 – 1.00 | 0.017 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.48 | ||
| ICC | 0.13 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.370 / 0.451 | ||
modelo 15
mod_mixto15 <- glmer(cicat ~ topo_factor + nume_factor + isq_factor + infe_factor+ ede_factor+ neur_factor + loca_factor+ evol+ (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00561179 (tol = 0.002, component 1)
tab_model(mod_mixto15)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.12 | 0.01 – 2.00 | 0.139 |
|
topo factor [dor/plan/lat] |
0.79 | 0.38 – 1.65 | 0.532 |
| nume factor [Una] | 5.06 | 2.48 – 10.31 | <0.001 |
| isq factor [NO/leve] | 4.04 | 2.12 – 7.68 | <0.001 |
| infe factor [Leve/Mod] | 2.48 | 0.94 – 6.50 | 0.066 |
| infe factor [No] | 4.66 | 1.40 – 15.50 | 0.012 |
| ede factor [Unilateral] | 2.80 | 0.79 – 9.90 | 0.110 |
| ede factor [Sin/local] | 3.50 | 1.06 – 11.59 | 0.041 |
|
neur factor [Leve/mod/charcot] |
0.22 | 0.02 – 2.14 | 0.192 |
| loca factor [Fal] | 1.65 | 0.92 – 2.97 | 0.093 |
| evol | 0.99 | 0.99 – 1.00 | 0.017 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.48 | ||
| ICC | 0.13 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.370 / 0.451 | ||
#modelo 16
mod_mixto16c <- glmer(cicat ~ topo_factor + nume_factor + isq_factor + infe_factor+ ede_factor+ neur_factor + loca_factor+ evol+ tisu_factor+ (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00677638 (tol = 0.002, component 1)
tab_model(mod_mixto16c)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.11 | 0.01 – 1.79 | 0.120 |
|
topo factor [dor/plan/lat] |
0.78 | 0.38 – 1.62 | 0.506 |
| nume factor [Una] | 5.06 | 2.49 – 10.31 | <0.001 |
| isq factor [NO/leve] | 3.74 | 1.95 – 7.17 | <0.001 |
| infe factor [Leve/Mod] | 2.30 | 0.88 – 5.99 | 0.090 |
| infe factor [No] | 3.52 | 0.99 – 12.50 | 0.051 |
| ede factor [Unilateral] | 2.88 | 0.82 – 10.15 | 0.100 |
| ede factor [Sin/local] | 3.41 | 1.03 – 11.22 | 0.044 |
|
neur factor [Leve/mod/charcot] |
0.26 | 0.03 – 2.55 | 0.247 |
| loca factor [Fal] | 1.67 | 0.93 – 3.00 | 0.088 |
| evol | 0.99 | 0.99 – 1.00 | 0.020 |
| tisu factor [Piel] | 1.86 | 0.70 – 4.99 | 0.215 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.42 | ||
| ICC | 0.11 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.379 / 0.450 | ||
Comparación del rendimiento de los modelos
AIC(mod_mixto, mod_mixto2, mod_mixto3, mod_mixto4, mod_mixto5, mod_mixto6, mod_mixto7, mod_mixto8, mod_mixto9, mod_mixto10, mod_mixto11, mod_mixto12,mod_mixto13, mod_mixto14, mod_mixto15, mod_mixto16c,mod_mixto13ti)
## df AIC
## mod_mixto 3 368
## mod_mixto2 4 351
## mod_mixto3 6 350
## mod_mixto4 7 349
## mod_mixto5 9 349
## mod_mixto6 10 350
## mod_mixto7 11 351
## mod_mixto8 11 351
## mod_mixto9 12 344
## mod_mixto10 12 348
## mod_mixto11 13 343
## mod_mixto12 10 342
## mod_mixto13 10 341
## mod_mixto14 12 342
## mod_mixto15 12 342
## mod_mixto16c 13 343
## mod_mixto13ti 11 341
anova(mod_mixto, mod_mixto2, mod_mixto3, mod_mixto4, mod_mixto5, mod_mixto6, mod_mixto7, mod_mixto8, mod_mixto9, mod_mixto10, mod_mixto11, mod_mixto12, mod_mixto13,mod_mixto14, mod_mixto16c, mod_mixto15,mod_mixto13ti, test="Chisq")
## Data: TES
## Models:
## mod_mixto: cicat ~ nume_factor + (1 | NOMBRE)
## mod_mixto2: cicat ~ nume_factor + isq_factor + (1 | NOMBRE)
## mod_mixto3: cicat ~ nume_factor + isq_factor + infe_factor + (1 | NOMBRE)
## mod_mixto4: cicat ~ nume_factor + isq_factor + tisu_factor + infe_factor + (1 | NOMBRE)
## mod_mixto5: cicat ~ nume_factor + isq_factor + tisu_factor + infe_factor + ede_factor + (1 | NOMBRE)
## mod_mixto6: cicat ~ topo_factor + nume_factor + isq_factor + tisu_factor + infe_factor + ede_factor + (1 | NOMBRE)
## mod_mixto12: cicat ~ nume_factor + isq_factor + infe_factor + ede_factor + neur_factor + evol + (1 | NOMBRE)
## mod_mixto13: cicat ~ isq_factor + infe_factor + loca_factor + nume_factor + ede_factor + evol + (1 | NOMBRE)
## mod_mixto7: cicat ~ topo_factor + nume_factor + isq_factor + tisu_factor + infe_factor + ede_factor + neur_factor + (1 | NOMBRE)
## mod_mixto8: cicat ~ topo_factor + nume_factor + isq_factor + tisu_factor + infe_factor + ede_factor + neur_factor + (1 | NOMBRE)
## mod_mixto13ti: cicat ~ isq_factor + infe_factor + loca_factor + nume_factor + ede_factor + evol + tisu_factor + (1 | NOMBRE)
## mod_mixto9: cicat ~ topo_factor + nume_factor + isq_factor + tisu_factor + infe_factor + ede_factor + neur_factor + evol + (1 | NOMBRE)
## mod_mixto10: cicat ~ topo_factor + nume_factor + isq_factor + tisu_factor + infe_factor + ede_factor + neur_factor + loca_factor + (1 | NOMBRE)
## mod_mixto14: cicat ~ topo_factor + nume_factor + isq_factor + infe_factor + ede_factor + neur_factor + loca_factor + evol + (1 | NOMBRE)
## mod_mixto15: cicat ~ topo_factor + nume_factor + isq_factor + infe_factor + ede_factor + neur_factor + loca_factor + evol + (1 | NOMBRE)
## mod_mixto11: cicat ~ topo_factor + nume_factor + isq_factor + tisu_factor + infe_factor + ede_factor + neur_factor + loca_factor + evol + (1 | NOMBRE)
## mod_mixto16c: cicat ~ topo_factor + nume_factor + isq_factor + infe_factor + ede_factor + neur_factor + loca_factor + evol + tisu_factor + (1 | NOMBRE)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## mod_mixto 3 368 379 -181 362
## mod_mixto2 4 351 366 -172 343 19.13 1 0.000012 ***
## mod_mixto3 6 350 372 -169 338 5.27 2 0.072 .
## mod_mixto4 7 349 375 -167 335 3.25 1 0.071 .
## mod_mixto5 9 349 383 -166 331 3.44 2 0.179
## mod_mixto6 10 350 387 -165 330 0.82 1 0.365
## mod_mixto12 10 342 379 -161 322 8.47 0
## mod_mixto13 10 341 378 -160 321 0.98 0
## mod_mixto7 11 351 391 -164 329 0.00 1 1.000
## mod_mixto8 11 351 391 -164 329 0.00 0
## mod_mixto13ti 11 341 382 -160 319 9.68 0
## mod_mixto9 12 344 388 -160 320 0.00 1 1.000
## mod_mixto10 12 348 393 -162 324 0.00 0
## mod_mixto14 12 342 387 -159 318 5.76 0
## mod_mixto15 12 342 387 -159 318 0.00 0
## mod_mixto11 13 343 391 -158 317 1.58 1 0.209
## mod_mixto16c 13 343 391 -158 317 0.00 0
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
MODELO DE EFECTOS PRINCIPALES mod_mixto13.
ranef(mod_mixto13ti)$NOMBRE
## (Intercept)
## ABUDARA 0.277
## Centro de rehabilitación, Obesidad y Diabetes. Formosa 0.427
## CER 0.470
## Clínica Centro Médico 0.433
## Hosp. Dr. J.R.Vidal -0.266
## Hospital Centro de Salud Zenón J. Santillán -0.525
## Hospital de Clínicas 0.095
## Hospital de Día de Pie Diabético. Polo Sanitario Malvinas Argentinas -0.553
## Hospital Güemes -0.054
## Hospital Perrupato 0.317
## Hospital Posadas 0.322
## Hospital san Martin -0.380
## Hospital Sommer -0.436
## HRRG 0.238
## Provincial Rosario -0.458
efectos_centros <- ranef(mod_mixto13ti)$NOMBRE
efectos_centros_df <- data.frame(
Centro = rownames(efectos_centros),
Intercepto_aleatorio = efectos_centros[, "(Intercept)"]
)
head(efectos_centros_df)
## Centro Intercepto_aleatorio
## 1 ABUDARA 0.28
## 2 Centro de rehabilitación, Obesidad y Diabetes. Formosa 0.43
## 3 CER 0.47
## 4 Clínica Centro Médico 0.43
## 5 Hosp. Dr. J.R.Vidal -0.27
## 6 Hospital Centro de Salud Zenón J. Santillán -0.53
intercepto_fijo <- fixef(mod_mixto13ti)["(Intercept)"]
efectos_centros_df$Intercepto_total <- intercepto_fijo + efectos_centros_df$Intercepto_aleatorio
library(ggplot2)
ggplot(efectos_centros_df, aes(x = reorder(Centro, Intercepto_total), y = Intercepto_total)) +
geom_point() +
coord_flip() +
labs(x = "Centro", y = "Intercepto total", title = "Variación del intercepto por centro") +
theme_minimal()
efectos_centros_df$Probabilidad_basal <- plogis(efectos_centros_df$Intercepto_total)
# 1️⃣ Cargar paquete
library(lme4)
library(ggplot2)
library(dplyr)
# 2️⃣ Extraer efectos aleatorios del modelo
efectos_centros <- ranef(mod_mixto13ti, condVar = TRUE)$NOMBRE
# 3️⃣ Convertir a data.frame
efectos_centros_df <- data.frame(
Centro = rownames(efectos_centros),
Intercepto_centro = efectos_centros[ , "(Intercept)"]
)
# 4️⃣ Sumar el intercepto fijo global
intercepto_fijo <- fixef(mod_mixto13ti)[["(Intercept)"]]
efectos_centros_df <- efectos_centros_df %>%
mutate(
Intercepto_total = intercepto_fijo + Intercepto_centro,
Probabilidad_basal = plogis(Intercepto_total) # convierte log-odds a probabilidad
)
# 5️⃣ Graficar la probabilidad basal de cicatrización por centro
ggplot(efectos_centros_df, aes(x = reorder(Centro, Probabilidad_basal), y = Probabilidad_basal)) +
geom_point(size = 3, color = "steelblue") +
geom_hline(yintercept = mean(efectos_centros_df$Probabilidad_basal),
linetype = "dashed", color = "red") +
coord_flip() +
labs(
x = "Centro",
y = "Probabilidad basal de cicatrización (ajustada)",
title = "Variación entre centros en la probabilidad basal de cicatrización"
) +
theme_minimal(base_size = 13)
Claro, te lo interpreto paso por paso. Este gráfico muestra la
variación entre centros en la probabilidad de cicatrización,
estimada a partir del modelo mixto donde el
centro es un efecto aleatorio.
Cada punto representa un centro Los centros están ordenados desde menor a mayor probabilidad de cicatrización predicha por el modelo mixto.CUANDO TODAS LAS VARIABLES SON CERO!!
El eje X es la probabilidad de cicatrización Valores alrededor de 0.015–0.040 (es decir, 1.5% a 4.0%).
La línea roja punteada Marca la probabilidad promedio o el intercepto predicho global del modelo mixto (el valor promedio de todos los centros).
Separación entre puntos = variabilidad entre centros Muestra cómo algunos centros tienen más probabilidad de cicatrizar (puntos a la derecha) y otros menos (puntos a la izquierda).
👉 Hay heterogeneidad real entre centros. Algunos centros tienen una probabilidad de cicatrización claramente menor que el promedio (izquierda de la línea roja), mientras que otros la tienen mayor (derecha de la línea roja).
Esto significa que:
Ejemplo: los que están cerca de 0.015–0.020 → Probabilidad de cicatrización más baja que la media → posible necesidad de revisar procesos.
Son los que están cerca de la línea roja. → No difieren sustancialmente del promedio nacional/global del modelo.
Cerca de 0.035–0.040 → Probabilidad de cicatrización claramente superior → podrían tener mejores prácticas o recursos.
Indirectamente sí:
Este gráfico demuestra que:
Podemos profundizar si querés:
¿Querés que analicemos qué tan grande es la variabilidad entre centros o cómo reportarlo en tu artículo?
#vamos a hacer las probabilidades por centro
pred <- predict(mod_mixto13ti, type = "response", re.form = ~(1|NOMBRE))
prob_centro <- aggregate(pred ~ NOMBRE, data = TES, mean)
prob_centro
## NOMBRE pred
## 1 ABUDARA 0.62
## 2 Centro de rehabilitación, Obesidad y Diabetes. Formosa 0.68
## 3 CER 0.60
## 4 Clínica Centro Médico 0.41
## 5 Hosp. Dr. J.R.Vidal 0.57
## 6 Hospital Centro de Salud Zenón J. Santillán 0.32
## 7 Hospital de Clínicas 0.73
## 8 Hospital de Día de Pie Diabético. Polo Sanitario Malvinas Argentinas 0.55
## 9 Hospital Güemes 0.74
## 10 Hospital Perrupato 0.80
## 11 Hospital Posadas 0.57
## 12 Hospital san Martin 0.51
## 13 Hospital Sommer 0.61
## 14 HRRG 0.63
## 15 Provincial Rosario 0.54
#Residuos vs predichos
library(DHARMa)
sim_res <- simulateResiduals(fittedModel = mod_mixto13ti, n = 1000)
plot(sim_res)
# Test formales
testUniformity(sim_res)
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: simulationOutput$scaledResiduals
## D = 0.05, p-value = 0.4
## alternative hypothesis: two-sided
testDispersion(sim_res)
##
## DHARMa nonparametric dispersion test via sd of residuals fitted vs.
## simulated
##
## data: simulationOutput
## dispersion = 1, p-value = 0.6
## alternative hypothesis: two.sided
testZeroInflation(sim_res)
##
## DHARMa zero-inflation test via comparison to expected zeros with
## simulation under H0 = fitted model
##
## data: simulationOutput
## ratioObsSim = 1, p-value = 1
## alternative hypothesis: two.sided
library(performance)
# Colinealidad
check_collinearity(mod_mixto13ti)
## # Check for Multicollinearity
##
## Low Correlation
##
## Term VIF VIF 95% CI adj. VIF Tolerance Tolerance 95% CI
## isq_factor 1.10 [1.03, 1.37] 1.05 0.91 [0.73, 0.97]
## infe_factor 1.44 [1.28, 1.70] 1.20 0.69 [0.59, 0.78]
## loca_factor 1.07 [1.01, 1.42] 1.03 0.94 [0.70, 0.99]
## nume_factor 1.09 [1.02, 1.37] 1.04 0.92 [0.73, 0.98]
## ede_factor 1.26 [1.14, 1.49] 1.12 0.80 [0.67, 0.88]
## evol 1.06 [1.01, 1.47] 1.03 0.95 [0.68, 0.99]
## tisu_factor 1.26 [1.14, 1.49] 1.12 0.79 [0.67, 0.88]
# Bondad de ajuste (R² marginal y condicional)
r2_nakagawa(mod_mixto13ti)
## # R2 for Mixed Models
##
## Conditional R2: 0.429
## Marginal R2: 0.370
# Varianza de efectos aleatorios
VarCorr(mod_mixto13ti)
## Groups Name Std.Dev.
## NOMBRE (Intercept) 0.581
ICC
performance::icc(mod_mixto13ti)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.093
## Unadjusted ICC: 0.059
Calibracion
#HyL
library(ResourceSelection)
## Warning: package 'ResourceSelection' was built under R version 4.4.3
## ResourceSelection 0.3-6 2023-06-27
pred <- predict(mod_mixto13ti, type = "response")
hoslem.test(TES$cicat, pred, g = 10)
## Warning in Ops.factor(1, y): '-' no es significativo para factores
##
## Hosmer and Lemeshow goodness of fit (GOF) test
##
## data: TES$cicat, pred
## X-squared = NA, df = 8, p-value = NA
#Brier
library(DescTools)
##
## Adjuntando el paquete: 'DescTools'
## The following objects are masked from 'package:psych':
##
## AUC, ICC, SD
## The following object is masked from 'package:data.table':
##
## %like%
pred <- predict(mod_mixto13ti, type = "response")
BrierScore <- BrierScore(TES$cicat, pred)
## Warning in Ops.factor(resp, (1 - pred)^2): '*' no es significativo para
## factores
## Warning in Ops.factor(1, resp): '-' no es significativo para factores
BrierScore
## [1] NA
Calibración:NO SE QUE ES ESTO EN MODELO MIXTO
TES$lp <- predict(mod_mixto13ti, type = "link") # predicción en escala logit
mod_slope <- glm(cicat ~ lp, family = binomial, data = TES)
summary(mod_slope)
##
## Call:
## glm(formula = cicat ~ lp, family = binomial, data = TES)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.0332 0.1486 -0.22 0.82
## lp 1.0811 0.1334 8.10 0.00000000000000053 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 405.76 on 298 degrees of freedom
## Residual deviance: 302.75 on 297 degrees of freedom
## AIC: 306.8
##
## Number of Fisher Scoring iterations: 4
auc
library(pROC)
## Warning: package 'pROC' was built under R version 4.4.3
## Type 'citation("pROC")' for a citation.
##
## Adjuntando el paquete: 'pROC'
## The following objects are masked from 'package:stats':
##
## cov, smooth, var
pred <- predict(mod_mixto13ti, type = "response")
roc_obj <- roc(TES$cicat, pred)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
auc(roc_obj)
## Area under the curve: 0.82
plot(roc_obj, print.auc = TRUE, col = "blue", main = "Curva ROC - Modelo mixto")
#modificación de efecto tabaquismo activo
TES <- TES %>%
mutate(tbq_factor = factor(if_else(tbq %in% c(1), "si", "no")))
table(TES$tbq_factor)
##
## no si
## 236 63
mod_mixto13timod <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + nume_factor+ ede_factor + evol + tisu_factor+ isq_factor:tbq_factor+ (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.0241635 (tol = 0.002, component 1)
tab_model(mod_mixto13timod)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.02 | 0.00 – 0.13 | <0.001 |
| isq factor [NO/leve] | 4.42 | 2.12 – 9.22 | <0.001 |
| infe factor [Leve/Mod] | 2.26 | 0.87 – 5.87 | 0.093 |
| infe factor [No] | 3.23 | 0.93 – 11.19 | 0.064 |
| loca factor [Fal] | 1.70 | 0.95 – 3.02 | 0.073 |
| nume factor [Una] | 4.77 | 2.50 – 9.12 | <0.001 |
| ede factor [Unilateral] | 3.12 | 0.87 – 11.18 | 0.080 |
| ede factor [Sin/local] | 3.45 | 1.02 – 11.64 | 0.046 |
| evol | 0.99 | 0.99 – 1.00 | 0.015 |
| tisu factor [Piel] | 1.86 | 0.70 – 4.91 | 0.213 |
|
isq factor [SI] × tbq factorsi |
1.34 | 0.41 – 4.37 | 0.630 |
|
isq factor [NO/leve] × tbq factorsi |
0.57 | 0.25 – 1.28 | 0.174 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.32 | ||
| ICC | 0.09 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.379 / 0.434 | ||
AIC(mod_mixto13timod)
## [1] 343
#modificacion efecto tabaquismo si o no
TES <- TES %>%
mutate(tbq_factor1 = factor(if_else(tbq %in% c(1,2), "si", "no")))
table(TES$tbq_factor1)
##
## no si
## 89 210
mod_mixto13timod2 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + nume_factor+ ede_factor + evol + tisu_factor+ isq_factor:tbq_factor1+ (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.0074089 (tol = 0.002, component 1)
tab_model(mod_mixto13timod2)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.03 | 0.01 – 0.20 | <0.001 |
| isq factor [NO/leve] | 3.05 | 0.99 – 9.41 | 0.052 |
| infe factor [Leve/Mod] | 2.28 | 0.89 – 5.86 | 0.087 |
| infe factor [No] | 3.24 | 0.94 – 11.12 | 0.062 |
| loca factor [Fal] | 1.71 | 0.96 – 3.04 | 0.068 |
| nume factor [Una] | 4.59 | 2.41 – 8.76 | <0.001 |
| ede factor [Unilateral] | 3.19 | 0.90 – 11.33 | 0.072 |
| ede factor [Sin/local] | 3.57 | 1.07 – 11.92 | 0.038 |
| evol | 0.99 | 0.99 – 1.00 | 0.019 |
| tisu factor [Piel] | 1.99 | 0.75 – 5.26 | 0.166 |
|
isq factor [SI] × tbq factor1si |
0.66 | 0.22 – 2.03 | 0.474 |
|
isq factor [NO/leve] × tbq factor1si |
0.85 | 0.39 – 1.89 | 0.698 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.29 | ||
| ICC | 0.08 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.373 / 0.423 | ||
AIC(mod_mixto13timod2)
## [1] 344
DICOTOMIZO INFECCIÓN SI O NO A VER SI HAY ALGUN CAMBIO, PERO NO ES SIGNIFICATIVO TAMPODO
#que pasa si dicotomizo infección?Tampoco modifica nada. No es significativo
TES <- TES %>%
mutate(infe_factor1 = factor(if_else(infe %in% c(1,2,3), "si", "no")))
TES$infe_factor1 <- factor (TES$infe_factor1, levels= c ("si","no"))
table(TES$infe_factor1)
##
## si no
## 232 67
mod_mixto13ti1 <- glmer(cicat ~ isq_factor + infe_factor1 + loca_factor + nume_factor+ ede_factor + evol + tisu_factor+ (1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto13ti1)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.06 | 0.01 – 0.23 | <0.001 |
| isq factor [NO/leve] | 3.38 | 1.81 – 6.31 | <0.001 |
| infe factor1 [no] | 1.48 | 0.66 – 3.31 | 0.338 |
| loca factor [Fal] | 1.63 | 0.92 – 2.86 | 0.092 |
| nume factor [Una] | 4.83 | 2.55 – 9.13 | <0.001 |
| ede factor [Unilateral] | 2.64 | 0.77 – 9.10 | 0.123 |
| ede factor [Sin/local] | 3.35 | 1.02 – 11.01 | 0.046 |
| evol | 0.99 | 0.99 – 1.00 | 0.017 |
| tisu factor [Piel] | 2.16 | 0.83 – 5.59 | 0.114 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.23 | ||
| ICC | 0.07 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.360 / 0.402 | ||
AIC(mod_mixto13ti1)
## [1] 342
#OJO AGREGANDO DIALSIS BAJA LA DEVIANCE Y EL AIC
mod_mixto13ti2 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + nume_factor+ ede_factor + evol + tisu_factor+dial+ (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00791649 (tol = 0.002, component 1)
tab_model(mod_mixto13ti2)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.03 | 0.00 – 0.15 | <0.001 |
| isq factor [NO/leve] | 3.59 | 1.88 – 6.84 | <0.001 |
| infe factor [Leve/Mod] | 2.25 | 0.87 – 5.81 | 0.094 |
| infe factor [No] | 3.33 | 0.96 – 11.49 | 0.057 |
| loca factor [Fal] | 1.69 | 0.95 – 3.01 | 0.074 |
| nume factor [Una] | 4.71 | 2.47 – 8.99 | <0.001 |
| ede factor [Unilateral] | 2.99 | 0.85 – 10.54 | 0.088 |
| ede factor [Sin/local] | 3.39 | 1.02 – 11.21 | 0.046 |
| evol | 0.99 | 0.99 – 1.00 | 0.018 |
| tisu factor [Piel] | 1.95 | 0.74 – 5.15 | 0.177 |
| dial [1] | 0.74 | 0.26 – 2.10 | 0.575 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.36 | ||
| ICC | 0.10 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.372 / 0.434 | ||
AIC(mod_mixto13ti2)
## [1] 343
AIC(mod_mixto13ti)
## [1] 341
deviance(mod_mixto13ti2)
## [1] 302
deviance(mod_mixto13ti)
## [1] 303
#VOY A AGREGAR AAMAY
#OJO AGREGANDO DIALSIS BAJA LA DEVIANCE Y EL AIC
mod_mixto13ti3 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + nume_factor+ ede_factor + evol + tisu_factor+dial+aamay+ (1 | NOMBRE),
family = binomial,
data = TES)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00444906 (tol = 0.002, component 1)
tab_model(mod_mixto13ti3)
| cicat | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.03 | 0.00 – 0.15 | <0.001 |
| isq factor [NO/leve] | 3.32 | 1.73 – 6.36 | <0.001 |
| infe factor [Leve/Mod] | 2.33 | 0.90 – 6.06 | 0.082 |
| infe factor [No] | 3.73 | 1.06 – 13.13 | 0.040 |
| loca factor [Fal] | 1.71 | 0.96 – 3.05 | 0.071 |
| nume factor [Una] | 4.54 | 2.38 – 8.67 | <0.001 |
| ede factor [Unilateral] | 3.33 | 0.94 – 11.79 | 0.063 |
| ede factor [Sin/local] | 3.67 | 1.11 – 12.19 | 0.033 |
| evol | 0.99 | 0.99 – 1.00 | 0.012 |
| tisu factor [Piel] | 2.07 | 0.77 – 5.58 | 0.150 |
| dial [1] | 0.79 | 0.27 – 2.28 | 0.658 |
| aamay [1] | 0.32 | 0.10 – 1.07 | 0.065 |
| Random Effects | |||
| σ2 | 3.29 | ||
| τ00 NOMBRE | 0.37 | ||
| ICC | 0.10 | ||
| N NOMBRE | 15 | ||
| Observations | 299 | ||
| Marginal R2 / Conditional R2 | 0.386 / 0.447 | ||
AIC(mod_mixto13ti3)
## [1] 341
AIC(mod_mixto13ti2)
## [1] 343
AIC(mod_mixto13ti)
## [1] 341
deviance(mod_mixto13ti2)
## [1] 302
deviance(mod_mixto13ti)
## [1] 303
deviance(mod_mixto13ti3)
## [1] 299
library(pROC)
pred <- predict(mod_mixto13ti3, type = "response")
roc_obj <- roc(TES$cicat, pred)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
auc(roc_obj)
## Area under the curve: 0.83
plot(roc_obj, print.auc = TRUE, col = "blue", main = "Curva ROC - Modelo mixto")