Scripts to reproduce figures and tables of paper:
Alburez-Gutierrez, D., Kolk, M. and Zagheni E. (2021). Women's experience of child death: A global demographic perspective. Demography. DOI:10.1215/00703370-9420770.
The directory R
has five sub-directories, which are needed to transform the data to the right format, produce the model estimates
, produce the figures and tables from the main text, and create the resources for the SI Appendix. They are:
Each directory in R
has the same structure, which includes:
- An R project prefaced by
___
(e.g.___A_Data_formatting.Rproj
) - A script called
__run_code.R
which should be used to execute all scripts in the directory - Several R scripts ordered numerically.
In order to run the code, please do the following:
- Download this repository as a zip file and extract its content
- Open the
R/A_Data_formatting
directory in order to start with the data wrangling - Open the
___A_Data_formatting.Rproj
R project in RStudio - Open the
__run_code.R
script and run the code line by line to execute all the scripts in the directory - When finished, exit RStudio
- Repeat for the other directories in
R
.
The final results of the analysis are stored in the Output
directory, including the figures as .pdf files and full country and regional estimates.
This repository already includes all the raw data needed to reproduce the results. UN World Population Prospect data was downloaded by hand in advance and stored in the Data/wpp_data directory. All data come from: https://population.un.org/wpp/Download/, downloaded on 14 October 2019. See the Supporting Information for more details about the data and estimation.
If possible, the R scripts in the A_Data_formatting directory (used to re-format the UN WPP data) should be run on a High Performance Computing (HPC) unit as they involve many calculations. These would take many hours in a normal PC, but under one hour on a HPC running multiple cores.
The code to reproduce the Shiny app to visualize the results is in the directory Shiny. The app can be accessed using this link.
I ran the scripts on a Windows server:
> sessionInfo()
R version 3.6.0 Patched (2019-06-11 r76697)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server >= 2012 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] directlabels_2018.05.22 gridExtra_2.3 scales_1.0.0 reshape2_1.4.3 data.table_1.12.2 forcats_0.4.0
[7] stringr_1.4.0 dplyr_0.8.2 purrr_0.3.2 readr_1.3.1 tidyr_0.8.3 tibble_2.1.3
[13] ggplot2_3.2.0 tidyverse_1.2.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 plyr_1.8.4 cellranger_1.1.0 pillar_1.4.2 compiler_3.6.0 tools_3.6.0 digest_0.6.19 jsonlite_1.6
[9] lubridate_1.7.4 gtable_0.3.0 nlme_3.1-140 lattice_0.20-38 pkgconfig_2.0.2 rlang_0.4.0 cli_1.1.0 rstudioapi_0.10
[17] yaml_2.2.0 haven_2.1.0 withr_2.1.2 xml2_1.2.0 httr_1.4.0 generics_0.0.2 hms_0.4.2 grid_3.6.0
[25] tidyselect_0.2.5 glue_1.3.1 R6_2.4.0 readxl_1.3.1 modelr_0.1.4 magrittr_1.5 backports_1.1.4 rvest_0.3.4
[33] assertthat_0.2.1 colorspace_1.4-1 labeling_0.3 quadprog_1.5-7 stringi_1.4.3 lazyeval_0.2.2 munsell_0.5.0 broom_0.5.2
[41] crayon_1.3.4