1.2. Anthroprometric analysis
# Layout to split the screen
layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(1,8))
# Draw the boxplot and the histogram
par(mar=c(0, 3.1, 1.1, 2.1))
boxplot(PSFI_df_malnutrition$ht , horizontal=TRUE , ylim=c(0,200), xaxt="n" , col=rgb(0.8,0.8,0,0.5) , frame=F)
par(mar=c(4, 3.1, 1.1, 2.1))
hist(PSFI_df_malnutrition$ht
, breaks=40 , col=rgb(1,0.8,0.8,1) , border=F , main="" , xlab="Height (cm)", xlim=c(0,200))

layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(1,8))
par(mar=c(0, 3.1, 1.1, 2.1))
boxplot(PSFI_df_malnutrition$wt , horizontal=TRUE , ylim=c(0,200), xaxt="n" , col=rgb(0.8,0.8,0,0.5) , frame=F)
par(mar=c(4, 3.1, 1.1, 2.1))
hist(PSFI_df_malnutrition$wt
, breaks=40 , col=rgb(1,0.8,0.8,1) , border=F , main="" , xlab="Weight (kg)", xlim=c(0,100))

layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(1,8))
par(mar=c(0, 3.1, 1.1, 2.1))
boxplot(PSFI_df_malnutrition$muac , horizontal=TRUE , ylim=c(0,200), xaxt="n" , col=rgb(0.8,0.8,0,0.5) , frame=F)
par(mar=c(4, 3.1, 1.1, 2.1))
hist(PSFI_df_malnutrition$muac
, breaks=20 , col=rgb(1,0.8,0.8,1) , border=F , main="" , xlab="Mid-upper arm circumference (cm)", xlim=c(0,30))
abline(v = 11.5, col = "red", lwd = 2, lty = 2) # severe
abline(v = 12.5, col = "blue", lwd = 2, lty = 2) # moderate

PSFI_df_malnutrition <- PSFI_df_malnutrition %>%
mutate(age_years = age_days_exact / 365.25)
summary(PSFI_df_malnutrition$age_years)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.08768 0.79176 1.65535 3.07854 4.00176 14.92786
layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(1,8))
par(mar=c(0, 3.1, 1.1, 2.1))
boxplot(PSFI_df_malnutrition$age_years , horizontal=TRUE , ylim=c(0,300), xaxt="n" , col=rgb(0.8,0.8,0,0.5) , frame=F)
par(mar=c(4, 3.1, 1.1, 2.1))
hist(PSFI_df_malnutrition$age_years
, breaks=40 , col=rgb(1,0.8,0.8,1) , border=F , main="" , xlab="Age (years)", xlim=c(0,15))

1.3. Z-scorer
PSFI_df_malnutrition <- PSFI_df_malnutrition %>%
mutate(sex_who = if_else(sex == 1, 1, 2))
summary(PSFI_df_malnutrition$sex_who)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.000 1.000 1.000 1.427 2.000 2.000
PSFI_df_malnutrition <- PSFI_df_malnutrition %>%
mutate(
wflz = addWGSR(
data = .,
sex = "sex_who",
firstPart = "wt",
secondPart = "ht",
index = "wfl"
)$wflz,
wfhz = addWGSR(
data = .,
sex = "sex_who",
firstPart = "wt",
secondPart = "ht",
index = "wfh"
)$wfhz,
baz = addWGSR(
data = .,
sex = "sex_who",
firstPart = "wt",
secondPart = "ht",
thirdPart = "age_days_exact",
index = "bfa"
)$bfaz,
)
========================================================================================
========================================================================================
========================================================================================
PSFI_df_malnutrition <- PSFI_df_malnutrition %>%
mutate(
wflz = addWGSR(
data = .,
sex = "sex_who",
firstPart = "wt",
secondPart = "ht",
index = "wfl"
)$wflz,
wfhz = addWGSR(
data = .,
sex = "sex_who",
firstPart = "wt",
secondPart = "ht",
index = "wfh"
)$wfhz,
baz = addWGSR(
data = .,
sex = "sex_who",
firstPart = "wt",
secondPart = "ht",
thirdPart = "age_days_exact",
index = "bfa"
)$bfaz,
)
========================================================================================
========================================================================================
========================================================================================
PSFI_df_malnutrition <- PSFI_df_malnutrition %>%
mutate(
muacz = case_when(
muac >= 12.5 ~ 0,
muac >= 11.5 & muac < 12.5 ~ -2.5,
muac < 11.5 ~ -4,
TRUE ~ NA_real_
)
)
PSFI_df_malnutrition <- PSFI_df_malnutrition %>%
mutate(
zscore_unified = case_when(
age_group == 0 & ht >= 45 & ht < 65 ~ wflz,
age_group == 0 & ht >= 65 & ht < 120 ~ wfhz,
age_group == 0 & (ht < 45 | ht >= 120 | is.na(ht)) ~ muacz,
age_group == 1 ~ baz,
TRUE ~ NA_real_
)
)
PSFI_df_malnutrition <- PSFI_df_malnutrition %>%
mutate(
malnutrition = case_when(
is.na(zscore_unified) ~ NA_integer_,
zscore_unified < -3 ~ 2L,
zscore_unified >= -3 & zscore_unified < -2 ~ 1L,
TRUE ~ 0L
)
)
PSFI_df_malnutrition <- PSFI_df_malnutrition %>%
mutate(
malnutrition_source = case_when(
age_group == 0 & ht >= 45 & ht < 65 ~ "WFL",
age_group == 0 & ht >= 65 & ht < 120 ~ "WFH",
age_group == 0 & (ht < 45 | ht >= 120 | is.na(ht)) ~ "MUAC",
age_group == 1 ~ "BFA",
TRUE ~ NA_character_
)
)
1.4. Data check
PSFI_df_malnutrition%>%
group_by(malnutrition) %>%
summarize(
malnutrition_missing = sum(is.na(malnutrition)),
mort_inhosp_missing = sum(is.na(mort_inhosp)), #103 mort_inhosp_miissing = controls
)
PSFI_df_malnutrition %>%
drop_na(mort_inhosp) %>%
group_by(malnutrition_source) %>%
summarize(
count_malnut = n()
)
# NA due to child with height of 20 cm (under WHO curve for wfh/wfl) and 38 days old (too young for MUAC)
PSFI_df_malnutrition %>%
drop_na(mort_inhosp) %>%
group_by(malnutrition) %>%
summarize(
count_malnut = n()
)
PSFI_df_malnutrition %>%
drop_na(malnutrition, mort_inhosp) %>%
ggplot(aes(x = factor(malnutrition))) +
geom_bar() +
labs(
x = "Malnutrition",
y = "N"
)

PSFI_df_malnutrition%>%
drop_na(mort_inhosp) %>% #drops controls
count(malnutrition, mort_inhosp) %>%
group_by(malnutrition) %>%
mutate(prop = n / sum(n))
PSFI_df_malnutrition %>%
drop_na(mort_inhosp, malnutrition) %>% #only cases & minus the one previously mentioned NA
ggplot +
(aes(x = factor(malnutrition), fill = factor(mort_inhosp))) +
geom_bar(stat = "count", position = "fill") +
labs(
x = "Malnutrition",
y = "Proportion",
fill = "Mortality"
)

PSFI_df_malnutrition %>%
count(malnutrition, case_control) %>%
group_by(malnutrition) %>%
mutate(prop = n / sum(n))
PSFI_df_malnutrition %>%
drop_na(malnutrition) %>%
ggplot +
(aes(x = factor(malnutrition), fill = factor(case_control))) +
geom_bar(stat = "count", position = "fill") +
labs(
x = "Malnutrition",
y = "Proportion",
fill = "Case/Control"
)
