This doc will explore mortality and DALYs by risk factors
First to load the pre requisite packages and script for downloading data.
library(tidyverse)
source("download_completed_request.R")
Next I will download the data from the request. (Only has to be done once so now set not to evaluate (run)).
The files can now be loaded and joined locally as follows
dta <- read_csv("raw_data/risk/1.csv") %>% bind_rows(read_csv("raw_data/risk/2.csv"))
Parsed with column specification:
cols(
measure_id = col_integer(),
measure_name = col_character(),
location_id = col_integer(),
location_name = col_character(),
sex_id = col_integer(),
sex_name = col_character(),
age_id = col_integer(),
age_name = col_character(),
cause_id = col_integer(),
cause_name = col_character(),
rei_id = col_integer(),
rei_name = col_character(),
metric_id = col_integer(),
metric_name = col_character(),
year = col_integer(),
val = col_double(),
upper = col_double(),
lower = col_double()
)
| | 0%
| | 0%
| | 0%
| | 0%
| | 0%
| | 0%
| | 0%
|= | 1%
|= | 1%
|= | 1% 1 MB
|= | 1% 1 MB
|= | 1% 1 MB
|= | 1% 1 MB
|= | 1% 1 MB
|= | 1% 1 MB
|= | 1% 1 MB
|= | 2% 1 MB
|== | 2% 1 MB
|== | 2% 1 MB
|== | 2% 1 MB
|== | 2% 1 MB
|== | 2% 1 MB
|== | 2% 2 MB
|== | 2% 2 MB
|== | 2% 2 MB
|== | 2% 2 MB
|== | 2% 2 MB
|=== | 3% 2 MB
|=== | 3% 2 MB
|=== | 3% 2 MB
|=== | 3% 2 MB
|=== | 3% 2 MB
|=== | 3% 2 MB
|=== | 3% 2 MB
|=== | 3% 2 MB
|=== | 3% 3 MB
|=== | 3% 3 MB
|==== | 4% 3 MB
|==== | 4% 3 MB
|==== | 4% 3 MB
|==== | 4% 3 MB
|==== | 4% 3 MB
|==== | 4% 3 MB
|==== | 4% 3 MB
|==== | 4% 3 MB
|==== | 4% 3 MB
|==== | 5% 3 MB
|===== | 5% 4 MB
|===== | 5% 4 MB
|===== | 5% 4 MB
|===== | 5% 4 MB
|===== | 5% 4 MB
|===== | 5% 4 MB
|===== | 5% 4 MB
|===== | 5% 4 MB
|====== | 6% 4 MB
|====== | 6% 4 MB
|====== | 6% 4 MB
|====== | 6% 5 MB
|====== | 6% 5 MB
|====== | 6% 5 MB
|====== | 6% 5 MB
|====== | 6% 5 MB
|====== | 6% 5 MB
|====== | 6% 5 MB
|====== | 7% 5 MB
|======= | 7% 5 MB
|======= | 7% 5 MB
|======= | 7% 5 MB
|======= | 7% 5 MB
|======= | 7% 5 MB
|======= | 7% 5 MB
|======= | 7% 6 MB
|======= | 7% 6 MB
|======= | 7% 6 MB
|======== | 8% 6 MB
|======== | 8% 6 MB
|======== | 8% 6 MB
|======== | 8% 6 MB
|======== | 8% 6 MB
|======== | 8% 6 MB
|======== | 8% 6 MB
|======== | 8% 7 MB
|======== | 9% 7 MB
|========= | 9% 7 MB
|========= | 9% 7 MB
|========= | 9% 7 MB
|========= | 9% 7 MB
|========= | 9% 7 MB
|========= | 9% 7 MB
|========= | 9% 7 MB
|========= | 9% 7 MB
|========= | 10% 7 MB
|========== | 10% 7 MB
|========== | 10% 8 MB
|========== | 10% 8 MB
|========== | 10% 8 MB
|========== | 10% 8 MB
|========== | 10% 8 MB
|========== | 10% 8 MB
|========== | 10% 8 MB
|========== | 10% 8 MB
|========== | 11% 8 MB
|=========== | 11% 8 MB
|=========== | 11% 8 MB
|=========== | 11% 8 MB
|=========== | 11% 8 MB
|=========== | 11% 9 MB
|=========== | 11% 9 MB
|=========== | 11% 9 MB
|=========== | 11% 9 MB
|=========== | 11% 9 MB
|=========== | 12% 9 MB
|============ | 12% 9 MB
|============ | 12% 9 MB
|============ | 12% 9 MB
|============ | 12% 9 MB
|============ | 12% 9 MB
|============ | 12% 9 MB
|============ | 12% 10 MB
|============ | 12% 10 MB
|============ | 13% 10 MB
|============= | 13% 10 MB
|============= | 13% 10 MB
|============= | 13% 10 MB
|============= | 13% 10 MB
|============= | 13% 10 MB
|============= | 13% 10 MB
|============= | 13% 10 MB
|============= | 13% 10 MB
|============= | 14% 11 MB
|============== | 14% 11 MB
|============== | 14% 11 MB
|============== | 14% 11 MB
|============== | 14% 11 MB
|============== | 14% 11 MB
|============== | 14% 11 MB
|============== | 14% 11 MB
|============== | 15% 11 MB
|============== | 15% 11 MB
|=============== | 15% 11 MB
|=============== | 15% 12 MB
|=============== | 15% 12 MB
|=============== | 15% 12 MB
|=============== | 15% 12 MB
|=============== | 15% 12 MB
|=============== | 15% 12 MB
|=============== | 16% 12 MB
|================ | 16% 12 MB
|================ | 16% 12 MB
|================ | 16% 12 MB
|================ | 16% 12 MB
|================ | 16% 13 MB
|================ | 16% 13 MB
|================ | 16% 13 MB
|================ | 16% 13 MB
|================ | 16% 13 MB
|================ | 17% 13 MB
|================= | 17% 13 MB
|================= | 17% 13 MB
|================= | 17% 13 MB
|================= | 17% 13 MB
|================= | 17% 13 MB
|================= | 17% 13 MB
|================= | 17% 13 MB
|================= | 17% 14 MB
|================= | 17% 14 MB
|================= | 18% 14 MB
|================= | 18% 14 MB
|================== | 18% 14 MB
|================== | 18% 14 MB
|================== | 18% 14 MB
|================== | 18% 14 MB
|================== | 18% 14 MB
|================== | 18% 14 MB
|================== | 18% 14 MB
|================== | 18% 14 MB
|================== | 19% 15 MB
|=================== | 19% 15 MB
|=================== | 19% 15 MB
|=================== | 19% 15 MB
|=================== | 19% 15 MB
|=================== | 19% 15 MB
|=================== | 19% 15 MB
|=================== | 19% 15 MB
|=================== | 20% 15 MB
|==================== | 20% 15 MB
|==================== | 20% 15 MB
|==================== | 20% 16 MB
|==================== | 20% 16 MB
|==================== | 20% 16 MB
|==================== | 20% 16 MB
|==================== | 20% 16 MB
|==================== | 21% 16 MB
|==================== | 21% 16 MB
|===================== | 21% 16 MB
|===================== | 21% 16 MB
|===================== | 21% 16 MB
|===================== | 21% 17 MB
|===================== | 21% 17 MB
|===================== | 21% 17 MB
|===================== | 22% 17 MB
|===================== | 22% 17 MB
|====================== | 22% 17 MB
|====================== | 22% 17 MB
|====================== | 22% 17 MB
|====================== | 22% 17 MB
|====================== | 22% 17 MB
|====================== | 22% 17 MB
|====================== | 22% 17 MB
|====================== | 22% 18 MB
|====================== | 23% 18 MB
|====================== | 23% 18 MB
|======================= | 23% 18 MB
|======================= | 23% 18 MB
|======================= | 23% 18 MB
|======================= | 23% 18 MB
|======================= | 23% 18 MB
|======================= | 23% 18 MB
|======================= | 23% 18 MB
|======================= | 23% 18 MB
|======================= | 24% 18 MB
|======================= | 24% 18 MB
|======================= | 24% 19 MB
|======================== | 24% 19 MB
|======================== | 24% 19 MB
|======================== | 24% 19 MB
|======================== | 24% 19 MB
|======================== | 24% 19 MB
|======================== | 24% 19 MB
|======================== | 24% 19 MB
|======================== | 24% 19 MB
|======================== | 25% 19 MB
|======================== | 25% 19 MB
|========================= | 25% 19 MB
|========================= | 25% 19 MB
|========================= | 25% 20 MB
|========================= | 25% 20 MB
|========================= | 25% 20 MB
|========================= | 25% 20 MB
|========================= | 26% 20 MB
|========================= | 26% 20 MB
|========================== | 26% 20 MB
|========================== | 26% 20 MB
|========================== | 26% 20 MB
|========================== | 26% 20 MB
|========================== | 26% 21 MB
|========================== | 26% 21 MB
|========================== | 27% 21 MB
|========================== | 27% 21 MB
|========================== | 27% 21 MB
|=========================== | 27% 21 MB
|=========================== | 27% 21 MB
|=========================== | 27% 21 MB
|=========================== | 27% 21 MB
|=========================== | 27% 21 MB
|=========================== | 27% 21 MB
|=========================== | 28% 22 MB
|=========================== | 28% 22 MB
|============================ | 28% 22 MB
|============================ | 28% 22 MB
|============================ | 28% 22 MB
|============================ | 28% 22 MB
|============================ | 28% 22 MB
|============================ | 28% 22 MB
|============================ | 29% 22 MB
|============================ | 29% 22 MB
|============================ | 29% 22 MB
|============================= | 29% 23 MB
|============================= | 29% 23 MB
|============================= | 29% 23 MB
|============================= | 29% 23 MB
|============================= | 29% 23 MB
|============================= | 29% 23 MB
|============================= | 29% 23 MB
|============================= | 29% 23 MB
|============================= | 30% 23 MB
|============================= | 30% 23 MB
|============================= | 30% 23 MB
|============================== | 30% 23 MB
|============================== | 30% 23 MB
|============================== | 30% 24 MB
|============================== | 30% 24 MB
|============================== | 30% 24 MB
|============================== | 30% 24 MB
|============================== | 31% 24 MB
|============================== | 31% 24 MB
|=============================== | 31% 24 MB
|=============================== | 31% 24 MB
|=============================== | 31% 24 MB
|=============================== | 31% 24 MB
|=============================== | 31% 24 MB
|=============================== | 31% 25 MB
|=============================== | 32% 25 MB
|=============================== | 32% 25 MB
|=============================== | 32% 25 MB
|=============================== | 32% 25 MB
|================================ | 32% 25 MB
|================================ | 32% 25 MB
|================================ | 32% 25 MB
|================================ | 32% 25 MB
|================================ | 32% 25 MB
|================================ | 32% 25 MB
|================================ | 33% 25 MB
|================================ | 33% 26 MB
|================================ | 33% 26 MB
|================================= | 33% 26 MB
|================================= | 33% 26 MB
|================================= | 33% 26 MB
|================================= | 33% 26 MB
|================================= | 33% 26 MB
|================================= | 33% 26 MB
|================================= | 34% 26 MB
|================================= | 34% 26 MB
|================================= | 34% 26 MB
|================================== | 34% 27 MB
|================================== | 34% 27 MB
|================================== | 34% 27 MB
|================================== | 34% 27 MB
|================================== | 34% 27 MB
|================================== | 34% 27 MB
|================================== | 35% 27 MB
|================================== | 35% 27 MB
|================================== | 35% 27 MB
|=================================== | 35% 27 MB
|=================================== | 35% 27 MB
|=================================== | 35% 27 MB
|=================================== | 35% 28 MB
|=================================== | 35% 28 MB
|=================================== | 35% 28 MB
|=================================== | 35% 28 MB
|=================================== | 36% 28 MB
|=================================== | 36% 28 MB
|=================================== | 36% 28 MB
|=================================== | 36% 28 MB
|==================================== | 36% 28 MB
|==================================== | 36% 28 MB
|==================================== | 36% 28 MB
|==================================== | 36% 28 MB
|==================================== | 36% 28 MB
|==================================== | 37% 29 MB
|==================================== | 37% 29 MB
|==================================== | 37% 29 MB
|===================================== | 37% 29 MB
|===================================== | 37% 29 MB
|===================================== | 37% 29 MB
|===================================== | 37% 29 MB
|===================================== | 37% 29 MB
|===================================== | 38% 29 MB
|===================================== | 38% 29 MB
|===================================== | 38% 30 MB
|====================================== | 38% 30 MB
|====================================== | 38% 30 MB
|====================================== | 38% 30 MB
|====================================== | 38% 30 MB
|====================================== | 38% 30 MB
|====================================== | 38% 30 MB
|====================================== | 39% 30 MB
|====================================== | 39% 30 MB
|====================================== | 39% 30 MB
|======================================= | 39% 30 MB
|======================================= | 39% 31 MB
|======================================= | 39% 31 MB
|======================================= | 39% 31 MB
|======================================= | 39% 31 MB
|======================================= | 40% 31 MB
|======================================= | 40% 31 MB
|======================================= | 40% 31 MB
|======================================== | 40% 31 MB
|======================================== | 40% 31 MB
|======================================== | 40% 31 MB
|======================================== | 40% 32 MB
|======================================== | 40% 32 MB
|======================================== | 41% 32 MB
|======================================== | 41% 32 MB
|======================================== | 41% 32 MB
|========================================= | 41% 32 MB
|========================================= | 41% 32 MB
|========================================= | 41% 32 MB
|========================================= | 41% 32 MB
|========================================= | 41% 32 MB
|========================================= | 42% 33 MB
|========================================= | 42% 33 MB
|========================================= | 42% 33 MB
|========================================= | 42% 33 MB
|========================================= | 42% 33 MB
|========================================== | 42% 33 MB
|========================================== | 42% 33 MB
|========================================== | 42% 33 MB
|========================================== | 42% 33 MB
|========================================== | 42% 33 MB
|========================================== | 42% 33 MB
|========================================== | 43% 33 MB
|========================================== | 43% 33 MB
|========================================== | 43% 33 MB
|========================================== | 43% 34 MB
|=========================================== | 43% 34 MB
|=========================================== | 43% 34 MB
|=========================================== | 43% 34 MB
|=========================================== | 43% 34 MB
|=========================================== | 43% 34 MB
|=========================================== | 43% 34 MB
|=========================================== | 44% 34 MB
|=========================================== | 44% 34 MB
|=========================================== | 44% 34 MB
|=========================================== | 44% 34 MB
|============================================ | 44% 34 MB
|============================================ | 44% 35 MB
|============================================ | 44% 35 MB
|============================================ | 44% 35 MB
|============================================ | 44% 35 MB
|============================================ | 44% 35 MB
|============================================ | 45% 35 MB
|============================================ | 45% 35 MB
|============================================ | 45% 35 MB
|============================================ | 45% 35 MB
|============================================= | 45% 35 MB
|============================================= | 45% 35 MB
|============================================= | 45% 35 MB
|============================================= | 45% 35 MB
|============================================= | 45% 36 MB
|============================================= | 45% 36 MB
|============================================= | 46% 36 MB
|============================================= | 46% 36 MB
|============================================= | 46% 36 MB
|============================================= | 46% 36 MB
|============================================== | 46% 36 MB
|============================================== | 46% 36 MB
|============================================== | 46% 36 MB
|============================================== | 46% 36 MB
|============================================== | 46% 36 MB
|============================================== | 47% 36 MB
|============================================== | 47% 36 MB
|============================================== | 47% 37 MB
|============================================== | 47% 37 MB
|============================================== | 47% 37 MB
|=============================================== | 47% 37 MB
|=============================================== | 47% 37 MB
|=============================================== | 47% 37 MB
|=============================================== | 47% 37 MB
|=============================================== | 47% 37 MB
|=============================================== | 47% 37 MB
|=============================================== | 48% 37 MB
|=============================================== | 48% 37 MB
|=============================================== | 48% 37 MB
|================================================ | 48% 38 MB
|================================================ | 48% 38 MB
|================================================ | 48% 38 MB
|================================================ | 48% 38 MB
|================================================ | 48% 38 MB
|================================================ | 49% 38 MB
|================================================ | 49% 38 MB
|================================================ | 49% 38 MB
|================================================ | 49% 38 MB
|================================================= | 49% 38 MB
|================================================= | 49% 39 MB
|================================================= | 49% 39 MB
|================================================= | 49% 39 MB
|================================================= | 50% 39 MB
|================================================= | 50% 39 MB
|================================================= | 50% 39 MB
|================================================= | 50% 39 MB
|================================================== | 50% 39 MB
|================================================== | 50% 39 MB
|================================================== | 50% 39 MB
|================================================== | 50% 39 MB
|================================================== | 51% 40 MB
|================================================== | 51% 40 MB
|================================================== | 51% 40 MB
|================================================== | 51% 40 MB
|================================================== | 51% 40 MB
|=================================================== | 51% 40 MB
|=================================================== | 51% 40 MB
|=================================================== | 51% 40 MB
|=================================================== | 51% 40 MB
|=================================================== | 52% 40 MB
|=================================================== | 52% 41 MB
|=================================================== | 52% 41 MB
|=================================================== | 52% 41 MB
|==================================================== | 52% 41 MB
|==================================================== | 52% 41 MB
|==================================================== | 52% 41 MB
|==================================================== | 52% 41 MB
|==================================================== | 53% 41 MB
|==================================================== | 53% 41 MB
|==================================================== | 53% 41 MB
|==================================================== | 53% 41 MB
|==================================================== | 53% 42 MB
|===================================================== | 53% 42 MB
|===================================================== | 53% 42 MB
|===================================================== | 53% 42 MB
|===================================================== | 54% 42 MB
|===================================================== | 54% 42 MB
|===================================================== | 54% 42 MB
|===================================================== | 54% 42 MB
|===================================================== | 54% 42 MB
|====================================================== | 54% 42 MB
|====================================================== | 54% 43 MB
|====================================================== | 54% 43 MB
|====================================================== | 55% 43 MB
|====================================================== | 55% 43 MB
|====================================================== | 55% 43 MB
|====================================================== | 55% 43 MB
|====================================================== | 55% 43 MB
|====================================================== | 55% 43 MB
|======================================================= | 55% 43 MB
|======================================================= | 55% 43 MB
|======================================================= | 55% 43 MB
|======================================================= | 55% 43 MB
|======================================================= | 56% 43 MB
|======================================================= | 56% 44 MB
|======================================================= | 56% 44 MB
|======================================================= | 56% 44 MB
|======================================================= | 56% 44 MB
|======================================================= | 56% 44 MB
|======================================================== | 56% 44 MB
|======================================================== | 56% 44 MB
|======================================================== | 56% 44 MB
|======================================================== | 56% 44 MB
|======================================================== | 57% 44 MB
|======================================================== | 57% 44 MB
|======================================================== | 57% 44 MB
|======================================================== | 57% 44 MB
|======================================================== | 57% 45 MB
|======================================================== | 57% 45 MB
|========================================================= | 57% 45 MB
|========================================================= | 57% 45 MB
|========================================================= | 57% 45 MB
|========================================================= | 57% 45 MB
|========================================================= | 57% 45 MB
|========================================================= | 58% 45 MB
|========================================================= | 58% 45 MB
|========================================================= | 58% 45 MB
|========================================================= | 58% 45 MB
|========================================================== | 58% 46 MB
|========================================================== | 58% 46 MB
|========================================================== | 58% 46 MB
|========================================================== | 58% 46 MB
|========================================================== | 59% 46 MB
|========================================================== | 59% 46 MB
|========================================================== | 59% 46 MB
|========================================================== | 59% 46 MB
|========================================================== | 59% 46 MB
|=========================================================== | 59% 46 MB
|=========================================================== | 59% 46 MB
|=========================================================== | 59% 47 MB
|=========================================================== | 60% 47 MB
|=========================================================== | 60% 47 MB
|=========================================================== | 60% 47 MB
|=========================================================== | 60% 47 MB
|=========================================================== | 60% 47 MB
|=========================================================== | 60% 47 MB
|============================================================ | 60% 47 MB
|============================================================ | 60% 47 MB
|============================================================ | 60% 47 MB
|============================================================ | 60% 47 MB
|============================================================ | 61% 47 MB
|============================================================ | 61% 48 MB
|============================================================ | 61% 48 MB
|============================================================ | 61% 48 MB
|============================================================ | 61% 48 MB
|============================================================ | 61% 48 MB
|============================================================= | 61% 48 MB
|============================================================= | 61% 48 MB
|============================================================= | 61% 48 MB
|============================================================= | 61% 48 MB
|============================================================= | 62% 48 MB
|============================================================= | 62% 48 MB
|============================================================= | 62% 48 MB
|============================================================= | 62% 48 MB
|============================================================= | 62% 49 MB
|============================================================= | 62% 49 MB
|============================================================== | 62% 49 MB
|============================================================== | 62% 49 MB
|============================================================== | 62% 49 MB
|============================================================== | 62% 49 MB
|============================================================== | 63% 49 MB
|============================================================== | 63% 49 MB
|============================================================== | 63% 49 MB
|============================================================== | 63% 49 MB
|============================================================== | 63% 49 MB
|============================================================== | 63% 49 MB
|=============================================================== | 63% 50 MB
|=============================================================== | 63% 50 MB
|=============================================================== | 63% 50 MB
|=============================================================== | 63% 50 MB
|=============================================================== | 64% 50 MB
|=============================================================== | 64% 50 MB
|=============================================================== | 64% 50 MB
|=============================================================== | 64% 50 MB
|=============================================================== | 64% 50 MB
|=============================================================== | 64% 50 MB
|================================================================ | 64% 50 MB
|================================================================ | 64% 50 MB
|================================================================ | 64% 50 MB
|================================================================ | 65% 51 MB
|================================================================ | 65% 51 MB
|================================================================ | 65% 51 MB
|================================================================ | 65% 51 MB
|================================================================ | 65% 51 MB
|================================================================ | 65% 51 MB
|================================================================ | 65% 51 MB
|================================================================= | 65% 51 MB
|================================================================= | 65% 51 MB
|================================================================= | 65% 51 MB
|================================================================= | 66% 51 MB
|================================================================= | 66% 51 MB
|================================================================= | 66% 52 MB
|================================================================= | 66% 52 MB
|================================================================= | 66% 52 MB
|================================================================== | 66% 52 MB
|================================================================== | 66% 52 MB
|================================================================== | 66% 52 MB
|================================================================== | 67% 52 MB
|================================================================== | 67% 52 MB
|================================================================== | 67% 52 MB
|================================================================== | 67% 52 MB
|================================================================== | 67% 53 MB
|================================================================== | 67% 53 MB
|=================================================================== | 67% 53 MB
|=================================================================== | 67% 53 MB
|=================================================================== | 68% 53 MB
|=================================================================== | 68% 53 MB
|=================================================================== | 68% 53 MB
|=================================================================== | 68% 53 MB
|=================================================================== | 68% 53 MB
|=================================================================== | 68% 53 MB
|==================================================================== | 68% 54 MB
|==================================================================== | 68% 54 MB
|==================================================================== | 69% 54 MB
|==================================================================== | 69% 54 MB
|==================================================================== | 69% 54 MB
|==================================================================== | 69% 54 MB
|==================================================================== | 69% 54 MB
|==================================================================== | 69% 54 MB
|===================================================================== | 69% 54 MB
|===================================================================== | 69% 54 MB
|===================================================================== | 70% 55 MB
|===================================================================== | 70% 55 MB
|===================================================================== | 70% 55 MB
|===================================================================== | 70% 55 MB
|===================================================================== | 70% 55 MB
|===================================================================== | 70% 55 MB
|====================================================================== | 70% 55 MB
|====================================================================== | 70% 55 MB
|====================================================================== | 71% 55 MB
|====================================================================== | 71% 55 MB
|====================================================================== | 71% 55 MB
|====================================================================== | 71% 56 MB
|====================================================================== | 71% 56 MB
|====================================================================== | 71% 56 MB
|======================================================================= | 71% 56 MB
|======================================================================= | 71% 56 MB
|======================================================================= | 71% 56 MB
|======================================================================= | 72% 56 MB
|======================================================================= | 72% 56 MB
|======================================================================= | 72% 56 MB
|======================================================================= | 72% 56 MB
|======================================================================= | 72% 57 MB
|======================================================================= | 72% 57 MB
|======================================================================== | 72% 57 MB
|======================================================================== | 72% 57 MB
|======================================================================== | 73% 57 MB
|======================================================================== | 73% 57 MB
|======================================================================== | 73% 57 MB
|======================================================================== | 73% 57 MB
|======================================================================== | 73% 57 MB
|======================================================================== | 73% 57 MB
|======================================================================== | 73% 57 MB
|========================================================================= | 73% 57 MB
|========================================================================= | 73% 58 MB
|========================================================================= | 74% 58 MB
|========================================================================= | 74% 58 MB
|========================================================================= | 74% 58 MB
|========================================================================= | 74% 58 MB
|========================================================================= | 74% 58 MB
|========================================================================= | 74% 58 MB
|========================================================================= | 74% 58 MB
|========================================================================== | 74% 58 MB
|========================================================================== | 74% 58 MB
|========================================================================== | 75% 58 MB
|========================================================================== | 75% 59 MB
|========================================================================== | 75% 59 MB
|========================================================================== | 75% 59 MB
|========================================================================== | 75% 59 MB
|========================================================================== | 75% 59 MB
|=========================================================================== | 75% 59 MB
|=========================================================================== | 75% 59 MB
|=========================================================================== | 76% 59 MB
|=========================================================================== | 76% 59 MB
|=========================================================================== | 76% 59 MB
|=========================================================================== | 76% 59 MB
|=========================================================================== | 76% 60 MB
|=========================================================================== | 76% 60 MB
|=========================================================================== | 76% 60 MB
|============================================================================ | 76% 60 MB
|============================================================================ | 76% 60 MB
|============================================================================ | 76% 60 MB
|============================================================================ | 77% 60 MB
|============================================================================ | 77% 60 MB
|============================================================================ | 77% 60 MB
|============================================================================ | 77% 60 MB
|============================================================================ | 77% 60 MB
|============================================================================ | 77% 60 MB
|============================================================================ | 77% 61 MB
|============================================================================= | 77% 61 MB
|============================================================================= | 77% 61 MB
|============================================================================= | 77% 61 MB
|============================================================================= | 78% 61 MB
|============================================================================= | 78% 61 MB
|============================================================================= | 78% 61 MB
|============================================================================= | 78% 61 MB
|============================================================================= | 78% 61 MB
|============================================================================= | 78% 61 MB
|============================================================================= | 78% 61 MB
|============================================================================== | 78% 61 MB
|============================================================================== | 78% 61 MB
|============================================================================== | 79% 62 MB
|============================================================================== | 79% 62 MB
|============================================================================== | 79% 62 MB
|============================================================================== | 79% 62 MB
|============================================================================== | 79% 62 MB
|============================================================================== | 79% 62 MB
|============================================================================== | 79% 62 MB
|=============================================================================== | 79% 62 MB
|=============================================================================== | 79% 62 MB
|=============================================================================== | 80% 62 MB
|=============================================================================== | 80% 62 MB
|=============================================================================== | 80% 63 MB
|=============================================================================== | 80% 63 MB
|=============================================================================== | 80% 63 MB
|=============================================================================== | 80% 63 MB
|================================================================================ | 80% 63 MB
|================================================================================ | 80% 63 MB
|================================================================================ | 81% 63 MB
|================================================================================ | 81% 63 MB
|================================================================================ | 81% 63 MB
|================================================================================ | 81% 63 MB
|================================================================================ | 81% 64 MB
|================================================================================ | 81% 64 MB
|================================================================================= | 81% 64 MB
|================================================================================= | 81% 64 MB
|================================================================================= | 82% 64 MB
|================================================================================= | 82% 64 MB
|================================================================================= | 82% 64 MB
|================================================================================= | 82% 64 MB
|================================================================================= | 82% 64 MB
|================================================================================= | 82% 64 MB
|================================================================================== | 82% 65 MB
|================================================================================== | 82% 65 MB
|================================================================================== | 83% 65 MB
|================================================================================== | 83% 65 MB
|================================================================================== | 83% 65 MB
|================================================================================== | 83% 65 MB
|================================================================================== | 83% 65 MB
|================================================================================== | 83% 65 MB
|================================================================================== | 83% 65 MB
|================================================================================== | 83% 65 MB
|=================================================================================== | 83% 65 MB
|=================================================================================== | 84% 65 MB
|=================================================================================== | 84% 66 MB
|=================================================================================== | 84% 66 MB
|=================================================================================== | 84% 66 MB
|=================================================================================== | 84% 66 MB
|=================================================================================== | 84% 66 MB
|=================================================================================== | 84% 66 MB
|=================================================================================== | 84% 66 MB
|=================================================================================== | 84% 66 MB
|==================================================================================== | 84% 66 MB
|==================================================================================== | 84% 66 MB
|==================================================================================== | 85% 66 MB
|==================================================================================== | 85% 66 MB
|==================================================================================== | 85% 66 MB
|==================================================================================== | 85% 67 MB
|==================================================================================== | 85% 67 MB
|==================================================================================== | 85% 67 MB
|==================================================================================== | 85% 67 MB
|==================================================================================== | 85% 67 MB
|===================================================================================== | 85% 67 MB
|===================================================================================== | 86% 67 MB
|===================================================================================== | 86% 67 MB
|===================================================================================== | 86% 67 MB
|===================================================================================== | 86% 67 MB
|===================================================================================== | 86% 67 MB
|===================================================================================== | 86% 68 MB
|===================================================================================== | 86% 68 MB
|====================================================================================== | 86% 68 MB
|====================================================================================== | 87% 68 MB
|====================================================================================== | 87% 68 MB
|====================================================================================== | 87% 68 MB
|====================================================================================== | 87% 68 MB
|====================================================================================== | 87% 68 MB
|====================================================================================== | 87% 68 MB
|====================================================================================== | 87% 68 MB
|======================================================================================= | 87% 69 MB
|======================================================================================= | 88% 69 MB
|======================================================================================= | 88% 69 MB
|======================================================================================= | 88% 69 MB
|======================================================================================= | 88% 69 MB
|======================================================================================= | 88% 69 MB
|======================================================================================= | 88% 69 MB
|======================================================================================= | 88% 69 MB
|======================================================================================== | 88% 69 MB
|======================================================================================== | 89% 69 MB
|======================================================================================== | 89% 70 MB
|======================================================================================== | 89% 70 MB
|======================================================================================== | 89% 70 MB
|======================================================================================== | 89% 70 MB
|======================================================================================== | 89% 70 MB
|======================================================================================== | 89% 70 MB
|======================================================================================== | 89% 70 MB
|========================================================================================= | 89% 70 MB
|========================================================================================= | 90% 70 MB
|========================================================================================= | 90% 70 MB
|========================================================================================= | 90% 70 MB
|========================================================================================= | 90% 70 MB
|========================================================================================= | 90% 71 MB
|========================================================================================= | 90% 71 MB
|========================================================================================= | 90% 71 MB
|========================================================================================= | 90% 71 MB
|========================================================================================= | 90% 71 MB
|========================================================================================== | 91% 71 MB
|========================================================================================== | 91% 71 MB
|========================================================================================== | 91% 71 MB
|========================================================================================== | 91% 71 MB
|========================================================================================== | 91% 71 MB
|========================================================================================== | 91% 71 MB
|========================================================================================== | 91% 71 MB
|========================================================================================== | 91% 72 MB
|========================================================================================== | 91% 72 MB
|=========================================================================================== | 91% 72 MB
|=========================================================================================== | 92% 72 MB
|=========================================================================================== | 92% 72 MB
|=========================================================================================== | 92% 72 MB
|=========================================================================================== | 92% 72 MB
|=========================================================================================== | 92% 72 MB
|=========================================================================================== | 92% 72 MB
|=========================================================================================== | 92% 72 MB
|=========================================================================================== | 92% 72 MB
|=========================================================================================== | 92% 72 MB
|============================================================================================ | 93% 73 MB
|============================================================================================ | 93% 73 MB
|============================================================================================ | 93% 73 MB
|============================================================================================ | 93% 73 MB
|============================================================================================ | 93% 73 MB
|============================================================================================ | 93% 73 MB
|============================================================================================ | 93% 73 MB
|============================================================================================ | 93% 73 MB
|============================================================================================= | 94% 73 MB
|============================================================================================= | 94% 73 MB
|============================================================================================= | 94% 74 MB
|============================================================================================= | 94% 74 MB
|============================================================================================= | 94% 74 MB
|============================================================================================= | 94% 74 MB
|============================================================================================= | 94% 74 MB
|============================================================================================== | 94% 74 MB
|============================================================================================== | 95% 74 MB
|============================================================================================== | 95% 74 MB
|============================================================================================== | 95% 74 MB
|============================================================================================== | 95% 74 MB
|============================================================================================== | 95% 75 MB
|============================================================================================== | 95% 75 MB
|============================================================================================== | 95% 75 MB
|=============================================================================================== | 95% 75 MB
|=============================================================================================== | 96% 75 MB
|=============================================================================================== | 96% 75 MB
|=============================================================================================== | 96% 75 MB
|=============================================================================================== | 96% 75 MB
|=============================================================================================== | 96% 75 MB
|=============================================================================================== | 96% 75 MB
|=============================================================================================== | 96% 76 MB
|================================================================================================ | 96% 76 MB
|================================================================================================ | 97% 76 MB
|================================================================================================ | 97% 76 MB
|================================================================================================ | 97% 76 MB
|================================================================================================ | 97% 76 MB
|================================================================================================ | 97% 76 MB
|================================================================================================ | 97% 76 MB
|================================================================================================ | 97% 76 MB
|================================================================================================ | 97% 76 MB
|================================================================================================= | 98% 77 MB
|================================================================================================= | 98% 77 MB
|================================================================================================= | 98% 77 MB
|================================================================================================= | 98% 77 MB
|================================================================================================= | 98% 77 MB
|================================================================================================= | 98% 77 MB
|================================================================================================= | 98% 77 MB
|================================================================================================= | 98% 77 MB
|==================================================================================================| 99% 77 MB
|==================================================================================================| 99% 77 MB
|==================================================================================================| 99% 77 MB
|==================================================================================================| 99% 77 MB
|==================================================================================================| 99% 78 MB
|==================================================================================================| 99% 78 MB
|==================================================================================================| 99% 78 MB
|==================================================================================================| 99% 78 MB
|==================================================================================================| 99% 78 MB
|==================================================================================================| 99% 78 MB
|===================================================================================================| 100% 78 MB
|===================================================================================================| 100% 78 MB
Parsed with column specification:
cols(
measure_id = col_integer(),
measure_name = col_character(),
location_id = col_integer(),
location_name = col_character(),
sex_id = col_integer(),
sex_name = col_character(),
age_id = col_integer(),
age_name = col_character(),
cause_id = col_integer(),
cause_name = col_character(),
rei_id = col_integer(),
rei_name = col_character(),
metric_id = col_integer(),
metric_name = col_character(),
year = col_integer(),
val = col_double(),
upper = col_double(),
lower = col_double()
)
dta
glimpse(dta)
Observations: 501,900
Variables: 18
$ measure_id <int> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ...
$ measure_name <chr> "DALYs (Disability-Adjusted Life Years)", "DALYs (Disability-Adjusted Life Years)", "DA...
$ location_id <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
$ location_name <chr> "Global", "Global", "Global", "Global", "Global", "Global", "Global", "Global", "Global...
$ sex_id <int> 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, ...
$ sex_name <chr> "Male", "Female", "Male", "Female", "Male", "Female", "Male", "Female", "Male", "Female...
$ age_id <int> 1, 1, 1, 1, 1, 1, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 2...
$ age_name <chr> "Under 5", "Under 5", "Under 5", "Under 5", "Under 5", "Under 5", "All Ages", "All Ages...
$ cause_id <int> 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 29...
$ cause_name <chr> "All causes", "All causes", "All causes", "All causes", "All causes", "All causes", "Al...
$ rei_id <int> 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 16...
$ rei_name <chr> "Occupational exposure to silica", "Occupational exposure to silica", "Occupational exp...
$ metric_id <int> 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, ...
$ metric_name <chr> "Number", "Number", "Percent", "Percent", "Rate", "Rate", "Number", "Number", "Percent"...
$ year <int> 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 1990, 199...
$ val <dbl> 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 1.0...
$ upper <dbl> 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 1.4...
$ lower <dbl> 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 5.9...
The _id suffix columns can be used to join to the lookup tables. In this case for risk (by rei_id)
lookup <- readxl::read_excel("raw_data/IHME_GBD_2016_CODEBOOK/IHME_GBD_2016_REI_HIERARCHY_Y2018M04D26.XLSX")
lookup
glimpse(lookup)
Observations: 144
Variables: 5
$ rei_id <dbl> 169, 202, 203, 104, 171, 191, 82, 83, 84, 238, 85, 86, 87, 88, 89, 90, 91, 126, 127, 150, ...
$ rei_name <chr> "All risk factors", "Environmental/occupational risks", "Behavioral risks", "Metabolic ris...
$ parent_id <dbl> 169, 169, 169, 169, 171, 191, 202, 82, 82, 82, 202, 85, 85, 85, 202, 89, 89, 202, 126, 127...
$ level <dbl> 0, 1, 1, 1, 0, 0, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, ...
$ sort_order <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,...
In this example I’ll join then filter only level 1 categories in the rei hierarchy
dta %>%
left_join(lookup) %>%
filter(level == 1) -> dta_lvl1
Joining, by = c("rei_id", "rei_name")
Now to start exploring: age-standardised, global, deaths, by lvl 1 risk factor and gender
dta_lvl1 %>%
filter(measure_name == "Deaths") %>%
filter(location_name == "Global") %>%
filter(age_name == "Age-standardized") %>%
filter(metric_name == "Rate") %>%
filter(cause_name == "All causes") %>%
select(year, sex = sex_name, risk_factor = rei_name, death_rate = val) %>%
ggplot(aes(x = year, y = death_rate, linetype = sex, colour = sex)) +
facet_wrap(~ risk_factor) +
geom_line()
Now to do the same by SDI
dta_lvl1 %>%
filter(measure_name == "Deaths") %>%
filter(location_name != "Global") %>%
filter(age_name == "Age-standardized") %>%
filter(metric_name == "Rate") %>%
filter(cause_name == "All causes") %>%
select(year, sex = sex_name, sdi = location_name, risk_factor = rei_name, death_rate = val) %>%
mutate(sdi = stringr::str_replace(sdi, " SDI", "")) %>%
mutate(sdi = factor(sdi, levels = c("Low", "Low-middle", "Middle", "High-middle", "High"), ordered = T)) %>%
ggplot(aes(x = year, y = death_rate, linetype = sex, colour = sex)) +
facet_grid(risk_factor ~ sdi) +
geom_line()
And now let’s see what this implies for relative inequalities
dta_lvl1 %>%
filter(measure_name == "Deaths") %>%
filter(location_name != "Global") %>%
filter(age_name == "Age-standardized") %>%
filter(metric_name == "Rate") %>%
filter(cause_name == "All causes") %>%
select(year, sex = sex_name, sdi = location_name, risk_factor = rei_name, death_rate = val) %>%
mutate(sdi = stringr::str_replace(sdi, " SDI", "")) %>%
mutate(sdi = factor(sdi, levels = c("Low", "Low-middle", "Middle", "High-middle", "High"), ordered = T)) %>% spread(sex, death_rate) %>% mutate(ratio = Male / Female) %>%
ggplot(aes(x = year, y = ratio, colour = risk_factor)) +
geom_line() +
facet_grid(. ~ sdi) +
geom_hline(yintercept = 1)
Let’s look at the contribution of different risk factors to DALY difference
dta_lvl1 %>%
filter(measure_name == "DALYs (Disability-Adjusted Life Years)") %>%
filter(location_name != "Global") %>%
filter(cause_name == "All causes") %>%
filter(age_name == "Age-standardized") %>%
filter(metric_name == "Rate") %>%
select(year, sex = sex_name, sdi = location_name, risk_factor = rei_name, daly_rate = val) %>%
mutate(sdi = stringr::str_replace(sdi, " SDI", "")) %>%
mutate(sdi = factor(sdi, levels = c("Low", "Low-middle", "Middle", "High-middle", "High"), ordered = T)) %>%
ggplot(aes(x = year, y = daly_rate, fill = risk_factor), colour = "black") +
geom_area() +
facet_grid(sdi~sex)
Now proportion of all DALYs attributable to each risk factor by year and SDI
dta_lvl1 %>%
filter(measure_name == "DALYs (Disability-Adjusted Life Years)") %>%
filter(location_name != "Global") %>%
filter(cause_name == "All causes") %>%
filter(age_name == "Age-standardized") %>%
filter(metric_name == "Rate") %>%
select(year, sex = sex_name, sdi = location_name, risk_factor = rei_name, daly_rate = val) %>%
mutate(sdi = stringr::str_replace(sdi, " SDI", "")) %>%
mutate(sdi = factor(sdi, levels = c("Low", "Low-middle", "Middle", "High-middle", "High"), ordered = T)) %>%
group_by(year, sex, sdi) %>%
mutate(total = sum(daly_rate)) %>%
mutate(proportion_total = daly_rate / total) %>%
ungroup() %>%
ggplot(aes(x = year, y = proportion_total, fill = risk_factor), colour = "black") +
geom_area() +
facet_grid(sdi~sex)
Now proportion of total deaths
by_factor <- dta_lvl1 %>%
filter(measure_name == "Deaths") %>%
select(-measure_name, -measure_id) %>%
filter(location_name != "Global") %>%
filter(age_name == "Age-standardized") %>%
filter(metric_name == "Rate") %>%
filter(cause_name == "All causes") %>%
select(year, sex = sex_name, sdi = location_name, rei = rei_name, rate = val) %>% mutate(sdi = stringr::str_replace(sdi, " SDI", "")) %>%
mutate(sdi = factor(sdi, levels = c("Low", "Low-middle", "Middle", "High-middle", "High"), ordered = T))
overall <- dta %>%
filter(rei_name == "All risk factors") %>%
filter(measure_name == "Deaths") %>%
select(-measure_name, -measure_id) %>%
filter(location_name != "Global") %>%
filter(age_name == "Age-standardized") %>%
filter(metric_name == "Rate") %>%
filter(cause_name == "All causes") %>%
select(year, sex = sex_name, sdi = location_name, rei = rei_name, rate = val) %>% mutate(sdi = stringr::str_replace(sdi, " SDI", "")) %>%
mutate(sdi = factor(sdi, levels = c("Low", "Low-middle", "Middle", "High-middle", "High"), ordered = T))
joined <- bind_rows(by_factor, overall)
rm(by_factor, overall)
Unfortunately it seems ‘all risk factors’ is not the same as ‘total’, i.e. the absolute differences in age-standardised death rates from each of the three level 1 risk factors do not add up to the ‘all risk factors’ absolute difference
joined %>%
spread(sex, rate) %>%
mutate(abs_diff = Male - Female) %>%
group_by(year, sdi) %>%
mutate(perc_of_abs_diff = 100 * abs_diff / abs_diff[rei=="All risk factors"]) %>%
summarise(discrepancy = sum(perc_of_abs_diff[rei != "All risk factors"]) - 100) %>%
ungroup() %>%
ggplot(aes(x = year, y = discrepancy, colour = sdi)) +
geom_line()
So, the risk factors might not be mutually exclusive and exhaustive. Let’s take middle SDI in 2000 as an example
joined %>%
filter(sdi == "Middle") %>%
filter(year == 2000) %>%
spread(sex, rate) %>%
mutate(abs_diff = Male - Female) %>%
group_by(year, sdi) %>%
mutate(perc_of_abs_diff = 100 * abs_diff / abs_diff[rei=="All risk factors"])
So, the total of the three bottom rows adds up to around 160, when I might expect them to add to 100. A simple decomposition assumption doesn’t seem to apply when using the ‘all risk factors’ designation as total.
To try to account for this let’s look at a different dataset, with:
Let’s try to grab this data with a new query
The query link is here.
url_body <- "http://s3.healthdata.org/gbd-api-2016-production/c9bf1a5197bf46a966c1467c3103e8a9_files"
url_head <- "IHME-GBD_2016_DATA-c9bf1a51-"
outdir <- "raw_data/rate_all_cause"
download_completed_request(url_body, url_head, outdir, flush = T)
And now to load this file
dta_total <- read_csv("raw_data/rate_all_cause/1.csv")
Parsed with column specification:
cols(
measure = col_character(),
location = col_character(),
sex = col_character(),
age = col_character(),
cause = col_character(),
metric = col_character(),
year = col_integer(),
val = col_double(),
upper = col_double(),
lower = col_double()
)
by_factor <- dta_lvl1 %>%
filter(measure_name == "Deaths") %>%
select(-measure_name, -measure_id) %>%
filter(location_name != "Global") %>%
filter(age_name == "Age-standardized") %>%
filter(metric_name == "Rate") %>%
filter(cause_name == "All causes") %>%
select(year, sex = sex_name, sdi = location_name, rei = rei_name, rate = val) %>% mutate(sdi = stringr::str_replace(sdi, " SDI", "")) %>%
mutate(sdi = factor(sdi, levels = c("Low", "Low-middle", "Middle", "High-middle", "High"), ordered = T))
overall <- dta_total %>% filter(location != "Global") %>% mutate(rei = "total") %>% mutate(sdi = stringr::str_replace(location, " SDI", "")) %>%
mutate(sdi = factor(sdi, levels = c("Low", "Low-middle", "Middle", "High-middle", "High"), ordered = T)) %>% select(year, sex, sdi, rei, rate = val)
Let’s see if the totals add up this time. The three level 1 risk factors are shown as stacked areas, and the total is shown as a black line…
by_factor %>%
ggplot(aes(x = year, y = rate, fill = rei)) +
geom_area() +
facet_grid(sex ~ sdi) +
geom_line(aes(x = year, y = rate), inherit.aes = F, data = overall)
So, there is still discrepancy, which seems to be largest for low SDI, and smallest for high-middle SDI, but this might be decomposable subject to some assumptions.
Let’s now compare with previous attempt at an ‘overall’ estimate (based on ‘all risk factors’). In the following this is added as a black dashed line. We might expect the dashed and solid lines to be the same, but are they?
overall2 <- dta %>%
filter(rei_name == "All risk factors") %>%
filter(measure_name == "Deaths") %>%
select(-measure_name, -measure_id) %>%
filter(location_name != "Global") %>%
filter(age_name == "Age-standardized") %>%
filter(metric_name == "Rate") %>%
filter(cause_name == "All causes") %>%
select(year, sex = sex_name, sdi = location_name, rei = rei_name, rate = val) %>% mutate(sdi = stringr::str_replace(sdi, " SDI", "")) %>%
mutate(sdi = factor(sdi, levels = c("Low", "Low-middle", "Middle", "High-middle", "High"), ordered = T))
by_factor %>%
ggplot(aes(x = year, y = rate, fill = rei)) +
geom_area() +
facet_grid(sex ~ sdi) +
geom_line(aes(x = year, y = rate), inherit.aes = F, data = overall) +
geom_line(aes(x = year, y = rate), inherit.aes = F, data = overall2, linetype = "dashed")
So, there are clear differences between age-standardised rates drawn from all causes (solid line), and age-standardised rates drawm from all risk factors (dashed lines), with the latter below the former. Again, this raises questions about how to perform a decomposition into risk factors, the effect of age-standardization, and so on.
Let’s not use level 0 for decomposing level 1 etc, and instead just produce estimates of total by summing up level 1 risks. Then, do the same for level 2.
contributions <- by_factor %>%
inner_join(
by_factor %>%
group_by(year, sex, sdi) %>%
summarise(total_rate = sum(rate)) %>%
ungroup()
) %>%
group_by(year, sdi) %>%
mutate(abs_sex_diff = total_rate[sex == "Male"][1] - total_rate[sex == "Female"][1]) %>%
group_by(year, sdi, rei) %>%
mutate(rei_abs_sex_diff = rate[sex == "Male"] - rate[sex == "Female"]) %>%
ungroup() %>%
mutate(contribution = 100 * rei_abs_sex_diff / abs_sex_diff)
Joining, by = c("year", "sex", "sdi")
Now to plot the contribution over time by SDI
contributions %>%
select(year, sex, sdi, rei, contribution) %>%
distinct() %>%
ggplot(aes(x = year, y= contribution, colour = rei)) +
geom_line() +
facet_wrap(~sdi)
Let’s think again about how to present this in the case of three risk factors, such that it could be scaled up to more factors
by_factor %>%
spread(sex, rate) %>%
mutate(diff_abs = Male - Female) %>%
group_by(year, sdi) %>%
mutate(diff_cumulative = cumsum(diff_abs)) -> cumulative_contributions
Now to plot for two years, 1990 and 2010
# use geom_segement
cumulative_contributions %>%
filter(year %in% c(1990, 2010)) %>%
mutate(start_pos = diff_cumulative - diff_abs) %>%
mutate(is_increasing = diff_cumulative > start_pos) %>%
group_by(year, sdi) %>%
mutate(max_cumulative = diff_cumulative[length(diff_cumulative)]) %>%
ungroup() %>%
ggplot(aes(x = start_pos, xend = diff_cumulative, y = rei, yend = rei, colour = is_increasing)) +
geom_segment( arrow = arrow(length = unit(0.2, "npc"))) +
facet_grid(sdi ~ year) +
geom_vline(xintercept = 0) +
geom_vline(aes(xintercept = max_cumulative), linetype = "dashed") +
guides(colour = FALSE) +
labs(x = "Gender difference in rates", y = "Risk factors (level 1)", title = "Contribution of risk factors to gender differences in all-cause mortality rates", subtitle = "Age-standardised rates per 100 000", caption = "Source: GBD")
ggsave("figures/contribution_of_level1_riskfactors_death_rate.png", height = 30, width = 30, units = "cm", dpi = 300)
This seems to work as a visualisation. Let’s try to scale up to level 2
by_factor_l2 <- dta %>%
left_join(lookup) %>%
filter(level == 2) %>%
filter(measure_name == "Deaths") %>%
select(-measure_name, -measure_id) %>%
filter(location_name != "Global") %>%
filter(age_name == "Age-standardized") %>%
filter(metric_name == "Rate") %>%
filter(cause_name == "All causes") %>%
select(year, sex = sex_name, sdi = location_name, rei = rei_name, rate = val) %>% mutate(sdi = stringr::str_replace(sdi, " SDI", "")) %>%
mutate(sdi = factor(sdi, levels = c("Low", "Low-middle", "Middle", "High-middle", "High"), ordered = T))
Joining, by = c("rei_id", "rei_name")
by_factor_l2 %>%
spread(sex, rate) %>%
mutate(diff_abs = Male - Female) %>%
group_by(year, sdi) %>%
mutate(diff_cumulative = cumsum(diff_abs)) %>%
filter(year %in% c(1990, 2010)) %>%
mutate(start_pos = diff_cumulative - diff_abs) %>%
mutate(is_increasing = diff_cumulative > start_pos) %>%
group_by(year, sdi) %>%
mutate(max_cumulative = diff_cumulative[length(diff_cumulative)]) %>%
ungroup() %>%
ggplot(aes(x = start_pos, xend = diff_cumulative, y = rei, yend = rei, colour = is_increasing)) +
geom_segment( arrow = arrow(length = unit(0.05, "npc"))) +
facet_grid(sdi ~ year) +
geom_vline(xintercept = 0) +
geom_vline(aes(xintercept = max_cumulative), linetype = "dashed") +
guides(colour = FALSE) +
labs(x = "Gender difference in rates", y = "Risk factors (level 2)", title = "Contribution of risk factors to gender differences in all-cause mortality rates", subtitle = "Age-standardised rates per 100 000", caption = "Source: GBD")
ggsave("figures/contribution_of_level2_riskfactors_death_rate.png", height = 30, width = 30, units = "cm", dpi = 300)
This seems to work pretty well though is perhaps at the limit of visual complexity. More time periods etc would likely make this image too busy.