library(tidyverse)
library(readxl)
library(broom)
library(gt)
PSFI_df_malnutrition <- read_xlsx("PSFI_final_malnutrition3.xlsx")
# CREATE NEW AGE GROUP CATEGORY
PSFI_df_malnutrition <- PSFI_df_malnutrition %>%
mutate(
age_group1 = case_when(
age_months < 12 ~ 0L,
age_months >= 12 & age_months < 24 ~ 1L,
age_years >=2 & age_years <5 ~ 2L,
TRUE ~ NA_integer_
)
)
PSFI_df_malnutrition <- PSFI_df_malnutrition %>%
mutate(
popc_change = popc_dc - popc_admit,
popc_dc1 = case_when(
popc_dc >= 3 & popc_change >= 1 ~ 1L,
!is.na(popc_dc) & !is.na(popc_admit) ~ 0L,
TRUE ~ NA_integer_
),
popc_dc1 = factor(
popc_dc1,
levels = c(0, 1),
labels = c(
"No new moderate disability",
"New moderate disability"
)
)
)
analysis_df <- PSFI_df_malnutrition %>%
filter(
case_control == 1,
age_years < 5
)
# SET NUTRITIONAL STATUS REFERENCE CATEGORY
analysis_df <- analysis_df %>%
mutate(
malnutrition_who5 = relevel(
factor(malnutrition_who5),
ref = "No malnutrition"
)
)
analysis_df <- analysis_df %>%
mutate(
picu_admit1 = factor(
picu_admit,
levels = c("No","Yes"),
labels = c("No PICU admission","PICU admission")
)
)
sapply(
analysis_df[, c("malnutrition_who5", "age_group1", "sex1", "hiv_pos1", "comorbidity", "picu_admit1")],
class
)
malnutrition_who5 age_group1 sex1 hiv_pos1 comorbidity picu_admit1
"factor" "integer" "character" "character" "numeric" "factor"
analysis_df <- analysis_df %>%
mutate(
comorbidity = factor(
comorbidity,
levels = c(0, 1),
labels = c("No", "Yes")
)
)
mort_crude <- glm(
mort_inhosp ~ malnutrition_who5,
family = binomial,
data = analysis_df
)
mort_adj <- glm(
mort_inhosp ~ malnutrition_who5 +
age_group1 + sex1 + hiv_pos1 + comorbidity,
family = binomial,
data = analysis_df
)
popc_crude <- glm(
popc_dc1 ~ malnutrition_who5,
family = binomial,
data = analysis_df
)
popc_adj <- glm(
popc_dc1 ~ malnutrition_who5 +
age_group1 + sex1 + hiv_pos1 +
comorbidity,
family = binomial,
data = analysis_df
)
picu_crude <- glm(
picu_admit1 ~ malnutrition_who5,
family = binomial,
data = analysis_df
)
picu_adj <- glm(
picu_admit1 ~ malnutrition_who5 +
age_group1 + sex1 + hiv_pos1 +
comorbidity,
family = binomial,
data = analysis_df
)
analysis_df_survivors <- analysis_df %>%
filter(mort_inhosp == 0, case_control == 1, age_years <5)
los_crude <- lm(
los ~ malnutrition_who5,
data = analysis_df_survivors
)
los_adj <- lm(
los ~ malnutrition_who5 +
age_group1 + sex1 + hiv_pos1 + comorbidity,
data = analysis_df_survivors
)
library(broom)
library(dplyr)
library(tidyr)
make_table <- function(crude, adjusted){
c1 <- broom::tidy(
crude,
exponentiate = TRUE,
conf.int = TRUE
) %>%
filter(grepl("^malnutrition_who5", term)) %>%
transmute(
Category = sub("^malnutrition_who5", "", term),
OR = sprintf("%.2f (%.2f–%.2f)",
estimate,
conf.low,
conf.high),
P = ifelse(
p.value < 0.001,
"<0.001",
sprintf("%.3f", p.value)
)
)
c2 <- broom::tidy(
adjusted,
exponentiate = TRUE,
conf.int = TRUE
) %>%
filter(grepl("^malnutrition_who5", term)) %>%
transmute(
Category = sub("^malnutrition_who5", "", term),
aOR = sprintf("%.2f (%.2f–%.2f)",
estimate,
conf.low,
conf.high),
aP = ifelse(
p.value < 0.001,
"<0.001",
sprintf("%.3f", p.value)
)
)
full_join(c1, c2, by = "Category")
}
make_table_lm <- function(crude, adjusted){
c1 <- broom::tidy(crude, conf.int = TRUE) %>%
filter(grepl("^malnutrition_who5", term)) %>%
transmute(
Category = sub("^malnutrition_who5", "", term),
LOS_Beta = sprintf("%.2f (%.2f–%.2f)",
estimate,
conf.low,
conf.high),
LOS_P = ifelse(
p.value < 0.001,
"<0.001",
sprintf("%.3f", p.value)
)
)
c2 <- broom::tidy(adjusted, conf.int = TRUE) %>%
filter(grepl("^malnutrition_who5", term)) %>%
transmute(
Category = sub("^malnutrition_who5", "", term),
LOS_aBeta = sprintf("%.2f (%.2f–%.2f)",
estimate,
conf.low,
conf.high),
LOS_aP = ifelse(
p.value < 0.001,
"<0.001",
sprintf("%.3f", p.value)
)
)
full_join(c1, c2, by = "Category")
}
mort_tbl <- make_table(mort_crude, mort_adj)
popc_tbl <- make_table(popc_crude, popc_adj)
picu_tbl <- make_table(picu_crude, picu_adj)
los_tbl <- make_table_lm(los_crude, los_adj)
names(mort_tbl) <- c(
"Category",
"Mortality_OR","Mortality_P",
"Mortality_aOR","Mortality_aP"
)
names(popc_tbl) <- c(
"Category",
"POPC_OR","POPC_P",
"POPC_aOR","POPC_aP"
)
names(picu_tbl) <- c(
"Category",
"PICU_OR","PICU_P",
"PICU_aOR","PICU_aP"
)
names(los_tbl) <- c(
"Category",
"LOS_Beta","LOS_P",
"LOS_aBeta","LOS_aP"
)
table3 <-
mort_tbl %>%
left_join(popc_tbl, by = "Category") %>%
left_join(picu_tbl, by = "Category") %>%
left_join(los_tbl, by = "Category")
table3 <- bind_rows(
tibble(
Category = "No malnutrition",
Mortality_OR = "Reference",
Mortality_aOR = "Reference",
POPC_OR = "Reference",
POPC_aOR = "Reference",
PICU_OR = "Reference",
PICU_aOR = "Reference",
LOS_Beta = "Reference",
LOS_aBeta = "Reference"
),
table3
)
library(gt)
table3 %>%
gt() %>%
tab_header(
title = md("**Association between nutritional status and clinical outcomes**")
) %>%
tab_spanner(
label = "In-hospital mortality",
columns = c(Mortality_OR, Mortality_P,
Mortality_aOR, Mortality_aP)
) %>%
tab_spanner(
label = "New moderate disability",
columns = c(POPC_OR, POPC_P,
POPC_aOR, POPC_aP)
) %>%
tab_spanner(
label = "PICU admission",
columns = c(PICU_OR, PICU_P,
PICU_aOR, PICU_aP)
) %>%
tab_spanner(
label = "Length of stay (survivors only)",
columns = c(LOS_Beta, LOS_P,
LOS_aBeta, LOS_aP)
)%>%
cols_label(
Category = "Nutritional status",
Mortality_OR = "OR (95% CI)",
Mortality_P = "P",
Mortality_aOR = "aOR (95% CI)",
Mortality_aP = "P",
POPC_OR = "OR (95% CI)",
POPC_P = "P",
POPC_aOR = "aOR (95% CI)",
POPC_aP = "P",
PICU_OR = "OR (95% CI)",
PICU_P = "P",
PICU_aOR = "aOR (95% CI)",
PICU_aP = "P",
LOS_Beta = "β (95% CI)",
LOS_P = "P",
LOS_aBeta = "Adjusted β (95% CI)",
LOS_aP = "P"
) %>%
tab_source_note(
md("*Adjusted for age group, sex, HIV status, and comorbidity status.*")
)
| Association between nutritional status and clinical outcomes | ||||||||||||||||
| Nutritional status |
In-hospital mortality
|
New moderate disability
|
PICU admission
|
Length of stay (survivors only)
|
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| OR (95% CI) | P | aOR (95% CI) | P | OR (95% CI) | P | aOR (95% CI) | P | OR (95% CI) | P | aOR (95% CI) | P | β (95% CI) | P | Adjusted β (95% CI) | P | |
| No malnutrition | Reference | NA | Reference | NA | Reference | NA | Reference | NA | Reference | NA | Reference | NA | Reference | NA | Reference | NA |
| Moderate malnutrition | 2.12 (1.25–3.54) | 0.005 | 2.13 (1.24–3.63) | 0.006 | 2.75 (1.72–4.38) | <0.001 | 2.79 (1.73–4.50) | <0.001 | 1.12 (0.67–1.85) | 0.650 | 1.16 (0.68–1.93) | 0.570 | 1.64 (-1.42–4.70) | 0.292 | 1.77 (-1.31–4.85) | 0.260 |
| Obesity | 0.88 (0.25–2.38) | 0.823 | 0.85 (0.24–2.33) | 0.776 | 1.13 (0.44–2.63) | 0.782 | 1.12 (0.43–2.64) | 0.797 | 1.24 (0.50–2.79) | 0.625 | 1.19 (0.48–2.72) | 0.685 | -0.32 (-5.21–4.57) | 0.898 | -0.42 (-5.32–4.48) | 0.867 |
| Overweight | 0.47 (0.11–1.37) | 0.226 | 0.42 (0.10–1.23) | 0.164 | 0.31 (0.07–0.88) | 0.054 | 0.28 (0.07–0.80) | 0.038 | 0.61 (0.22–1.41) | 0.282 | 0.56 (0.20–1.30) | 0.210 | -5.02 (-9.21–-0.83) | 0.019 | -5.25 (-9.46–-1.04) | 0.015 |
| Severe malnutrition | 3.29 (1.97–5.48) | <0.001 | 3.40 (2.00–5.74) | <0.001 | 2.92 (1.80–4.73) | <0.001 | 2.97 (1.82–4.84) | <0.001 | 0.97 (0.55–1.65) | 0.922 | 0.97 (0.55–1.66) | 0.923 | 1.46 (-1.93–4.84) | 0.399 | 1.49 (-1.90–4.88) | 0.389 |
| Adjusted for age group, sex, HIV status, and comorbidity status. | ||||||||||||||||