This document contains the dataset needed and calculation for the summary benefit(deaths and Disability adjusted life years (DALYs)).
Library and settings
library(tidyverse)
library(readxl)
library(nutriR)
library(ggplot2)
#library(tabulizer)
library(rnaturalearth)
library(sf)
library(DT)
library(lhs)
library(stringr)
library(plotly)
library(countrycode)
Import the data for all the preterm birth related parameter
preterm1= read.csv("data/IHME-GBD_2019_DATA-26ced726-1/IHME-GBD_2019_DATA-26ced726-1.csv") %>%
janitor::clean_names()
preterm2= read.csv("data/IHME-GBD_2019_DATA-fe699dfb-1/IHME-GBD_2019_DATA-fe699dfb-1.csv") %>%
janitor::clean_names() %>%
dplyr::select(location_name, val, upper, lower) %>%
rename(val_ma_yld = val,
upper_ma_yld=upper,
lower_ma_yld=lower)
preterm = preterm1 %>%
dplyr:: select(measure_name, location_name, val, upper, lower) %>%
group_by(location_name) %>%
pivot_wider(
names_from = measure_name,
values_from = c("val", "upper", "lower"),
names_sep = "_"
) %>%
janitor::clean_names() %>%
left_join(preterm2)
Calculation the Infant deaths per preterm birth (\(m_i^{inf\_ptb}\)) , Infant YLLs per preterm bith case (\(n_i^{inf\_ptb}\)), Infant YLDs per preterm birth (\(o_i^{inf\_ptb}\)), maternal YLDs per preterm birth (\(o_i^{adu\_ptb}\)). Take the mean of the preterm birth incidence as denominator and the mean of the needed parameter as numerator.
The discounted yll calculation First calculated the yll per person with yll divided by death. Take the d= 0.03, yll as n. The formula is \(pv = (1-(1+d)^{-n})/d\). Then the scale is calculated and apply to the accumulated ylls to calculated the discount ylls.
calculate discoutn daly
pretermcal=
preterm %>%
mutate(death= val_deaths/val_incidence,
yll=val_yl_ls_years_of_life_lost/val_incidence,
yll_person=yll/death,
discount_yll_person = (1-(1+0.03)^(-yll_person))/0.03,
discount_yll= discount_yll_person/yll_person*yll,
yld=val_yl_ds_years_lived_with_disability/val_incidence,
ma_yld_pre=val_ma_yld/val_incidence,
iso3=countrycode(location_name, "country.name", "iso3c")) %>%
rename(country =location_name) %>%
dplyr::select(iso3, country, death, yll, yll_person, discount_yll_person, discount_yll, yld, ma_yld_pre )
# calculate the discounted yll
datatable(
data = pretermcal,
caption = "Table 1: The preterm birth dataset",
filter = "top",
style = "bootstrap4"
)
Import the data for all the preeclampsia related parameter
preecla=read_csv("data/IHME-GBD_2019_DATA-f5ed2da1-1/IHME-GBD_2019_DATA-f5ed2da1-1.csv") %>%
janitor::clean_names() %>%
dplyr::select(measure_name, location_name, val, upper, lower) %>%
pivot_wider(
names_from = measure_name,
values_from = c("val", "upper", "lower"),
names_sep = "_"
) %>%
janitor::clean_names()
Calculation the Maternal deaths per preeclampsia case (\(m_i^{adu\_pre}\)) , Maternal YLLs per preeclampsia case (\(n_i^{adu\_pre}\)), Maternal YLDs per preeclampsia case (\(o_i^{adu\_pre}\)). Take the mean of the preeclampsia incidence as denominator and the mean of the needed parameter as numerator.
preeccalcul=
preecla %>%
mutate(
ma_death=val_deaths/val_incidence,
ma_yll=val_yl_ls_years_of_life_lost/val_incidence,
ma_yll_person=ma_yll/ma_death,
ma_discountyll_person = (1-(1+0.03)^(-ma_yll_person))/0.03,
discount_ma_yll= ma_discountyll_person/ma_yll_person*ma_yll,
ma_yld=val_yl_ds_years_lived_with_disability/val_incidence,
iso3=countrycode(location_name, "country.name", "iso3c")) %>%
rename(country =location_name) %>%
dplyr::select(iso3, country, ma_death, ma_yll,ma_yll_person, ma_discountyll_person, discount_ma_yll, ma_yld)
datatable(
data = preeccalcul,
caption = "Table 2: The preelampsia birth dataset",
filter = "top",
style = "bootstrap4"
)
\[ deaths_i^{infant}=k_i*m_i^{inf_ptb}\]
\[deaths_i^{adult}=l_i*m_i^{adu_pre}\]
\[YLL_i^{adult}=l_i*n_i^{adu\_pre}\]
\[YLD_i^{adult}=k_i*o_i^{adu\_ptb}+l_i*n_i^{adu\_pre}\]
\[DALY_i^{infant}=YLL_i^{infant}+YLD_i^{infant}\]
\[DALY_i^{adult}=YLL_i^{adult}+YLD_i^{adult}\]
load(file="dashboard/immediate.RData")
preecsum = imm_prec %>%
dplyr::select(iso3, country, region, health_prec) %>%
left_join(preeccalcul) %>%
mutate(adu_death= health_prec*ma_death,
adu_yll=health_prec*ma_yll,
adu_dis_yll = health_prec*discount_ma_yll,
adu_yld=health_prec*ma_yld)
pretsum=imm_pret %>%
dplyr::select(iso3, country, region, health_pret) %>%
left_join(pretermcal) %>%
mutate(inf_death=death*health_pret,
inf_yll=yll*health_pret,
inf_dis_yll = discount_yll*health_pret,
inf_yld=yld*health_pret)
sumhealth= merge(preecsum, pretsum) %>%
mutate(adu_yld=adu_yld+ health_pret*ma_yld_pre,
inf_daly = inf_yll+ inf_yld,
adu_daly =adu_yll+adu_yld,
dis_inf_daly= inf_dis_yll + inf_yld,
dis_adu_daly = adu_dis_yll + adu_yld,
total_daly = inf_daly+ adu_daly,
total_dis_daly = dis_inf_daly + dis_adu_daly
) %>%
dplyr::select(iso3, country, region, adu_death,inf_death, adu_yll, inf_yll, adu_yld,inf_yld, adu_daly, inf_daly, dis_adu_daly,dis_inf_daly, total_daly, total_dis_daly )
datatable(
data = sumhealth,
caption = "Table 3: The Summary benefit table",
filter = "top",
style = "bootstrap4"
)
world= read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv')
summaryplot=world %>%
left_join(sumhealth, by = c("CODE" = "iso3"))
plot_ly(summaryplot, type="choropleth", locations = summaryplot$CODE, z=summaryplot$inf_daly, text=summaryplot$COUNTRY, colorscale="Red") %>%
colorbar(title=list(text="DALYs",font = list(size = 12)),
tickfont = list(size = 8),
len=0.5, x=1, y=0.85, thickness=10) %>%
layout(title =list(text= "Worldwide Infants DALYs", y=0.9),
annotations = list(
list(
text = "IHME",
x = 1.1,
y= 0.1,
xref = "paper",
yref = "paper",
showarrow = FALSE,
font = list(size = 10)
)))
world = ne_countries(scale = “medium”, returnclass = “sf”)
summaryplot = world %>% left_join( sumhealth %>% mutate(iso3 = case_when( iso3 == “SSD” ~ “SDS”, iso3 == “PSE” ~ “PSX”, TRUE ~ iso3 )), by = c(“adm0_a3” = “iso3”) )
ggplot(summaryplot) + geom_sf(aes(fill = inf_daly)) + scale_fill_gradient(low = “white”, high = “red”, na.value = “grey50”) + theme_minimal() + labs(fill = “DALY”, title = “Worldwide infants DALYs”, caption = “IHME”)
plot_ly(summaryplot, type="choropleth", locations = summaryplot$CODE, z=summaryplot$adu_daly, text=summaryplot$COUNTRY, colorscale="Red") %>%
colorbar(title=list(text="DALYs",font = list(size = 12)),
tickfont = list(size = 8),
len=0.5, x=1, y=0.85, thickness=10) %>%
layout(title =list(text= "Worldwide Maternal DALYs", y=0.9),
annotations = list(
list(
text = "IHME",
x = 1.1,
y= 0.1,
xref = "paper",
yref = "paper",
showarrow = FALSE,
font = list(size = 10)
)))
ggplot(summaryplot) + geom_sf(aes(fill = adu_daly)) + scale_fill_gradient(low = “white”, high = “red”, na.value = “grey50”) + theme_minimal() + labs(fill = “DALY”, title = “Worldwide maternal DALYs”, caption = “IHME”)
maternal_sum=
sumhealth %>%
dplyr::select(country, adu_yld, adu_yll, adu_death, adu_daly)
colnames(maternal_sum) <- gsub("^adu_", "", colnames(maternal_sum))
infant_sum=
sumhealth %>%
dplyr:: select(country, inf_yld, inf_yll, inf_death, inf_daly)
colnames(infant_sum) <- gsub("^inf_", "", colnames(infant_sum))
save the data for dashboard: save(maternal_sum, infant_sum, pretermcal, sumhealth, summaryplot, file=“/Users/hec442/Desktop/harvard/calcium/dashboard/summaryhealth.RData”)