Matlab code for large-scale simulation studies of impulse response estimators, including Local Projections (LPs), Vector Autoregressions (VARs), and several variants of these
Reference: Li, Dake, Mikkel Plagborg-Møller, and Christian K. Wolf (2024), "Local Projections vs. VARs: Lessons From Thousands of DGPs", Journal of Econometrics (published version, working paper, supplement)
Tested in: Matlab R2023a on Windows 10 PC (64-bit)
Documents: Paper, supplement, and documentation
Estimation_Routines: General-purpose impulse response estimation functions
DFM: Simulation study based on encompassing Dynamic Factor Model (DFM)
Estimate IRFs from simulated data: Run the following scripts to select 6000 DGPs (under observed-shock identification), repeat 5000 Monte Carlo simulations for each DGP, and apply multiple estimators for each simulation. This step produces the raw IRF estimates.
settings.specifications.random_n_spec = 100
, and settings.simul.n_MC = 5000
.estimand_type = 'ObsShock'
, lag_type = 4
, and mode_type = 1
.dgp_type
from 'G'
(for fiscal policy type) to 'MP'
(for monetary policy type);spec_id
from 1 to 30 (for 30 distinct seeds, where each seed draws 100 random DGPs). (Note: The code has been set up this way to allow the simulations to be split into several independent jobs on a research computing cluster.)Summarize key statistics: Run the following scripts to obtain summary statistics of raw IRF estimates across 5000 simulations. This step reduces the dimensionality of the results.
spec_id_array = [1:30]
, dgp_type = 'G'
(or 'MP'
). Additionally, specify estimand_type
, lag_type
, and mode_type
to be consistent with Step 1.Properties of selected DGPs and true IRFs: Run the following scripts to summarize the properties of the selected DGPs and their true IRFs (Section 3.4).
mode_select = 1
, lags_select = 2
, and exper_select_group = {[2,5]}
.Evaluate loss for observed-shock estimators: Run the following scripts to show bias and variance profiles of each estimator under observed shock identification, and compare their loss at different bias weights and target horizons (Sections 5.1-5.3).
mode_select = 1
, lags_select = 2
, and exper_select_group = {[2,5]}
below.folder
set to the output directory in Step 3), to depict the optimal estimator given different bias weights and target horizons (Figure 6).Evaluate loss for IV estimators: Run the following scripts to get bias and variance profiles for estimators under IV identification (Figures 10-11).
estimand_type = 'IV'
in Steps 1-2, and exper_select_group = {[1,4]}
in Steps 3-4.Examples of estimated IRFs: Run the following scripts to plot examples of IRF estimates, as in Appendix E.
spec_id = 1
, dgp_type = 'G'
. Additionally, specify estimand_type
, lag_type
, and mode_type
to be consistent with Step 1.Further evaluations for IV estimators: Run the following scripts to further examine bias and variance profiles of IV estimators, as in Appendix F.1.
DGP_select
to 2 (low degree of invertibility) or 3 (high degree of invertibility) in Reporting/run_plot_loss.m.Robustness checks: Run the following scripts to revisit the bias and variance trade-off in various extensions (Appendices F.2-F.10).
mode_type = 6
in Steps 1-2, and mode_select = 6
in Steps 3-4.estimand_type = 'Recursive'
in Steps 1-2, and exper_select_group = {[3,6]}
in Steps 3-4.mode_type = 4
in Steps 1-2, and mode_select = 4
in Steps 3-4. (Warning: In Step 1, the code will not execute for sufficiently large values of spec_id
, since the total number of available DGPs is exhausted. Simply skip to the next step when this happens.)loss_quant = 0.9
in Step 4.exper_select_group = {[2]}
(to display fiscal shocks only) or exper_select_group = {[5]}
(to display monetary shocks only) in Steps 3-4.lag_type = 8
in Steps 1-2, and lags_select = 3
in Steps 3-4.mode_type = 2
in Steps 1-2, and mode_select = 2
in Steps 3-4.mode_type = 3
and lag_type = 12
in Steps 1-2, coupled with mode_select = 3
and lags_select = 4
in Steps 3-4.mode_type = 5
in Steps 1-2, and mode_select = 5
in Steps 3-4. Also redo Step 5 for IV estimators.Splitting by variable categories: Table F.3 should have been generated in the outputs after finishing Steps 1-4 (Appendix F.11).
We rely on BVAR code by Domenico Giannone, Michele Lenza & Giorgio Primiceri, penalized LP code by Regis Barnichon & Christian Brownlees, as well as VAR model averaging code by Bruce Hansen. We have slightly modified these sets of code to improve their run-time without affecting their numerical output. We also use Dynamic Factor Model code and data by Eben Lazarus, Daniel Lewis, Jim Stock & Mark Watson.
Plagborg-Møller acknowledges that this material is based upon work supported by the NSF under Grant #2238049, and Wolf does the same for Grant #2314736.