Replication Package for "One Rule Fits All? Heterogeneous Fiscal Rules for Commodity Exporters When Price Shocks Can Be Persistent: Theory and Evidence" By Arthur Mendes (agalegomendes@worldbank.org and agalegomendes@gmail.com) and Steven Pennings (spennings@worldbank.org and steven.pennings@gmail.com) July 2024 This file explains how to replicate the figures and tables in the main text of the paper "One Rule Fits All? Heterogeneous Fiscal Rules for Commodity Exporters When Price Shocks Can Be Persistent: Theory and Evidence". All empirical results in the paper are generated using Stata 16.1 for Mac. The theoretical results use Stata 16.1 (including packages xtivreg2 and outreg2), Matlab 2015a (including statistics and optimization toolkits), and Dynare 4.4.3 for Mac. To install Stata package X type findit X. Code takes 10+ hours to run on Mac with Intel Core i9. Note that the Online Appendix has its own replication file (and Readme_for_Appendix.txt) which is stored in the /Appendix directory. ***Directions:*** * First run: MP2024_Master_RunFirstinMatlab.m in MATLAB, after adjusting the directory on line 30, and possibly the location of the Dynare installation on line 35. - This will directly generate output for Figure 2, and top 4 lines of Table 3, and model-simulated data. - MP2024_MPS.m called by this file takes 10+ hours to run, but can comment line 38 to skip and use preloaded optimal simple rules. * Second run: MP2024_Master_RunSecondinStata.do in STATA after adjusting the director on line 20. - This will directly generate empirical results for Table 1 and Figure 1 (which are repeated in Figure 3 and 4), and will run regressions on model-simulated data from above to generate the final row of Table 3, and NK model parts of Figures 3 and 4. *Optional: several steps to generate the regression data and samples from raw data (see end of this Readme). This data is pre-generated so this step is optional. ****Tables and Figure list*** Excel files containing all the figures and tables are in the root directory of the replication file. They contain links to the output which is stored in subdirectories Part1_Empirical/Results and Part2_NKmodel/Results Figure 1 and Table 1 Empirical results: generated by MP2024_Master_RunSecondinStata.do which calls Part1_Empirical\MP2024_Figure1.do and Part1_Empirical\MP2024_table1.do. Links to Table1.xlsx, Table1_test.xlsx and Covariancematrix.xlsx in Part1_Empirical/Results Figure 2 NK Model: generated by MP2024_Master_RunFirstinMatlab.m which calls Part2_NKmodel/MP2024_Figure2.m. Links to Part2_NKmodel/Result/IRF.csv Table 2 Calibration table not included in replication file (as are assumptions, not results) Table 3 NK Model: Top four lines generated by directly by MP2024_Master_RunFirstinMatlab.m which calls Part2_NKmodel/MP2024_Table3.m. Links to Part2_NKmodel/Result/Table3.csv Bottom row based on simulated data generated by MP2024_Master_RunFirstinMatlab.m, which calls Part2_NKmodel/MP2024_Simulation.m, and MP2024_Master_RunSecondinStata.do which calls Table3_Figure3_Figure4.do to run regressions on simulated data. Links to Part2_NKmodel/Result/Simulated_regressions_OSR_XXXX.xls Figure 3 Empirics: As in Figure 1. NK model: as in the bottom row of Table 3. Figure 4 Empirics: As in Table 1. NK model: as in the bottom row of Table 3. Table 4 Qualitative summary of other results, not included in replication file. ***Directory list*** Root directory: - Master do and m files MP2024_Master_RunFirstinMatlab.m and MP2024_Master_RunSecondinStata.do - Excel files for MP2024_Figure[1,2,3,4].(xlsx) and MP2024_Table[1,2].(xlsx) linked to source files. Other directories: / Part0_PriceIndex Constructs the price index and estimates persistence for each country (discussed below) /InputData Data from a variety of sources used to generate the master dataset /RegressionData Stores datasets to run regressions in Table 1 and Figure 1 /Logs Directory to store the Stata log files /Part1_Empirical Stata Do files to generate Table 1 and Figure 1, store empirical results, and generate preliminary data /Part2_NKmodel Stata Do files and MATLAB files to generate NK model results in Figure 2-4 and Table 3 and store simulation results. This folder also contains Mod files to run Dynare. MP2024_MPS.m calls "NKmodel.mod" and "NKmodel_OSR.mod" to calibrate the NK model to EMDEs and compute the optimal MPS for flex-price and flexible/fixed ERs over half-lives from 0 to 20 years. This step takes 10+ hours. The results are saved as Part2 /NKmodel/Results/Benchmark_OSR_XXXX.(csv and matlab) for those wanting to skip this step by commenting out line 38 of MP2024_Master_RunFirstinMatlab.m. MP2024_Simulation.m simulates data using the NK model to generate Part2_NKmodel\Results\Simulated_data_XXXX.csv ***Step 0 (Optional) Commodity price index, persistence and estimating the dataset*** Data formatted by these files are preloaded so this step is optional. * Part0_PriceIndex/ contains MP2024_cindex.do constructs a commodity price index for each country from raw commodity price and export data and generates cindex.dta MP2024_commodity.m which estimates the persistence of each commodity, and generates AR1commodity.csv, MP2024_country.m estimates the persistence of commodity price shocks of each country in the sample, using the previous results. Generates AR1country.csv and cindex_EMEDs.csv * Part1_Empirical/MP2024_PreliminaryGenerateDataset.do merges several external datasets from /InputData to generate the master dataset, saved as /RegressionData/dataset.dta. This program also loads two inputs from Step 0: the commodity price index from /RegressionData/cindex.dta and the half-life from /RegressionData/AR1country.csv. It then calls dataset.dta, cleans the data (transformations, outliers, etc.), and saves the benchmark sample as RegressionData/dataset_sample_1.dta. In the same folder, the program saves dataset_sample_2, 3, 4, 5 to be used in the robustness exercises. This program also computes the distribution of ER regimes and half-life in the benchmark sample and saves as /Part2_NKmodel/Sample_distribution.xls, to be used to simulate data in the NK model. Disclaimer: The views expressed here are the authors' and do not necessarily reflect those of the World Bank, its executive directors, or the countries they represent.