Skip to content
Reproducible code for our BMJ Open 2019 paper
R Stan
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Decomposition of the US black/white inequality in premature mortality, , 2010–2015: an observational study


Code for our BMJ Open paper “Decomposition of the US black/white inequality in premature mortality, 2010–2015: an observational study”. This paper uses joint Bayesian spatial models with restricted-access compressed mortality data to estimate and decompose black/white inequalities in premature mortality. The full citation is:

Kiang MV, Krieger N, Buckee CO, Onnela JP, & Chen JT, Decomposition of the US black/white inequality in premature mortality, 2010–2015: an observational study, BMJ Open (December 2019), doi: 10.1136/bmjopen-2019-029373


Please submit issues via Github or via email.

Important note about reproducibility

Due to limitations on sharing the restricted-access data, this pipeline is not fully reproducible. To reproduce the pipeline, you must have the restricted-access compressed mortality files and the accompanying population estimates. Specify the path to these files in the 04_extracting_cmf_data.R script in lines 64 and 72.


Since completion of this project, there have been significant advances in the underlying software packages. For example, stan now allows for parallel processing within a single chain, which should substantially reduce computation time. In addition, there has been significant development in estimating a spatial conditional autoregressive using stan (e.g., cor_car() in the brms package). Members of the stan team themselves have published an example that did not exist when this project was underway.

All that to say, this code should be considered a starting point for future project development. Modernizing the code used in this project will likely decrease the computational burden substantially.


Restricted-access compressed mortality files

Request access to the compressed mortality files through the National Center for Health Statistics.


All analyses are conducted using R.

Analysis pipeline

The code is made to be run in sequential order.

Intermediate, publicly-available files (e.g., the ACS variables and shapefiles) are included, so you should not need to update config.yml. However, if you want to use other ACS variables, or start from scratch, you will need to request an API key from the US Census Bureau and put it in the config.yml file. See ./config.yml for descriptions of project-wide parameters that can be modified.

Code files beginning with 50_ were used internally for diagnostic purposes but not included in the final manuscript.


Special thanks to Max Joseph who freely provided his stan conditional autoregressive code online (doi: 10.5281/zenodo.210407).

Interested readers should see his official stan case study, another ICAR stan case study here, and a paper using ICAR by members of the stan team.


You can’t perform that action at this time.