Overview

This is a fully integrated replication pipeline whose final outcome is the paper manuscript in pdf format.

You can download the replication package here (about 19GB).1

General structure

The main (root) folder contains the following folders:

  • programs/: contains all R and python codes that replicate the results of the paper.

  • inputs/: contains the data inputs used by the replication codes.

  • output/: where all processed data and simulation results are stored.

  • results/: where all results (figures, tables, and other tex results) are stored.

It also contains the JMP_README.html readme (this document).

Replicating the results

The paper is reproduced by executing, in this specific order, the following R and python codes:

  1. data.R: pre-processes all the raw data.

  2. quant.py: performs the quantification of the model as in Section 5.

  3. cfac.py: runs all the counterfactual simulations of Sections 4.2, 5.5, and 6.

  4. results.R: uses the previous inputs to reproduce all figures and tables of the paper. It also renders the .tex source file of the paper, producing the manuscript in .pdf format.

Inputs

The set of inputs (data and code/subroutines) required by 1-4 are:

Data:

  • inputs/conte-etal-2021/: global temperature data from Conte et al. (2021).
  • inputs/faostat-agric-prod/: country-crop-level agricultural production in US$ from FAOSTAT.
  • inputs/gaez/: raw GAEZ data (IIASA and FAO, 2012) on attainable/potential yields (for several crops, time periods, and technology assumptions), effective production, and harvested land by the early 21st century.
  • inputs/gam-friction/: friction surface of the Glabal Access Map/Accessibility to Cities’ project (Weiss et al., 2018).
  • inputs/g-econ-v4/: raw G-Econ data (Nordhaus et al., 2006)
  • inputs/ghsp/: raw gridded population data from the Global Human Settlement Project (Florczyk et al., 2019).
  • inputs/groads/: rasterized African and EU road infrastructure from the gROADS database (CIESIN, 2013).
  • inputs/ipums/: raw internal migration data and time-consistent shapefiles of all countries and subnational regions from IPUMS (2020).
  • inputs/itpd-e-trade/: country-pair-industry-level data on trade flows from the ITPD-E database (Borchert et al., 2021).
  • inputs/mig-data-abel-cohen/: country-pair-level data on migration stocks and gross flows from Abel and Cohen (2019).
  • inputs/ne_50m_admin_0_countries/: shapefile of the world (ADM0) from Natural Earth Data.
  • inputs/ne_50m_lakes/: shapefile of all lakes in the world from Natural Earth Data.
  • inputs/ne_10m_populated_places_simple/: shapefiles of all populated places in the world from Natural Earth Data.
  • inputs/ne_10m_ports/: shapefile of all ports and harbors in the world from Natural Earth Data.
  • inputs/other/aoi2.rdata: SSA’s shape in .rdata format (used to render maps).
  • inputs/other/exchange_rates.rdata: exchange rates for SSA country currencies and USD.
  • inputs/other/otherlists.rdata: inputs for the whichCountry() function (in loadfunctions.R).
  • inputs/un-pop-data/: cleaned .xls with estimates of future national populations from United Nations and Social Affairs (2019).
  • inputs/wb-va-agric/: country-level agricultural value added from the World Bank Development Indicators.
  • inputs/wb-gdp-pc/: country-level GDP per capita growth from the World Bank Development Indicators.
  • inputs/wfp-vam/: geocoded crop price data from the WFP-VAM program.

Paper:

  • inputs/tex-paper/JMP_brunoconte.tex: source of the manuscript in .tex format.
  • inputs/tex-paper/00preamb.tex: .tex preamble of manuscript (packages, commands, etc).
  • inputs/tex-paper/00appendix.tex: source of the appendix in .tex format.
  • inputs/tex-paper/00bib.tex: .tex file that calls the bibligraphy of the paper.
  • inputs/tex-paper/00bib.bib: bibtex-format of all cited references in the paper.
  • results/figures/rcp_sres_comparison*.png: figures from IPCC (2012) that is used in the Appendix.

Auxiliary programs and files:

  • programs/loadfunctions.R: loads several functions used to process data (e.g. distance-calculating algorithms).
  • programs/model_2024.py: contains all functions of the model (Section 4.1). It is used by quant.py and cfac.py.
  • programs/model_line.py: contains the functions and the simulation codes of the economy represented in a line (in Section 4.2).

Processing data and preparing model inputs (data.R)

The code data.R runs all data-processing tasks – make sure to set the right working and temporary directories in lines 16-17.2 It consists of a sequence of 15 code slices that run for different cty geographical regions in an outer loop.3

The outcome is exported to data/outputs/*/ to be subsequently used as inputs in the model (note that * stands for region cty; e.g., SSA is defined as ssa_2023).

Quantifying the model (quant.py)

The quant.py code links the model to the data as in Section 5. It requires a number of libraries (e.g., numpy) installed within the local python IDE.7 As with quant.py, it loops over several regions (called, in this case, country), executing:

Counterfactuals (cfac.py)

The cfac.py code uses the inputs from the previous tasks to run and export the outputs of ALL counterfactual simulations. It loops over several cty regions for different scenarios; it takes about 6-8 hours in a 8-core computer.

Note that, after solving the model for each scenario, the model.export_output() function exports all outcomes in .csv format, in a standardized way and in each simulation’s folder.

Reproducing results and the paper (results.R)

The code results.R processes all of the results and generates all tables, plots, and maps of the paper. Make sure to set the right working and temporary directories in lines 24-25.

Importantly, it extensively uses the functions genAggregateStats() and addToGrid(), which I developed to processes and/or and aggregate the simulation results (in terms of climate change effects) at the SSA and/or country levels.

Finally, results.R compiles the jmp_brunoconte.tex source file. Thus, once concluding all of the previous steps, the replcation package will produce the paper in .pdf format in the root folder.

References


  1. Most of the inputs for the replication are not available because of editorial/copy right issues, but are available upon request.↩︎

  2. Lines 16-21 load the main required R libraries and line 13 sets a TRUE/FALSE for installing ALL the required libaries (in lines 25-46). Make sure to have then all installed from CRAN.↩︎

  3. These “regions” are SSA, the EU, SSA with the rest of the World, or SSA for different models (e.g., with a single crop).↩︎

  4. The grid is created based on G-Econ gridcells with non-zero population. Some coastal/bordering cells are manually removed.↩︎

  5. Specifically, it exports a \(N \times N\) dummy matrix for all \(i,j\) combinations that stand for internal migration choices. Analogously, it exports a \(C \times N \times N\) dummy matrix where every slice along the \(C\) (country) dimension contains dummies for the \(i,j\) combinations that stand for migration into country \(C\).↩︎

  6. For that, it is divided in subsets and computed in parallel. Executed with 6 cores, each cty region requires 4-10 hours.↩︎

  7. These are numpy, timeit, os, pandas, matplotlib, and scipy.↩︎