Skip to content

mwaugh0328/heterogeneous-agent-trade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HAT: Heterogeneous Agent Trade

This repository contain code associated with the paper Heterogeneous Agent Trade. Please let me know of any problems.


What is HAT?

HAT is a model where aggregate trade arises from the explicit aggregation of household-level decisions.

Households live lives similar to the "standard incomplete markets model" where agents face to idiosyncratic productivity and taste shocks (a new part) and have access to a risk free asset. Trade in goods follows the Armington tradition with producers in each country producing a national variety.

The twist is that I do not employ modeling techniques with aggregation at the household level across national varieties, and instead I have households make discrete choices over the varieties they consume in addition to their savings decisions. The explicit aggregation of household-level decisions then determines aggregate trade flows, trade elasticities, and the gains from trade.

I view HAT as a new way to think about the distributional affects of trade reforms, their dynamics, and complementary policies to mitigate the downsides of globalization.

HAT also provides a laboratory where there is non-trivial connection between international trade and finance. Issues such as sequencing of reforms (trade or capital account first) and the value of those reforms, the distributional issues of those reforms are all natural questions to ask of this framework. I might get to it one day.


How?

The goal here is to provide code and informative notebooks to illustrate how things work.

The base code is in julia with the goal of implementing things using transparent and well developed methods. Most the notation in the code tries to closely follow the paper. In the repository there are also python versions of the code. Results are plotted in jupyter notebooks (python).

Replicating results in the paper.

  • two-country.ipynb is a jupyter notebook (julia) that computes a symmetric two country model and illustrates how everything works. Figure 1a and Figure 1b are created from this files output and it is plotted in a jupyter notebook (python) in plot-micro-elasticity.ipynb.

  • calibrate-gravity-as-guide.jl is one of the main driver files used to calibrate the model as described in the paper. This does takes time and resources.

  • calibrate-all.jl is an alternative and much faster approach to calibrating the model. It looks for a parameter vector and a vector of wages and an interest rate that satisfies (i) the moment conditions and (ii) that markets clear, all in one step. It is, however, far more sensitive to the initial guess for parameters and prices.

  • coumpute-baseline.jl generates moments from the EK data set, takes in calibrated parameter values, and computes a world equilibrium. Outcomes are then compared to the data, i.e., plot trade in the model vs. the data Figure 2, the trade elasticities Figure 3, and micro moments are reported. The plotting file is plot-calibration.ipynb.

  • coumpute-baseline-log.jl same thing as above, but for the log preference case.

  • log-model.ipynb is a jupyter notebook that runs through a two country example with log preferences and illustrates how the model collapses to a constant elasticity model. The jupyter notebook (python) plot-micro-elasticity-log.ipynb plots the results.

  • coumpute-welfare.jl computes the baseline, the counterfactual equilibrium with a unilateral reduction of trade costs by 10 percent, then constructs welfare measures, and saves the results. The -log version does the same for the log preference model. The jupyter notebook (python) plot-welfare.ipynb plots the results Figure 4.

  • coumpute-welfare-global.jl computes the baseline, the counterfactual equilibrium with a global reduction of trade costs by 10 percent, then constructs welfare measures, and saves the results. The -log version does the same for the log preference model. The jupyter notebook (python) plot-welfare-global.ipynb plots the results Figure 5.

More about the code.

Here are core elements of the code (more detailed descriptions to be provided in the coming weeks):


Want to know more?

Much of this is a continuation of my thinking across several papers that connect models of household heterogeneity with trade:


Support and Disclaimers

This project was developed with research support from the National Science Foundation (NSF Award number 1948800).

The views expressed herein are those of the author and not necessarily those of the Federal Reserve Bank of Minneapolis or the Federal Reserve System.

About

HAT: Heterogeneous Agent Trade

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published