Supplemental Materials for "The Macroeconomic Impact of NAFTA Termination”
Joseph Steinberg, University of Toronto
This document describes the source data and computer programs used to create the results in Canadian Journal of Economics Manuscript 201842, “The Macroeconomic Impact of NAFTA Termination.” These supplementary materials contain all of the files necessary to replicate the analysis in the paper. Section 1 describes the source data. Section 2 describes the Python scripts used to process and analyze the data, and the scripts that create the tables and figures that contain empirical results. Section 3 describes the C program used to calibrate and solve the model. Section 4 describes the Python scripts that create the tables and figures that contain model results.
The raw data described below are contained in the data folder of the supplementary materials. 1. Data
The 2016 release of the World Input Output Database is comprised of 15 Stata data files, each of which contains a world input-output matrix for a given year. Each file lists gross output, intermediate input usage, and final demand for 43 countries and 56 industries. For more information on the construction of the WIOD, see 1.1 World Input Output Databasehttp://www.wiod.org/release16. I use only the 2014 data in this project, so I include only the input-output matrix for that year in this supplement. The file is WIOT2014_October16_ROW.dta.
The file wto_mfn_tariffs_nafta_2014_hs12.csv, which was downloaded from the WTO website, contains each NAFTA country’s MFN average applied tariff at the 6-digit HS 2012 level. 1.2 MFN tariffs from 2014
The file trains_data_extract.csv, which was downloaded from the TRAINS online database, contains bilateral average applied tariffs for each of the 6 NAFTA import relationships (USA-MEX, USA-CAN, MEX-USA, MEX-CAN, CAN-USA, CAN-MEX) at the 6-digit HS 2012 level. 1.3 Bilateral tariffs from 1993
The file comtrade_nafta_2014_hs12.csv, which was downloaded from the COMTRADE website, contains bilateral goods trade flows for each of the 6 NAFTA import relationships for the year 2014 at the 6-digit HS 2012 level. 1.4 Bilateral trade flows from 2014 (HS 2012 version)
The file comtrade_nafta_2014_hs96.csv, which was downloaded from the COMTRADE website, contains bilateral goods trade flows for each of the 6 NAFTA import relationships for the year 2014 at the 6-digit HS 1996 level. This second version of the COMTRADE data is required to compute sector-level pre-NAFTA tariffs because the TRAINS data from 1993 uses the 1996 version of the HS classification system. 1.5 Bilateral trade flows from 2014 (HS 1996 version)
All of the Python scripts described in this section are contained in the folder programs/python in the supplementary materials. They require the Python version 2 codebase, along with the NumPy, SciPy, and Matplotlib libraries. The output of these scripts is stored in the programs/python/output folder. Some of these scripts (namely 2.1) produce intermediate files that are used by other scripts (these files are also contained in the supplement). Thus, script 2.1 must be run first before running the other scripts in this section. 2. Python scripts (empirical)
This script processes the raw WIOD data (item 1.1) aggregating industries according to the specification in Table 1 and aggregating all non-NAFTA countries into a single rest of the world. The aggregated data are saved to three pickle files, wiod_m.pik, wiod_f.pik, wiod_vg.pik, that contain intermediate inputs, final demand, and gross output/value added, respectively. 2.1 wiod_preproc.py
This script loads the pickle files created by 2.1 and uses them to create a LaTeX file that contains Table 3 (key_facts.tex). 2.2 table_wiod_key_facts.py
This script loads the pickle files created by 2.1 and uses them to create Figures 1 through 3 (fig1_bilateral_trade.pdf, fig2_sectoral_trade.pdf, fig3_trade_balances.pdf). 2.3 plots_data.py
This script loads the pickle files created by 2.1 and uses them to create an aggregated input-output matrix that is used as an input to the C program that solves the model (see section 3). This input file is called iomat.txt. 2.4 iomat.py
This script loads the HS-6 level tariff and trade data (items 1.3–1.5), merges them, and creates LaTeX files that contain Table 2 (tariffs.tex, which contains sector-level MFN tariffs on trade between NAFTA countries) and Table 7 (tariffs_old.tex, which contains sector-level tariffs on trade between NAFTA countries based on bilateral applied tariffs from 1993). This script also creates text files that are used as inputs to the C program: tariffs.txt (the baseline tariffs); tariffs_alt1.txt (sensitivity analysis with increased U.S. protectionism); and tariffs_old.txt (pre-NAFTA tariffs). 2.5 table_tariffs.py
This script loads the raw, disaggregated WIOD data (item 1.1), and uses them to compute sectoral the trade elasticities shown in panel (b) of Table 4. This script simply prints output to the screen; the user must manually type the output into the LaTeX file for the table (assigned_params.tex). 2.6 elasticities.py
The general equilibrium model described in section 3 and calibrated in section 4 is solved using a computer program written in C. This program is contained in the folder programs/c. The source code is contained in the folder programs/c/src. The binary executable, which is created by compiling the program, is contained in the folder programs/c/bin. The output of the program, which is created by running the executable, is contained in the folder programs/c/output. 3. C program
In addition to the standard C codebase, this program requires the GNU gcc compiler (https://gcc.gnu.org/), the GNU GSL library (https://www.gnu.org/software/gsl/), OpenMP (https://www.openmp.org/), and the Intel Math Kernel Library (https://software.intel.com/en-us/mkl). I used the Ubuntu 16.04 Linux distribution to compile and run the program, and I cannot guarantee that the program will work without modifications in Windows or other operating systems.
The program uses OpenMP parallelization to evaluate the Jacobian matrix of the equilibrium system, and a computer with a large number of cores is required to run the program in a reasonable amount of time. The program also requires a large amount of memory to store this matrix and other program objects; the memory requirement depends on the number of threads used in the program. I used a 40-core Xeon workstation and the program required about 12 GB of RAM.