Skip to content

Commit 77ce173

Browse files
authored
Add files via upload
1 parent 4029bd9 commit 77ce173

22 files changed

+4552
-0
lines changed

Brain Health Initiative/Foregone wages of informal caregivers/1 Modeling condition-specific caregiving hours/01_create_age_matrix.R

Lines changed: 350 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#################################################################
2+
# Title: 02_create_disability_weights_all_ages.R
3+
# Author: USERNAME
4+
# Date: 2024 12 31
5+
# Project: BHI - Brain Health Initiative
6+
# Purpose : Pull YLDs and prevalent cases from the GBD and
7+
# calculate disability weights for brain health causes
8+
#################################################################
9+
10+
# Setting up environment
11+
# clear environment
12+
rm(list = ls())
13+
14+
# packages
15+
library(data.table)
16+
17+
# file paths
18+
age_group_id_path <- "FILEPATH/age_group_id_table.csv"
19+
20+
# functions
21+
source("FILEPATH/get_location_metadata.R")
22+
source("FILEPATH/get_age_metadata.R")
23+
source("FILEPATH/get_outputs.R")
24+
25+
# Importing Age group info
26+
age_group_id_table <- fread(age_group_id_path)
27+
28+
# Data info
29+
data_yr <- 2021
30+
gbd_release_id <- 16
31+
years <- 2000:(data_yr)
32+
locs <- get_location_metadata(location_set_id = 35, release_id = gbd_release_id)[level == 3]
33+
ages <- get_age_metadata(age_group_set_id = 24, release_id = gbd_release_id)
34+
35+
####----# Pull and process burden data #----####
36+
cat(' Pull and process burden data\n')
37+
38+
## Pull YLD values
39+
burden <- get_outputs('cause',
40+
cause_id = c(332, # meningitis
41+
337, # encephalitis
42+
477, # neo_brain
43+
494, # cvd_stroke
44+
543, # neuro_dementia
45+
544, # neuro_parkinsons
46+
545, # neuro_epilepsy
47+
546, # neuro_ms
48+
554, # neuro_neurone
49+
557, # neuro_other
50+
559, # mental_schizo
51+
567, # mental_unipolar
52+
570, # mental_bipolar
53+
571, # mental_anxiety
54+
572, # mental_eating
55+
575, # mental_pdd
56+
578, # mental_adhd
57+
579, # mental_conduct
58+
582, # mental_id
59+
585, # mental_other
60+
560, # mental_alcohol
61+
562, # mental_drug_opioids
62+
563, 564, 565, 566, # mental_drug_other (other substances to aggregate together)
63+
718, # inj_suicide
64+
972), # neuro_headach
65+
location_id = c(1, locs[level == 3]$location_id), # global and country locations
66+
year_id = years, # years 2000 to 2021
67+
sex_id = 3, # both sexes
68+
age_group_id = 22, # all ages
69+
measure_id = c(3, 5), # prevalence and YLDs
70+
metric_id = 1, # numeric
71+
release_id = gbd_release_id)
72+
73+
# Formatting cause ids
74+
## Reassign other drug use disorders
75+
# Non-opioid use disorders is a BHI-specific cause that is an aggregate of the following disorders:
76+
# - cocaine use disorders
77+
# - amphetamine use disorders
78+
# - cannabis use disorders
79+
# - other drug use disorders
80+
81+
burden[cause_id %in% 563:566, cause_name := 'Non-opioid drug use disorders']
82+
83+
## Aggregate measures for reassigned cause
84+
burden_agg <- burden[, .(val = sum(val, na.rm = T)),
85+
by = .(location_id, location_name, year_id, sex_id, age_group_name, cause_name, measure)]
86+
87+
## Reshape long to wide by measure
88+
burden_wide <- dcast.data.table(burden_agg, location_id + location_name + year_id + sex_id + age_group_name + cause_name ~ measure, value.var = 'val')
89+
90+
## Calculate YLDs per case (disability weight)
91+
burden_wide[, yld_per_case := yld / prevalence]
92+
93+
# adding age group id
94+
burden_wide <- merge(burden_wide, age_group_id_table, by = 'age_group_name', all.x = T)
95+
96+
## Reshape long to wide by year to make more readable
97+
burden_wide_years <- dcast.data.table(burden_wide, location_id + location_name + sex_id + age_group_name + age_group_id + cause_name ~ year_id, value.var = 'yld_per_case')
98+
99+
# Saving out dt
100+
fwrite(burden_wide, "FILEPATH/average_disability_weights_by_loc_year_no_age_sex.csv")
101+
fwrite(burden_wide_years, "FILEPATH/average_disability_weights_by_loc_year_no_age_sex_wide_by_year.csv")

0 commit comments

Comments
 (0)