Data and Code
This page provides links to a number of replication packages, for a number of papers that I co-authored. The code is provided "as is", i.e. with intent to replicate our results and in order to be helpful for researchers interested in using our data / techniques in their own research, with no further commitment from my co-authors or me. The code is usually written in R or Stata, and recently a little bit of Julia. Please when re-using the code and data, refer to the paper with citations listed below.
Head, K. and T. Mayer, 2022, Welfare effects of Balkan trade liberalization through the lens of structural gravity, mimeo. Data and code archive.
The code archive for this paper contains our latest version of R and Julia code for computing counterfactual trade policy analysis (Exact Hat Algebra). We recommend to use those rather than the Stata ones from the 2014 Handbook chapter (because of faster speed and also additional features like the incorporation of intermediates). The version in Julia is particularly fast, hence particularly useful if you want to explore large numbers of parameter values.
Head, K. and T. Mayer, 2023, "Poor Substitutes? Counterfactual methods in IO and Trade Compared" , forthcoming at the Review of Economics and Statistics. Data and code archive.
Data used is the original BLP 1995/1999 data. The code (in R) consists mostly of simulations of the BLP Data Generating Process and variations thereof, but also BLP estimation using Colon and Gortmaker PyBLP package. The paper and code also explains how to run Exact Hat Algebra for oligopolistic environments.
Head, K. and T. Mayer, 2021, "The United States of Europe: A gravity model evaluation of the four freedoms", Journal of Economic Perspectives 35(2): 23-48. Online appendix. Readme file for Data and code archive.
The code (in R) replicates all gravity regressions in the paper with long-run datasets intended to evaluate market integration for goods, services, capital and labour in Europe since the 1960s.
The data contains among other things an up-to-date gravity dataset for goods at the world level which includes trade-with-self (1960-2018).
Mayer, T., Vicard, V. and S. Zignago, 2019, "The Cost of Non-Europe, Revisited", Economic Policy 98: 145-199 (lead article). Find here the code and data (in Stata) for this paper.
Head, K., and T. Mayer, 2014, "Gravity Equations: Workhorse,Toolkit, and Cookbook", chapter 3 in Gopinath, G, E. Helpman and K. Rogoff (eds), vol. 4 of the Handbook of International Economics, Elsevier: 131–-195. Appendix here. Companion website to the paper, including a lot of Stata code, here.
The code on this webpage uses Stata to run monte-carlo simulations and counterfactual computations among many other things. The data is the CEPII gravity data available at the time, and a more recent version is now available on their website. Regarding counterfactual simulations, much faster R and Julia code are available in the "Balkans" section of this webpage.
Head, K., T. Mayer, and J. Ries, 2010, ``The erosion of colonial trade linkages after independence'' (supplementary material available here), Journal of International Economics 81(1):1-14 (lead article).
Martin, P., T. Mayer and M. Thoenig, 2008, ``Make Trade not War?'', Review of Economic Studies 75(3): 865-900. Replication file part 1. Replication file part 2.