Skip to content

korenmiklos/Diversification-Through-Trade-Replication

Repository files navigation

Replication Data for: 'Diversification Through Trade'

Citation and License

Please cite as

Caselli, Francesco, Miklós Koren, Milan Lisicky and Silvana Tenreyro, 2020. “Replication data for: Diversification through Trade.” Quarterly Journal of Economics. 135(1), pp. 449-502. https://doi.org/10.1093/qje/qjz028

The software provided here (.jl and .ipynb files) is licensed under licensed under a Creative Commons Attribution 4.0 International License. To use the data provided in the data folder, please check the license terms of the original data vendors.

Data Availability Statements

Data are from the following sources.

Sample Definition

The core sample of countries include the United States, Mexico, Canada, Australia, China, Japan, South Korea, India, Colombia, the United Kingdom, a composite of France and its overseas departments, Germany, Italy, Spain, Portugal, a composite of Belgium and Luxembourg, the Netherlands, Finland, Sweden, Norway, Denmark, Greece, Austria and Ireland. Other countries are merged as "Rest of the World."

The data are disaggregated into 24 sectors: agriculture (including mining and quarrying), 22 manufacturing sectors, and services, all available in US dollars for the core countries and the Rest of the world (ROW). The 22 manufacturing sectors correspond to the industries numbered 15 to 37 in the ISIC Rev. 3 classification (36 and 37 are bundled together).

The final dataset is obtained by combining different sources and some estimation. The details are described in the Appendix of Caselli, Koren, Lisicky and Tenreyro (2019). The input data is stored, in comma delimited format, in the data folder.

Computational Requirements

Software Requirements

  • Operating system: Max OS X or Linux.
  • Julia (version 0.6.4)
    • JLD2 (version 0.0.6)
    • CSV (version 0.2.5)
    • DataFrames (version 0.11.7)
    • Plots (version 0.17.4)
    • Missings (version 0.2.10)
    • HypothesisTests (version 0.7.0)
    • Distributions (version 0.15.0)
    • Formatting (version 0.3.5)
    • Logging (version 0.3.1)

The necessary Julia packages are installed by install.jl or make install.

Memory and Runtime Requirements

Both Julia and Make can run in parallel. Computing the equilibrium for a given set of parameters takes about 1 minute on a single 3.8GHz CPU core. Each period's equilibrium can be computed in parallel (in Julia) and each scenario can be computed in parallel (in Make). With 44 scenarios (see below) and 36 time periods, total run time should be about 1600 minutes.

Instructions

The Makefile runs all the necessary computations in the correct order. If you want to reproduce the tables in our paper, run make or make tables. The Makefile is set to run 2 Julia threads in parallel (PROCS = -p2). If you have more cores, set PROCS accordingly. You can then run Make jobs in parallel with make -j4 tables.

To run the code in an AWS EC2 instance, follow the steps in notebooks/aws-recipe.md. You need to launch an instance from an EC2 image with Julia 0.6 preinstalled.

The core logic is in two files.

  • equilibrium.jl calculates the equilibrium prices and quantities given a set of parameters.
  • calibrate_params.jl calibrates parameters to match a set of data moments.

These modules are called by each scenario to be computed. An experiment is a set of common parameters applied to our economy before calibration. For example, theta=4 is an experiment and so is theta=8. A scenario is a particular (often counterfactual) parametrization of an experiment. For example, given calibrated trade costs kappa, a scenario might reset those to their 1972 value.

As an example, consider the following two scenarios: experiments/CES2/actual/scenario.jl and experiments/CES2/kappa1972/scenario.jl. They belong to the same experiment, experiments/CES2, which calibrates its parameters after setting sigma=2 in experiments/CES2/init_parameters.jl.

The actual scenario does not change any of the calibrated parameters. The kappa1972 scenario replaces all kappa with the 1972 values in the same country and sector (see experiments/CES2/kappa1972/change_parameters.jl).

The results of each run are saved in results.jld2 (a JLD2 Julia file format) in the scenario folder, such as experiments/CES2/kappa1972/results.jld2. Most of our tables require comparisons of four scenarios (with and without trade cost changes, with and without sectoral shocks). These tables are saved in the experiment folder, such as experiments/CES2/output_table.csv.

Algorithm

The calibration algorithm is described in Section III in the paper. The equilibrium solution algorithm is described in Section II.B. The basic outline of the equilibrium solution can be described by four nested loops.

  • The outer loop solves for equilibrium labor shares, given expected wages. Expectations are taken over S possible realizations of future productivity shocks.
  • The adjustment loop solves for equilibrium deviations from pre-decided labor shares, in response to shocks to productivity. This only runs when labor adjustment costs are finite, otherwise labor shares remain at their preassigned value.
  • The middle loop solves for the equilibrium sectoral expenditure shares using resource constraints and market clearing conditions.
  • The inner loop solves for the equilibrium intermediate goods prices across countries, given a fixed set of sectoral expenditure shares. The rest of the prices can be computed algebraically.

Data Structures

All parameters are stored in the dictionary parameters. Parameters can vary by m (destination country), n (source country), j (sector) and t (time). They are stored in a 4-dimensional array with indexes (m,n,j,t). If a certain dimension is not relevant for a parameter, that dimension is retained as a singleton dimension. This is to ensure that arrays are conforming to one another in size.

Similarly, all random variables computed in the equilibrium are stored as 4-dimensional arrays with m, n, j and s (state of the world) as indexes. This ensures conformability of variables and easy formulas such as

R_nt = sum(w_njt .* L_njt ./ beta_j, 3)

where the summation is across the third, j, dimension.

Output

Tables and figured are saved in the output folder.

File Exhibit Script
output/Figure2.pdf Figure 2 notebooks/Create Figure 2.ipynb
output/table1.csv Table 1 experiments/baseline
output/table2.csv Table 2 notebooks/Volatility by decade.ipynb
output/table3.csv Table 3 experiments/trade_imbalance
output/table4left.csv Table 4, left panel experiments/theta2
output/table4right.csv Table 4, right panel experiments/theta8
output/table5left.csv Table 5, left panel experiments/rho0005
output/table5center.csv Table 5, center panel experiments/labor_adjustment
output/table5right.csv Table 5, right panel experiments/rho002
output/table6left.csv Table 6, left panel experiments/CES0.5
output/table6right.csv Table 6, right panel experiments/CES1.5
output/table7.csv Table 7 experiments/no_io_linkages
output/table8left.csv Table 8, left panel experiments/no_china
output/table8right.csv Table 8, right panel experiments/china_1972
output/trade_share.pdf Supplementary figure notebooks/Compare scenarios.ipynb

References

About

Caselli, Francesco, Miklós Koren, Milan Lisicky, Silvana Tenreyro. 2020. "Replication Package for Diversification Through Trade." The Quarterly Journal of Economics.

Resources

License

Stars

Watchers

Forks

Packages

No packages published