library(readxl)
TES <- read_excel("C:/Users/Administrador/Downloads/TES.xlsx",
sheet = "R")
View(TES)
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(lme4)
## Cargando paquete requerido: Matrix
##
## Adjuntando el paquete: 'Matrix'
##
## The following objects are masked from 'package:tidyr':
##
## expand, pack, unpack
library(sjPlot)
## Learn more about sjPlot with 'browseVignettes("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
options(scipen=999, digits=2)
library(tidyverse)
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(sjPlot)
library(lmerTest)
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
vis_miss(TES)

TES <- TES %>%
filter(!if_any(16:25, is.na))
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))
table(TES$Cicatrización)
##
## 0 1
## 124 175
TES$cicat=TES$Cicatrización
modelo1 <- glm(cicat ~ loca+ topo+nume+ isq+ infe+ ede+ neur+ tisu+ area+ cica , 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)
Cicatrización
|
|
cicat
|
|
Predictors
|
Odds Ratios
|
std. Error
|
CI
|
p
|
|
area2
|
1.75
|
0.70
|
0.81 – 3.91
|
0.161
|
|
area3
|
2.00
|
1.32
|
0.55 – 7.48
|
0.294
|
|
cica2
|
0.15
|
0.18
|
0.01 – 1.04
|
0.101
|
|
cica3
|
0.34
|
0.38
|
0.02 – 2.27
|
0.341
|
|
ede1
|
1.83
|
0.82
|
0.76 – 4.42
|
0.177
|
|
ede2
|
1.13
|
0.55
|
0.44 – 2.93
|
0.796
|
|
ede3
|
0.53
|
0.35
|
0.14 – 1.88
|
0.334
|
|
infe1
|
0.48
|
0.27
|
0.15 – 1.44
|
0.191
|
|
infe2
|
0.36
|
0.21
|
0.11 – 1.14
|
0.087
|
|
infe3
|
0.21
|
0.15
|
0.05 – 0.87
|
0.033
|
|
isq1
|
0.61
|
0.24
|
0.28 – 1.32
|
0.205
|
|
isq2
|
0.28
|
0.11
|
0.13 – 0.61
|
0.001
|
|
isq3
|
0.17
|
0.08
|
0.07 – 0.43
|
<0.001
|
|
loca2
|
0.61
|
0.21
|
0.31 – 1.21
|
0.157
|
|
loca3
|
0.30
|
0.16
|
0.10 – 0.85
|
0.025
|
|
neur1
|
0.23
|
0.29
|
0.01 – 1.86
|
0.242
|
|
neur2
|
0.25
|
0.31
|
0.01 – 1.90
|
0.258
|
|
neur3
|
0.22
|
0.30
|
0.01 – 2.37
|
0.268
|
|
nume2
|
0.14
|
0.06
|
0.06 – 0.32
|
<0.001
|
|
nume3
|
0.16
|
0.10
|
0.05 – 0.51
|
0.003
|
|
tisu2
|
0.52
|
0.27
|
0.18 – 1.40
|
0.202
|
|
tisu3
|
0.68
|
0.43
|
0.19 – 2.36
|
0.542
|
|
topo2
|
1.42
|
0.59
|
0.63 – 3.26
|
0.402
|
|
topo3
|
1.09
|
0.46
|
0.48 – 2.50
|
0.844
|
|
Observations
|
299
|
|
Deviance
|
309.410
|
|
log-Likelihood
|
-154.705
|
modelo2 <- glm(cicat ~ loca , family = "binomial", data = TES)
modelo3 <- glm(cicat ~ topo , family = "binomial", data = TES)
modelo4 <- glm(cicat ~ nume , family = "binomial", data = TES)
modelo5 <- glm(cicat ~ isq , family = "binomial", data = TES)
modelo6<- glm(cicat ~ infe, family = "binomial", data = TES)
modelo7<- glm(cicat ~ ede , family = "binomial", data = TES)
modelo8<- glm(cicat ~ neur , family = "binomial", data = TES)
modelo9<- glm(cicat ~ tisu , family = "binomial", data = TES)
modelo10<- glm(cicat ~ area , family = "binomial", data = TES)
modelo6<- glm(cicat ~ cica, 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, modelo6
)
# Convertir a tabla ordenada
tabla_coef <- lapply(modelos, tidy) %>%
bind_rows(.id = "modelo")
# Ver la tabla
tabla_coef
## # A tibble: 33 × 6
## modelo term estimate std.error statistic p.value
## <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 1 (Intercept) 0.595 0.162 3.67 0.000242
## 2 1 loca2 -0.494 0.258 -1.91 0.0559
## 3 1 loca3 -0.713 0.380 -1.88 0.0605
## 4 2 (Intercept) 0.606 0.179 3.38 0.000730
## 5 2 topo2 -0.0596 0.322 -0.185 0.853
## 6 2 topo3 -0.703 0.267 -2.64 0.00836
## 7 3 (Intercept) 0.877 0.151 5.80 0.00000000657
## 8 3 nume2 -1.62 0.317 -5.11 0.000000314
## 9 3 nume3 -2.02 0.460 -4.40 0.0000108
## 10 4 (Intercept) 0.820 0.173 4.73 0.00000220
## # ℹ 23 more rows
table(TES$topo)
##
## 1 2 3
## 136 60 103
#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()

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
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()

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
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()

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
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()

TES <- TES %>%
mutate(nume_factor = factor(if_else(nume %in% c(2, 3), "Dos o mas", "Una")))
TES <- TES %>% mutate(nume_factor = factor(nume_factor, levels = c("Una", "Dos o mas")))
TES$nume_factor <- factor (TES$nume_factor, levels= c ("Dos o mas","Una"))
table(TES$nume)
##
## 1 2 3
## 211 59 29
table(TES$nume_factor)
##
## Dos o mas Una
## 88 211
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()

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
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()

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
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()

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
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()

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
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()

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
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()

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
mod_mixto <- glmer(cicat ~ isq_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.59
|
0.38 – 0.92
|
0.019
|
|
isq factor [NO/leve]
|
3.45
|
2.04 – 5.81
|
<0.001
|
|
Random Effects
|
|
σ2
|
3.29
|
|
τ00 NOMBRE
|
0.00
|
|
N NOMBRE
|
15
|
|
Observations
|
299
|
|
Marginal R2 / Conditional R2
|
0.087 / NA
|
mod_mixto2 <- glmer(cicat ~ isq_factor + infe_factor +(1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto2)
|
|
cicat
|
|
Predictors
|
Odds Ratios
|
CI
|
p
|
|
(Intercept)
|
0.20
|
0.08 – 0.50
|
0.001
|
|
isq factor [NO/leve]
|
3.77
|
2.15 – 6.60
|
<0.001
|
|
infe factor [Leve/Mod]
|
2.99
|
1.30 – 6.87
|
0.010
|
|
infe factor [No]
|
6.10
|
2.29 – 16.26
|
<0.001
|
|
Random Effects
|
|
σ2
|
3.29
|
|
τ00 NOMBRE
|
0.24
|
|
ICC
|
0.07
|
|
N NOMBRE
|
15
|
|
Observations
|
299
|
|
Marginal R2 / Conditional R2
|
0.152 / 0.209
|
mod_mixto3 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor +(1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto3)
|
|
cicat
|
|
Predictors
|
Odds Ratios
|
CI
|
p
|
|
(Intercept)
|
0.12
|
0.04 – 0.32
|
<0.001
|
|
isq factor [NO/leve]
|
4.17
|
2.34 – 7.45
|
<0.001
|
|
infe factor [Leve/Mod]
|
3.12
|
1.33 – 7.31
|
0.009
|
|
infe factor [No]
|
6.81
|
2.48 – 18.68
|
<0.001
|
|
loca factor [Fal]
|
2.17
|
1.28 – 3.67
|
0.004
|
|
Random Effects
|
|
σ2
|
3.29
|
|
τ00 NOMBRE
|
0.23
|
|
ICC
|
0.07
|
|
N NOMBRE
|
15
|
|
Observations
|
299
|
|
Marginal R2 / Conditional R2
|
0.190 / 0.244
|
table(TES$NOMBRE)
##
## ABUDARA
## 10
## Centro de rehabilitación, Obesidad y Diabetes. Formosa
## 7
## CER
## 6
## Clínica Centro Médico
## 9
## Hosp. Dr. J.R.Vidal
## 12
## Hospital Centro de Salud Zenón J. Santillán
## 8
## Hospital de Clínicas
## 16
## Hospital de Día de Pie Diabético. Polo Sanitario Malvinas Argentinas
## 61
## Hospital Güemes
## 11
## Hospital Perrupato
## 15
## Hospital Posadas
## 97
## Hospital san Martin
## 10
## Hospital Sommer
## 17
## HRRG
## 10
## Provincial Rosario
## 10
mod_mixto4 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + topo_factor + (1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto4)
|
|
cicat
|
|
Predictors
|
Odds Ratios
|
CI
|
p
|
|
(Intercept)
|
0.09
|
0.03 – 0.26
|
<0.001
|
|
isq factor [NO/leve]
|
4.18
|
2.33 – 7.50
|
<0.001
|
|
infe factor [Leve/Mod]
|
2.88
|
1.22 – 6.79
|
0.016
|
|
infe factor [No]
|
5.30
|
1.88 – 14.98
|
0.002
|
|
loca factor [Fal]
|
2.23
|
1.31 – 3.78
|
0.003
|
topo factor [dor/plan/lat]
|
1.68
|
0.94 – 3.01
|
0.080
|
|
Random Effects
|
|
σ2
|
3.29
|
|
τ00 NOMBRE
|
0.20
|
|
ICC
|
0.06
|
|
N NOMBRE
|
15
|
|
Observations
|
299
|
|
Marginal R2 / Conditional R2
|
0.205 / 0.250
|
mod_mixto5 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + topo_factor + nume_factor+ (1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto5)
|
|
cicat
|
|
Predictors
|
Odds Ratios
|
CI
|
p
|
|
(Intercept)
|
0.06
|
0.02 – 0.19
|
<0.001
|
|
isq factor [NO/leve]
|
4.03
|
2.20 – 7.40
|
<0.001
|
|
infe factor [Leve/Mod]
|
2.38
|
0.96 – 5.92
|
0.062
|
|
infe factor [No]
|
3.93
|
1.31 – 11.75
|
0.014
|
|
loca factor [Fal]
|
1.79
|
1.03 – 3.11
|
0.038
|
topo factor [dor/plan/lat]
|
0.87
|
0.44 – 1.71
|
0.678
|
|
nume factor [Una]
|
5.01
|
2.55 – 9.85
|
<0.001
|
|
Random Effects
|
|
σ2
|
3.29
|
|
τ00 NOMBRE
|
0.16
|
|
ICC
|
0.05
|
|
N NOMBRE
|
15
|
|
Observations
|
299
|
|
Marginal R2 / Conditional R2
|
0.290 / 0.323
|
mod_mixto6 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + topo_factor + nume_factor+ ede_factor +(1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto6)
|
|
cicat
|
|
Predictors
|
Odds Ratios
|
CI
|
p
|
|
(Intercept)
|
0.02
|
0.00 – 0.12
|
<0.001
|
|
isq factor [NO/leve]
|
4.01
|
2.16 – 7.45
|
<0.001
|
|
infe factor [Leve/Mod]
|
2.45
|
0.95 – 6.30
|
0.062
|
|
infe factor [No]
|
3.88
|
1.23 – 12.25
|
0.021
|
|
loca factor [Fal]
|
1.84
|
1.04 – 3.23
|
0.035
|
topo factor [dor/plan/lat]
|
0.83
|
0.41 – 1.68
|
0.605
|
|
nume factor [Una]
|
4.84
|
2.43 – 9.64
|
<0.001
|
|
ede factor [Unilateral]
|
2.82
|
0.81 – 9.76
|
0.102
|
|
ede factor [Sin/local]
|
3.29
|
1.02 – 10.67
|
0.047
|
|
Random Effects
|
|
σ2
|
3.29
|
|
τ00 NOMBRE
|
0.24
|
|
ICC
|
0.07
|
|
N NOMBRE
|
15
|
|
Observations
|
299
|
|
Marginal R2 / Conditional R2
|
0.314 / 0.360
|
mod_mixto7 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + topo_factor + nume_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.00389862 (tol = 0.002, component 1)
tab_model(mod_mixto7)
|
|
cicat
|
|
Predictors
|
Odds Ratios
|
CI
|
p
|
|
(Intercept)
|
0.10
|
0.01 – 1.63
|
0.106
|
|
isq factor [NO/leve]
|
4.07
|
2.18 – 7.61
|
<0.001
|
|
infe factor [Leve/Mod]
|
2.43
|
0.94 – 6.27
|
0.066
|
|
infe factor [No]
|
3.78
|
1.18 – 12.10
|
0.025
|
|
loca factor [Fal]
|
1.85
|
1.04 – 3.27
|
0.035
|
topo factor [dor/plan/lat]
|
0.83
|
0.41 – 1.69
|
0.613
|
|
nume factor [Una]
|
4.76
|
2.37 – 9.54
|
<0.001
|
|
ede factor [Unilateral]
|
2.80
|
0.81 – 9.72
|
0.104
|
|
ede factor [Sin/local]
|
3.27
|
1.01 – 10.59
|
0.049
|
neur factor [Leve/mod/charcot]
|
0.21
|
0.02 – 1.93
|
0.166
|
|
Random Effects
|
|
σ2
|
3.29
|
|
τ00 NOMBRE
|
0.29
|
|
ICC
|
0.08
|
|
N NOMBRE
|
15
|
|
Observations
|
299
|
|
Marginal R2 / Conditional R2
|
0.329 / 0.384
|
mod_mixto8 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + topo_factor + nume_factor+ ede_factor + neur_factor + 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.0034586 (tol = 0.002, component 1)
tab_model(mod_mixto8)
|
|
cicat
|
|
Predictors
|
Odds Ratios
|
CI
|
p
|
|
(Intercept)
|
0.09
|
0.01 – 1.49
|
0.093
|
|
isq factor [NO/leve]
|
3.69
|
1.96 – 6.97
|
<0.001
|
|
infe factor [Leve/Mod]
|
2.23
|
0.88 – 5.70
|
0.093
|
|
infe factor [No]
|
2.76
|
0.82 – 9.30
|
0.101
|
|
loca factor [Fal]
|
1.85
|
1.04 – 3.28
|
0.035
|
topo factor [dor/plan/lat]
|
0.81
|
0.40 – 1.64
|
0.561
|
|
nume factor [Una]
|
4.78
|
2.39 – 9.58
|
<0.001
|
|
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
|
|
tisu factor [Piel]
|
2.08
|
0.80 – 5.39
|
0.132
|
|
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
|
mod_mixto9 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + topo_factor + nume_factor+ ede_factor + neur_factor + tisu_factor + area_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.00309462 (tol = 0.002, component 1)
tab_model(mod_mixto9)
|
|
cicat
|
|
Predictors
|
Odds Ratios
|
CI
|
p
|
|
(Intercept)
|
0.05
|
0.00 – 0.92
|
0.044
|
|
isq factor [NO/leve]
|
3.74
|
1.98 – 7.07
|
<0.001
|
|
infe factor [Leve/Mod]
|
2.55
|
0.97 – 6.67
|
0.057
|
|
infe factor [No]
|
3.35
|
0.97 – 11.63
|
0.057
|
|
loca factor [Fal]
|
1.92
|
1.08 – 3.42
|
0.027
|
topo factor [dor/plan/lat]
|
0.91
|
0.44 – 1.88
|
0.803
|
|
nume factor [Una]
|
5.79
|
2.72 – 12.32
|
<0.001
|
|
ede factor [Unilateral]
|
2.63
|
0.76 – 9.12
|
0.127
|
|
ede factor [Sin/local]
|
3.10
|
0.95 – 10.10
|
0.060
|
neur factor [Leve/mod/charcot]
|
0.27
|
0.03 – 2.52
|
0.249
|
|
tisu factor [Piel]
|
2.20
|
0.85 – 5.69
|
0.105
|
|
area factor [10 a 40]
|
1.68
|
0.80 – 3.55
|
0.172
|
|
area factor [Mas de 40]
|
1.81
|
0.51 – 6.41
|
0.360
|
|
Random Effects
|
|
σ2
|
3.29
|
|
τ00 NOMBRE
|
0.21
|
|
ICC
|
0.06
|
|
N NOMBRE
|
15
|
|
Observations
|
299
|
|
Marginal R2 / Conditional R2
|
0.346 / 0.385
|
mod_mixto10 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + topo_factor + nume_factor+ ede_factor + neur_factor + tisu_factor + area_factor + cica_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.00374972 (tol = 0.002, component 1)
tab_model(mod_mixto10)
|
|
cicat
|
|
Predictors
|
Odds Ratios
|
CI
|
p
|
|
(Intercept)
|
0.05
|
0.00 – 0.98
|
0.048
|
|
isq factor [NO/leve]
|
3.63
|
1.93 – 6.84
|
<0.001
|
|
infe factor [Leve/Mod]
|
2.57
|
0.98 – 6.73
|
0.055
|
|
infe factor [No]
|
3.02
|
0.86 – 10.53
|
0.084
|
|
loca factor [Fal]
|
1.91
|
1.07 – 3.39
|
0.028
|
topo factor [dor/plan/lat]
|
0.92
|
0.45 – 1.89
|
0.823
|
|
nume factor [Una]
|
5.71
|
2.69 – 12.14
|
<0.001
|
|
ede factor [Unilateral]
|
2.42
|
0.70 – 8.44
|
0.164
|
|
ede factor [Sin/local]
|
2.97
|
0.91 – 9.65
|
0.070
|
neur factor [Leve/mod/charcot]
|
0.27
|
0.03 – 2.49
|
0.247
|
|
tisu factor [Piel]
|
1.96
|
0.75 – 5.14
|
0.172
|
|
area factor [10 a 40]
|
1.72
|
0.82 – 3.62
|
0.153
|
|
area factor [Mas de 40]
|
1.89
|
0.53 – 6.69
|
0.325
|
|
cica factor [Epit]
|
3.57
|
0.40 – 31.99
|
0.256
|
|
Random Effects
|
|
σ2
|
3.29
|
|
τ00 NOMBRE
|
0.16
|
|
ICC
|
0.05
|
|
N NOMBRE
|
15
|
|
Observations
|
299
|
|
Marginal R2 / Conditional R2
|
0.357 / 0.387
|
##parece que este funciona
mod_mixto11 <- glmer(cicat ~ isq_factor + infe_factor + loca_factor + nume_factor+ ede_factor + (1 | NOMBRE),
family = binomial,
data = TES)
tab_model(mod_mixto11)
|
|
cicat
|
|
Predictors
|
Odds Ratios
|
CI
|
p
|
|
(Intercept)
|
0.02
|
0.00 – 0.11
|
<0.001
|
|
isq factor [NO/leve]
|
4.01
|
2.16 – 7.44
|
<0.001
|
|
infe factor [Leve/Mod]
|
2.44
|
0.95 – 6.25
|
0.063
|
|
infe factor [No]
|
3.72
|
1.19 – 11.60
|
0.023
|
|
loca factor [Fal]
|
1.87
|
1.07 – 3.28
|
0.028
|
|
nume factor [Una]
|
4.51
|
2.40 – 8.48
|
<0.001
|
|
ede factor [Unilateral]
|
2.88
|
0.83 – 9.97
|
0.094
|
|
ede factor [Sin/local]
|
3.25
|
1.00 – 10.49
|
0.049
|
|
Random Effects
|
|
σ2
|
3.29
|
|
τ00 NOMBRE
|
0.23
|
|
ICC
|
0.06
|
|
N NOMBRE
|
15
|
|
Observations
|
299
|
|
Marginal R2 / Conditional R2
|
0.313 / 0.358
|
AIC(mod_mixto, mod_mixto2, mod_mixto3, mod_mixto4, mod_mixto5, mod_mixto6, mod_mixto7, mod_mixto8, mod_mixto9, mod_mixto10, mod_mixto11)
## df AIC
## mod_mixto 3 389
## mod_mixto2 5 379
## mod_mixto3 6 372
## mod_mixto4 7 371
## mod_mixto5 8 349
## mod_mixto6 10 349
## mod_mixto7 11 348
## mod_mixto8 12 348
## mod_mixto9 14 350
## mod_mixto10 15 350
## mod_mixto11 9 347
performance::icc(mod_mixto7);performance::icc(mod_mixto8);performance::icc(mod_mixto9); performance::icc(mod_mixto11)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.081
## Unadjusted ICC: 0.054
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.068
## Unadjusted ICC: 0.045
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.059
## Unadjusted ICC: 0.038
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.065
## Unadjusted ICC: 0.045
##mejor performance
mod_mixto12 <- 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_mixto12)
|
|
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
|
ranef(mod_mixto12)$NOMBRE
## (Intercept)
## ABUDARA 0.273
## Centro de rehabilitación, Obesidad y Diabetes. Formosa 0.493
## CER 0.512
## Clínica Centro Médico 0.469
## Hosp. Dr. J.R.Vidal -0.245
## Hospital Centro de Salud Zenón J. Santillán -0.628
## Hospital de Clínicas 0.174
## Hospital de Día de Pie Diabético. Polo Sanitario Malvinas Argentinas -0.584
## Hospital Güemes -0.092
## Hospital Perrupato 0.444
## Hospital Posadas 0.274
## Hospital san Martin -0.434
## Hospital Sommer -0.567
## HRRG 0.255
## Provincial Rosario -0.461
efectos_centros <- ranef(mod_mixto12)$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.27
## 2 Centro de rehabilitación, Obesidad y Diabetes. Formosa 0.49
## 3 CER 0.51
## 4 Clínica Centro Médico 0.47
## 5 Hosp. Dr. J.R.Vidal -0.25
## 6 Hospital Centro de Salud Zenón J. Santillán -0.63
intercepto_fijo <- fixef(mod_mixto12)["(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()

##El gráfico que te propuse (de los interceptos por centro) es una forma visual de entender cómo varía la probabilidad basal de cicatrización entre los centros, después de ajustar por las variables clínicas del modelo.
##🔹 Qué representa cada punto
#Cada punto del gráfico corresponde a un centro (tu variable NOMBRE), y el valor en el eje Y es el intercepto total para ese centro.
#El intercepto total = intercepto fijo global + efecto aleatorio del centro.
#Es decir, refleja la tendencia basal del centro a que los pacientes cicatricen, antes de considerar los predictores clínicos.
#🔹 Cómo interpretar el eje vertical (valores)
#Si el Intercepto total está más alto (más positivo), significa que ese centro tiene una mayor probabilidad basal de cicatrización comparado con el promedio de todos los centros.
#Si el Intercepto total está más bajo (más negativo), ese centro tiene una menor probabilidad basal de cicatrización (sus pacientes, en promedio, tienden a cicatrizar menos, ajustando por las covariables).
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_mixto12, 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_mixto12)[["(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)

library(DHARMa)
sim_res <- simulateResiduals(fittedModel = mod_mixto12, 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.3
## 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_mixto12)
## # Check for Multicollinearity
##
## Low Correlation
##
## Term VIF VIF 95% CI adj. VIF Tolerance Tolerance 95% CI
## isq_factor 1.08 [1.01, 1.40] 1.04 0.93 [0.72, 0.99]
## infe_factor 1.22 [1.11, 1.45] 1.11 0.82 [0.69, 0.90]
## loca_factor 1.07 [1.01, 1.42] 1.03 0.94 [0.70, 0.99]
## nume_factor 1.09 [1.02, 1.38] 1.04 0.92 [0.73, 0.98]
## ede_factor 1.24 [1.12, 1.47] 1.11 0.81 [0.68, 0.89]
## evol 1.05 [1.01, 1.50] 1.03 0.95 [0.67, 0.99]
# Bondad de ajuste (R² marginal y condicional)
r2_nakagawa(mod_mixto12)
## # R2 for Mixed Models
##
## Conditional R2: 0.427
## Marginal R2: 0.358
# Varianza de efectos aleatorios
VarCorr(mod_mixto12)
## Groups Name Std.Dev.
## NOMBRE (Intercept) 0.628