Evaluación de los datos basales (tamizaje y mini-CDR inicial)

Tenemos datos de 600 participantes para el análisis de incidencia. El reclutamiento fue en base al algoritmo del tamizaje inicial, el cual tenía como categorías:

  1. Saludable, 2) DCL, 3) Demencia
Saludable DCL Demencia
Lima 50 (33.3%) 50 (33.3%) 50 (33.3%)
Huancayo 50 (33.3%) 50 (33.3%) 50 (33.3%)
Tumbes 50 (33.3%) 50 (33.3%) 50 (33.3%)
Iquitos 50 (33.3%) 50 (33.3%) 50 (33.3%)
Total 200 (33.3%) 200 (33.3%) 200 (33.3%)

De estos 600 participantes, la clasificación en base al mini-CDR fue:

  1. Saludable, 2) DCL o Cuestionable, 3) Demencia (leve, moderada y severa)

Según el mini-CDR, se evidencia una menor distribución de participantes con demencia y más saludables, excepto por Tumbes.

Tenemos 490 personas libres de demencia.

Normal MCI Dementia
Lima 70 (46.7%) 44 (29.3%) 36 (24.0%)
Huancayo 68 (45.3%) 79 (52.7%) 3 (2.0%)
Tumbes 57 (38.0%) 42 (28.0%) 51 (34.0%)
Iquitos 78 (52.0%) 52 (34.7%) 20 (13.3%)
Total 273 (45.5%) 217 (36.2%) 110 (18.3%)

Cruce de tamizaje vs mini-CDR iniciales:

Normal MCI Dementia
Saludable 145 (72.5%) 50 (25.0%) 5 (2.5%)
DCL 85 (42.5%) 88 (44.0%) 27 (13.5%)
Demencia 43 (21.5%) 79 (39.5%) 78 (39.0%)

De las personas que el algoritmo clasifica como normal, casi 3/4 son normales y el resto DCL según el mini-CDR.

De las personas que el algoritmo clasifica como DCL, o son DCL o son normales según el mini-CDR.

De las personas que el algoritmo clasifica como demencia, o son demencia o son DCL según el mini-CDR, y el 20% son saludables.

Visualmente:

  1. El algoritmo identifica muy bien a los normales. Cuando el algoritmo dice “Saludable”, es raro que la persona tenga demencia según el mini-CDR.
  2. Existe mucha reclasificación hacia categorías menos severas. Casi la mitad de los DCL fueron considerados normales por mini-CDR.
  3. De las personas con demencia según el algoritmo, 61% no fueron clasificados como demencia por el mini-CDR.
  4. La reclasificación ocurre principalmente hacia abajo en severidad.

Evaluación de los datos actuales para la validación (tamizaje versus evaluación neuro-psicológica)

Cada participante fue evaluado por una trabajadora de campo con:

  1. AD8: Positivo (>=2) vs Negativo
  2. RUDAS: Positivo (<19 o <21) vs Negativo
  3. Pfeffer: Positivo (>=7) vs Negativo

En base a las 3 pruebas, el participante puede ser clasificado como: Normal vs DCL vs Demencia.

Cada participante fue evaluado por una neuropsicóloga con:

  1. CDR: Normal vs DCL o Cuestionable vs Demencia (leve, moderada o severa)
  2. Criterios DSM-5 para trastorno neurocognitivo mayor o leve: Normal vs TNC leve vs TNC mayor. Estos criterios se basan en los resultados del CDR, UDS, GDS, T-ADLQ y NPIQ
Descripción de la muestra
Variable Lima Huancayo Tumbes Iquitos Total
Edad 77.1 (8.9) 74.7 (8.7) 76.6 (9.9) 74.6 (8.1) 75.8 (9.0)
Sexo Masculino: 72 (48.0%)
Femenino: 78 (52.0%)
Masculino: 48 (32.0%)
Femenino: 102 (68.0%)
Masculino: 61 (40.7%)
Femenino: 89 (59.3%)
Masculino: 61 (40.7%)
Femenino: 89 (59.3%)
Masculino: 242 (40.3%)
Femenino: 358 (59.7%)
Nivel educativo Sin nivel: 23 (15.3%)
Inicial: 0 (0.0%)
Primaria: 73 (48.7%)
Secundaria: 43 (28.7%)
Superior: 11 (7.3%)
NS/NR: 0 (0.0%)
Sin nivel: 63 (42.0%)
Inicial: 0 (0.0%)
Primaria: 58 (38.7%)
Secundaria: 25 (16.7%)
Superior: 4 (2.7%)
NS/NR: 0 (0.0%)
Sin nivel: 12 (8.0%)
Inicial: 0 (0.0%)
Primaria: 101 (67.3%)
Secundaria: 25 (16.7%)
Superior: 11 (7.3%)
NS/NR: 1 (0.7%)
Sin nivel: 13 (8.7%)
Inicial: 2 (1.3%)
Primaria: 99 (66.0%)
Secundaria: 31 (20.7%)
Superior: 5 (3.3%)
NS/NR: 0 (0.0%)
Sin nivel: 111 (18.5%)
Inicial: 2 (0.3%)
Primaria: 331 (55.2%)
Secundaria: 124 (20.7%)
Superior: 31 (5.2%)
NS/NR: 1 (0.2%)
Mini-CDR Normal: 70 (46.7%)
MCI: 44 (29.3%)
Dementia: 36 (24.0%)
Normal: 68 (45.3%)
MCI: 79 (52.7%)
Dementia: 3 (2.0%)
Normal: 57 (38.0%)
MCI: 42 (28.0%)
Dementia: 51 (34.0%)
Normal: 78 (52.0%)
MCI: 52 (34.7%)
Dementia: 20 (13.3%)
Normal: 273 (45.5%)
MCI: 217 (36.2%)
Dementia: 110 (18.3%)
AD8 NEGATIVO: 64 (42.7%)
POSITIVO: 86 (57.3%)
NEGATIVO: 69 (46.0%)
POSITIVO: 81 (54.0%)
NEGATIVO: 69 (46.0%)
POSITIVO: 81 (54.0%)
NEGATIVO: 70 (46.7%)
POSITIVO: 80 (53.3%)
NEGATIVO: 272 (45.3%)
POSITIVO: 328 (54.7%)
RUDAS Inválido: 5 (3.3%)
NEGATIVO: 77 (51.3%)
POSITIVO: 68 (45.3%)
Inválido: 4 (2.7%)
NEGATIVO: 108 (72.0%)
POSITIVO: 38 (25.3%)
NEGATIVO: 83 (55.3%)
POSITIVO: 67 (44.7%)
Inválido: 15 (10.0%)
NEGATIVO: 69 (46.0%)
POSITIVO: 66 (44.0%)
Inválido: 24 (4.0%)
NEGATIVO: 337 (56.2%)
POSITIVO: 239 (39.8%)
Pfeffer NEGATIVO: 94 (62.7%)
POSITIVO: 56 (37.3%)
NEGATIVO: 79 (52.7%)
POSITIVO: 71 (47.3%)
NEGATIVO: 88 (58.7%)
POSITIVO: 62 (41.3%)
NEGATIVO: 100 (66.7%)
POSITIVO: 50 (33.3%)
NEGATIVO: 361 (60.2%)
POSITIVO: 239 (39.8%)
Clasificación algoritmo DCL: 21 (14.0%)
Demencia: 53 (35.3%)
No clasificable: 5 (3.3%)
Sano: 71 (47.3%)
DCL: 6 (4.0%)
Demencia: 58 (38.7%)
No clasificable: 4 (2.7%)
Sano: 82 (54.7%)
DCL: 15 (10.0%)
Demencia: 60 (40.0%)
Sano: 75 (50.0%)
DCL: 28 (18.7%)
Demencia: 42 (28.0%)
No clasificable: 15 (10.0%)
Sano: 65 (43.3%)
DCL: 70 (11.7%)
Demencia: 213 (35.5%)
No clasificable: 24 (4.0%)
Sano: 293 (48.8%)
CDR Normal: 91 (60.7%)
MCI: 22 (14.7%)
Dementia: 37 (24.7%)
Normal: 121 (80.7%)
MCI: 18 (12.0%)
Dementia: 11 (7.3%)
Normal: 74 (49.3%)
MCI: 29 (19.3%)
Dementia: 47 (31.3%)
Normal: 84 (56.0%)
MCI: 32 (21.3%)
Dementia: 34 (22.7%)
Normal: 370 (61.7%)
MCI: 101 (16.8%)
Dementia: 129 (21.5%)
DSM-5 Normal: 87 (58.0%)
Mild neurocognitive disorder: 27 (18.0%)
Major neurocognitive disorder: 36 (24.0%)
Normal: 120 (80.0%)
Mild neurocognitive disorder: 21 (14.0%)
Major neurocognitive disorder: 9 (6.0%)
Normal: 74 (49.3%)
Mild neurocognitive disorder: 30 (20.0%)
Major neurocognitive disorder: 46 (30.7%)
Normal: 82 (54.7%)
Mild neurocognitive disorder: 33 (22.0%)
Major neurocognitive disorder: 35 (23.3%)
Normal: 363 (60.5%)
Mild neurocognitive disorder: 111 (18.5%)
Major neurocognitive disorder: 126 (21.0%)

Ahora, evaluamos la concordancia entre CDR y criterios DSM-5:

Normal Mild neurocognitive disorder Major neurocognitive disorder
Normal 363 (98.1%) 5 (1.4%) 2 (0.5%)
MCI 0 (0.0%) 101 (100.0%) 0 (0.0%)
Dementia 0 (0.0%) 5 (3.9%) 124 (96.1%)
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

Ahora, evaluamos las pruebas individuales del tamizaje versus el gold standard: CDR

Distribución de RUDAS, AD8, Pfeffer y algoritmo según CDR
Variable Normal MCI Dementia Total
RUDAS Inválido: 10 (2.7%)
NEGATIVO: 296 (80.0%)
POSITIVO: 64 (17.3%)
Inválido: 9 (8.9%)
NEGATIVO: 33 (32.7%)
POSITIVO: 59 (58.4%)
Inválido: 5 (3.9%)
NEGATIVO: 8 (6.2%)
POSITIVO: 116 (89.9%)
Inválido: 24 (4.0%)
NEGATIVO: 337 (56.2%)
POSITIVO: 239 (39.8%)
AD8 NEGATIVO: 253 (68.4%)
POSITIVO: 117 (31.6%)
NEGATIVO: 15 (14.9%)
POSITIVO: 86 (85.1%)
NEGATIVO: 4 (3.1%)
POSITIVO: 125 (96.9%)
NEGATIVO: 272 (45.3%)
POSITIVO: 328 (54.7%)
Pfeffer NEGATIVO: 307 (83.0%)
POSITIVO: 63 (17.0%)
NEGATIVO: 43 (42.6%)
POSITIVO: 58 (57.4%)
NEGATIVO: 11 (8.5%)
POSITIVO: 118 (91.5%)
NEGATIVO: 361 (60.2%)
POSITIVO: 239 (39.8%)
Algoritmo DCL: 39 (10.5%)
Demencia: 47 (12.7%)
No clasificable: 10 (2.7%)
Sano: 274 (74.1%)
DCL: 22 (21.8%)
Demencia: 53 (52.5%)
No clasificable: 9 (8.9%)
Sano: 17 (16.8%)
DCL: 9 (7.0%)
Demencia: 113 (87.6%)
No clasificable: 5 (3.9%)
Sano: 2 (1.6%)
DCL: 70 (11.7%)
Demencia: 213 (35.5%)
No clasificable: 24 (4.0%)
Sano: 293 (48.8%)

Y las pruebas individuales del tamizaje versus los criterios DSM-5

Distribución de RUDAS, AD8, Pfeffer y algoritmo según DSM-5
Variable Normal MCI Dementia Total
RUDAS Inválido: 9 (2.5%)
NEGATIVO: 295 (81.3%)
POSITIVO: 59 (16.3%)
Inválido: 10 (9.0%)
NEGATIVO: 35 (31.5%)
POSITIVO: 66 (59.5%)
Inválido: 5 (4.0%)
NEGATIVO: 7 (5.6%)
POSITIVO: 114 (90.5%)
Inválido: 24 (4.0%)
NEGATIVO: 337 (56.2%)
POSITIVO: 239 (39.8%)
AD8 NEGATIVO: 251 (69.1%)
POSITIVO: 112 (30.9%)
NEGATIVO: 17 (15.3%)
POSITIVO: 94 (84.7%)
NEGATIVO: 4 (3.2%)
POSITIVO: 122 (96.8%)
NEGATIVO: 272 (45.3%)
POSITIVO: 328 (54.7%)
Pfeffer NEGATIVO: 303 (83.5%)
POSITIVO: 60 (16.5%)
NEGATIVO: 48 (43.2%)
POSITIVO: 63 (56.8%)
NEGATIVO: 10 (7.9%)
POSITIVO: 116 (92.1%)
NEGATIVO: 361 (60.2%)
POSITIVO: 239 (39.8%)
Algoritmo DCL: 36 (9.9%)
Demencia: 45 (12.4%)
No clasificable: 9 (2.5%)
Sano: 273 (75.2%)
DCL: 26 (23.4%)
Demencia: 57 (51.4%)
No clasificable: 10 (9.0%)
Sano: 18 (16.2%)
DCL: 8 (6.3%)
Demencia: 111 (88.1%)
No clasificable: 5 (4.0%)
Sano: 2 (1.6%)
DCL: 70 (11.7%)
Demencia: 213 (35.5%)
No clasificable: 24 (4.0%)
Sano: 293 (48.8%)

Evaluamos el tiempo de seguimiento (días o meses) entre la evaluación basal con mini-CDR y la evaluación de seguimiento con CDR:

Tiempo hasta el seguimiento según lugar, en meses
Lugar N Entre el screening y el seguimiento Entre el basal y el seguimiento Entre el Mini-CDR y el seguimiento
Lima 150 10.4 (3.5); 9.4 (7.9–11.2) 9.8 (3.3); 8.4 (7.4–11.1) 7.2 (1.4); 7.0 (6.3–8.1)
Huancayo 150 13.1 (2.9); 12.2 (11.0–15.3) 12.7 (2.7); 12.2 (10.8–14.2) 9.4 (2.0); 9.3 (7.7–11.4)
Tumbes 150 12.5 (3.0); 11.6 (10.3–14.0) 12.5 (3.0); 11.4 (10.3–13.9) 9.5 (1.5); 9.3 (8.5–10.1)
Iquitos 150 15.4 (2.7); 14.8 (13.5–17.5) 14.9 (2.4); 14.1 (12.9–17.0) 9.9 (2.0); 9.5 (8.4–11.5)

Cruce de mini-CDR y CDR

Normal MCI Dementia
Normal 230 (84.2%) 30 (11.0%) 13 (4.8%)
MCI 123 (56.7%) 55 (25.3%) 39 (18.0%)
Dementia 17 (15.5%) 16 (14.5%) 77 (70.0%)
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

Para la categorización original:

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

Y ahora hacemos lo mismo pero en población libre de demencia según mini-CDR (N=490)

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

Tabla para describir los puntajes y categorizaciones del AD8, RUDAS, Pfeffer y algoritmo, inicial vs seguimiento.

El tamizaje inicial incluyó: AD8, RUDAS, Pfeffer (subgrupo para aquellos con AD8+ y RUDAS+) El tamizaje del seguimiento incluyó: AD8, RUDAS, Pfeffer (a todos)

Descripción de los puntajes y categorizaciones, inicial vs final
Variable Lima Huancayo Tumbes Iquitos Total
N 150 150 150 150 600
AD8, puntaje (inicial) 3.0 (2.6); n=150 2.9 (2.1); n=150 2.7 (2.4); n=150 2.9 (2.3); n=150 2.9 (2.4); n=600
AD8, puntaje (final) 3.0 (2.7); n=150 2.3 (2.2); n=150 2.8 (2.7); n=150 2.3 (2.5); n=150 2.6 (2.6); n=600
RUDAS, puntaje (inicial) 18.4 (5.8); n=150 19.3 (5.0); n=150 18.2 (6.7); n=150 18.0 (5.4); n=150 18.5 (5.7); n=600
RUDAS, puntaje (final) 18.8 (7.1); n=150 21.4 (5.8); n=150 18.5 (7.5); n=150 17.6 (6.6); n=150 19.1 (6.9); n=600
Pfeffer, puntaje (inicial) 12.4 (10.7); n=100 9.9 (7.9); n=97 13.2 (10.6); n=100 10.8 (10.1); n=100 11.6 (9.9); n=397
Pfeffer, puntaje (final), toda la muestra 9.1 (11.1); n=150 8.0 (8.2); n=150 10.4 (12.8); n=150 6.7 (9.8); n=150 8.5 (10.7); n=600
Pfeffer, puntaje (final), solo con Pfeffer inicial 13.2 (11.5); n=100 9.9 (8.5); n=97 15.4 (12.9); n=100 9.4 (10.9); n=100 12.0 (11.3); n=397
AD8, categoría (inicial) NEGATIVO: 50 (33.3%)
POSITIVO: 100 (66.7%)
NEGATIVO: 50 (33.3%)
POSITIVO: 100 (66.7%)
NEGATIVO: 50 (33.3%)
POSITIVO: 100 (66.7%)
NEGATIVO: 50 (33.3%)
POSITIVO: 100 (66.7%)
NEGATIVO: 200 (33.3%)
POSITIVO: 400 (66.7%)
AD8, categoría (final) NEGATIVO: 64 (42.7%)
POSITIVO: 86 (57.3%)
NEGATIVO: 69 (46.0%)
POSITIVO: 81 (54.0%)
NEGATIVO: 69 (46.0%)
POSITIVO: 81 (54.0%)
NEGATIVO: 70 (46.7%)
POSITIVO: 80 (53.3%)
NEGATIVO: 272 (45.3%)
POSITIVO: 328 (54.7%)
RUDAS, categoría (inicial) NEGATIVO: 50 (33.3%)
POSITIVO: 100 (66.7%)
NEGATIVO: 50 (33.3%)
POSITIVO: 100 (66.7%)
NEGATIVO: 50 (33.3%)
POSITIVO: 100 (66.7%)
NEGATIVO: 50 (33.3%)
POSITIVO: 100 (66.7%)
NEGATIVO: 200 (33.3%)
POSITIVO: 400 (66.7%)
RUDAS, categoría (final) Inválido: 5 (3.3%)
NEGATIVO: 77 (51.3%)
POSITIVO: 68 (45.3%)
Inválido: 4 (2.7%)
NEGATIVO: 108 (72.0%)
POSITIVO: 38 (25.3%)
NEGATIVO: 83 (55.3%)
POSITIVO: 67 (44.7%)
Inválido: 15 (10.0%)
NEGATIVO: 69 (46.0%)
POSITIVO: 66 (44.0%)
Inválido: 24 (4.0%)
NEGATIVO: 337 (56.2%)
POSITIVO: 239 (39.8%)
Pfeffer, categoría (inicial) NEGATIVO: 50 (33.3%)
POSITIVO: 50 (33.3%)
NA: 50 (33.3%)
NEGATIVO: 50 (33.3%)
POSITIVO: 47 (31.3%)
NA: 53 (35.3%)
NEGATIVO: 50 (33.3%)
POSITIVO: 50 (33.3%)
NA: 50 (33.3%)
NEGATIVO: 50 (33.3%)
POSITIVO: 50 (33.3%)
NA: 50 (33.3%)
NEGATIVO: 200 (33.3%)
POSITIVO: 197 (32.8%)
NA: 203 (33.8%)
Pfeffer, categoría (final), toda la muestra NEGATIVO: 94 (62.7%)
POSITIVO: 56 (37.3%)
NEGATIVO: 79 (52.7%)
POSITIVO: 71 (47.3%)
NEGATIVO: 88 (58.7%)
POSITIVO: 62 (41.3%)
NEGATIVO: 100 (66.7%)
POSITIVO: 50 (33.3%)
NEGATIVO: 361 (60.2%)
POSITIVO: 239 (39.8%)
Pfeffer, categoría (final), solo con Pfeffer inicial NEGATIVO: 45 (45.0%)
POSITIVO: 55 (55.0%)
NEGATIVO: 40 (41.2%)
POSITIVO: 57 (58.8%)
NEGATIVO: 38 (38.0%)
POSITIVO: 62 (62.0%)
NEGATIVO: 53 (53.0%)
POSITIVO: 47 (47.0%)
NEGATIVO: 176 (44.3%)
POSITIVO: 221 (55.7%)
Algoritmo (inicial) Saludable: 50 (33.3%)
DCL: 50 (33.3%)
Demencia: 50 (33.3%)
Saludable: 50 (33.3%)
DCL: 50 (33.3%)
Demencia: 50 (33.3%)
Saludable: 50 (33.3%)
DCL: 50 (33.3%)
Demencia: 50 (33.3%)
Saludable: 50 (33.3%)
DCL: 50 (33.3%)
Demencia: 50 (33.3%)
Saludable: 200 (33.3%)
DCL: 200 (33.3%)
Demencia: 200 (33.3%)
Algoritmo (final) DCL: 21 (14.0%)
Demencia: 53 (35.3%)
No clasificable: 5 (3.3%)
Sano: 71 (47.3%)
DCL: 6 (4.0%)
Demencia: 58 (38.7%)
No clasificable: 4 (2.7%)
Sano: 82 (54.7%)
DCL: 15 (10.0%)
Demencia: 60 (40.0%)
Sano: 75 (50.0%)
DCL: 28 (18.7%)
Demencia: 42 (28.0%)
No clasificable: 15 (10.0%)
Sano: 65 (43.3%)
DCL: 70 (11.7%)
Demencia: 213 (35.5%)
No clasificable: 24 (4.0%)
Sano: 293 (48.8%)

Hay 3 participantes de Huancayo sin evidencia de Pfeffer en el tamizaje inicial (missings en todas las 11 preguntas). Fueron clasificadas por el algoritmo inicial como “Demencia”. Al seguimiento, el algoritmo actual las clasifica como “Demencia”.

Ahora, hacemos cruce de tamizaje inicial vs tamizaje final.

library(dplyr)
library(ggplot2)
library(ggalluvial)

sankey_pre_post <- function(data, var_ini, var_fin, niveles, colores,
                            lab_ini = "Inicial", lab_fin = "Final") {

  d <- data %>%
    transmute(ini = as.character(.data[[var_ini]]),
              fin = as.character(.data[[var_fin]]))

  # Detiene el código si hay NA o etiquetas que no están en `niveles`
  fuera <- setdiff(unique(c(d$ini, d$fin)), niveles)
  if (length(fuera) > 0)
    stop("Categorías fuera de `niveles`: ", paste(fuera, collapse = ", "))

  tab <- d %>%
    count(ini, fin, name = "Freq") %>%
    mutate(ini = factor(ini, levels = niveles),
           fin = factor(fin, levels = niveles))

  # Total por categoría inicial (denominador del %)
  tot_ini <- tapply(tab$Freq, tab$ini, sum)

  ggplot(tab, aes(axis1 = ini, axis2 = fin, y = Freq)) +
    geom_alluvium(aes(fill = ini), width = 1/4, alpha = 0.8, knot.pos = 0.4) +
    geom_stratum(width = 1/4, fill = "grey90", color = "black") +
    geom_text(stat = "stratum",
              aes(label = paste0(after_stat(stratum),
                                 "\n(n = ", after_stat(count), ")")),
              size = 4.5) +
    geom_text(stat = "flow",
              aes(label = after_stat(ifelse(
                flow == "from",
                paste0(count, " (",
                       sprintf("%.0f", count / tot_ini[as.character(stratum)] * 100),
                       "%)"),
                NA))),
              nudge_x = 0.2, hjust = 0, size = 4, na.rm = TRUE) +
    scale_fill_manual(values = colores) +
    scale_x_discrete(limits = c(lab_ini, lab_fin), expand = c(.15, .15)) +
    labs(x = NULL, y = "Número de participantes") +
    theme_minimal(base_size = 14) +
    theme(legend.position = "none")
}

# Algoritmo: "Saludable" (inicial) y "Sano" (final) son la misma categoría → unificar
full_data <- full_data %>%
  mutate(alg_ini = recode(as.character(result_final_2), "Saludable" = "Sano"),
         alg_fin = as.character(f12_clasificacion_algoritmo))

col_bin <- c(NEGATIVO = "#6BAED6", POSITIVO = "#DE2D26")
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.