Skip to content

replication code for „Forecasting with Shadow-Rate VARs“ by Carriero, Clark, Marcellino and Mertens

License

Notifications You must be signed in to change notification settings

elmarmertens/CCMMshadowrateVAR-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code for „Forecasting with Shadow-Rate VARs“ by Carriero, Clark, Marcellino and Mertens (2024)

  • Andrea Carriero (Queen Mary University of London)
  • Todd Clark (Federal Reserve Bank of Cleveland)
  • Massimiliano Marcellino (Department of Economics, Baffi, Bidsa, IGIER, Bocconi University and CEPR)
  • Elmar Mertens (Deutsche Bundesbank; em@elmarmertens.com) corresponding author

WORK IN PROGRESS

The usual disclaimers apply: the views and results conveyed in our research are solely those of the authors and do not necessarily reflect the views of the Federal Reserve Bank of Cleveland, the Federal Reserve System, the Eurosystem, or the Deutsche Bundesbank.

A manuscript of our paper and and a supplementary online appendix are available here: https://www.elmarmertens.com/research/workingpapers#h.nqkg0ogemt4s

This replication package is maintained at https://github.com/elmarmertens/CCMMshadowrateVAR-code.

When reading this README, please note that links to file names work when viewing the markdown version of this README.md in the main folder of the repository.

Overview

The code in this replication package estimates all models discussed in the paper and produces all figures and tables shown in paper and appendix using MATLAB. There are 2 main files, called runbatch.m, and runtablesandfigures.m to perform estimation and construct figures and tables, respectively. In addition, the code can be used to reconstruct or update our data inputs from FRED-MD source data, using a single script. The replicator should expect the code to run for about 30 hours on a machine with 32 workers (or cores). The code also works with as few as a single worker, but runtime should be expected to lengthen correspondingly.

This package also contains a csv file with our shadow rate estimates named CCMMshadowrateEstimates.csv, with further details described below.

Data Availability and Provenance Statements

  • This paper does not involve analysis of external data (i.e., no data are used or the only data are generated by the authors via simulation in their code).

Statement about Rights

  • I certify that the author(s) of the manuscript have legitimate access to and permission to use the data used in this manuscript.
  • I certify that the author(s) of the manuscript have documented permission to redistribute/publish the data contained within this replication package. Appropriate permission are documented in the LICENSE.txt file.

Summary of Availability

  • All data are publicly available.
  • Some data cannot be made publicly available.
  • No data can be made publicly available.
  • Confidential data used in this paper and not provided as part of the public replication package will be preserved for ___ years after publication, in accordance with journal policies.

Details on each Data Source

Data.Name Data.Files Location Provided Citation
“FRED-MD” 2022-09.csv data/ TRUE McCracken and Ng (2016)
“Krippner Shadow-rate estimates” SSR_Estimates_2022March.xlsx data/ TRUE Krippner (2015)
“Wu-Xia Shadow-rate estimates” shadowrate_US.xls data/ TRUE Wu and Xia (2016)

Dataset list

FRED-MD data were downloaded from the Federal Reserve Bank of St. Louis. We use the 2022 September vintage. A copy of the data is provided as part of this archive. The data are in the public domain.

Updated shadow rate estimates from Krippner (2015) and Wu and Xia (2016) were downloaded from the authors websites, but are only used for comparison plots; these data series are not used in our estimation.The data are publicly available, and copies are provided with this replication package. Estimates from Krippner can be downloaded from https://www.ljkmfa.com/visitors/ and are subject to his disclaimer and copyright statements (https://www.ljkmfa.com/disclaimer-copyright/). We use his estimates per March 2022. Updated estimates from Wu and Xia can be downloaded from https://sites.google.com/view/jingcynthiawu/shadow-rates. We use a copy downloaded on September 10, 2022.

Computational requirements

Software Requirements

  • The replication package provides all dependencies and each script sets up the necessary path variables.

  • Matlab including Statistics and Machine Learning Toolbox and Parallel Computing Toolbox (code was run with Matlab Release 2023b)

  • personal toolbox files maintained by Elmar Mertens (one of the authors), included as part of this package. Also available at https://github.com/elmarmertens/em-matlabbox (Code was run with commit from Dec 30 2024, hash: 84bcdf4)

Portions of the code use bash (or zsh) scripting, which may require Linux or macOS. Use of these code portions is, however, optional and serves merely to regenerate scripts that are provided as part of this replication package under different parameterizations than used in the paper.

Controlled Randomness

Except for goVAR200811.m, each of the programs listed above executes code in parallel workers using substreams of the global random-generator streams, which is seeded as described above. The substreams are assigned in the following lines:

  • goVAR.m:260
  • goVAR200811.m:257
  • goVARshadowrateBlockNonstructural.m:276
  • goVARshadowrateGeneral.m:280
  • goVARshadowrateNonstructural.m:275

From the programs listed above, we also derive driver files named bot*.m (by using the shell script preparebatch.sh) and these inherit the above-described settings for the random seed.

Memory, Runtime, Storage Requirements

Summary

Approximate time needed to reproduce the analyses on a standard (2024) desktop machine:

  • <10 minutes
  • 10-60 minutes
  • 1-2 hours
  • 2-8 hours
  • 8-24 hours
  • 1-3 days
  • 3-14 days
  • > 14 days

Feasible in about 32 hours on a 32 core machine.

Approximate storage space needed:

  • < 25 MBytes
  • 25 MB - 250 MB
  • 250 MB - 2 GB
  • 2 GB - 3 GB
  • 3 GB - 25 GB
  • 25 GB - 250 GB
  • > 250 GB

Approximate RAM memory needed:

  • 24 GB (sequential estimation), and 2-3 GB per core when using parallel execution.

  • Not feasible to run on a desktop machine, as described below.

Details

The main computational routines last run on a 32-core Intel virtual client with 112 GB of RAM. Computation took about 30 hours.

Auxiliary code to collect MCMC estimates, and produce tables and figures was last run on a laptop with Apple Silicon chips and MacOS version 15.2 (and Matlab 2024b) with 16GB of RAM and 200GB of free storage.

Description of programs/code

To produce quasi-real estimates of each models defined in the paper, there are various go*.m files:

  • goVAR.m for the standard linear VAR. (goVAR200811.m estimates the linear VAR using only data through 2008; these estimates are used as reference point in our analysis of parameter changes of various models described in the supplement.)

  • goVARshadowrateGeneral.m for the general shadow rate VAR (applies only to the exYield data set provided in fredsxMD20exYield-2022-09.csv).

  • goVARshadowrateNonstructural.m for the unrestricted version of the non-structural shadow-rate VAR

  • goVARshadowrateBlockNonstructural.m for the restricted version of the non-structural shadow-rate VAR

  • In order to apply each dataset to each applicable model, use the driver fiels botgo*.m. This set of driver files can also be recreated (and with different settings) by the bash script preparebatch.sh as described further below.

Other estimates, tables and figures: To produce all tables and figures of the paper, as well as additional material as shown in the supplementary appendix, call runtablesandfigures.m, which calls the following scripts to create tables and figures:

  • oosEvaluationTables.m produces forecast comparison tables (as in Tables 2 and 3 of the paper) based on output stored by the goVAR*.m scripts. Comparisons against a linear VAR that omits short-rate data, as in Table 4 of the paper, are compiled by oosEvaluationTablesAgainstLongYieldsOnly.m.
  • barplotBETAslopes.m reports the ELB-specific coefficients estimated from the general shadow-rate VAR as reported in Figure 1 of the paper.
  • showShadowrates.m produces figures of shadow-rate estimates as shown in Figure 2 in the paper, and stores the time seris of shadow-rate estimates in CCMMshadowrateEstimates.csv. The shadow-rate estimates are obtained from output stored by the goVAR*.m scripts.
  • oosPlotForecastsSHADOWFFR.m to plot predictive densities for shadow rate and federal funds rate at selected jump offs (as in Figure 3).
  • showPAIchanges.m produces comparison figures of VAR transition coefficients as discussed in the supplement to our paper.

All core scripts are in the main directory. In addition, there are the following subdirectories:

  • data contains raw input data, and the script generateFREDdata.m to produce input files, named fredsxMD*.csv, as needed by the estimation routines (copies of these input files are also provided in the main folder).
  • matlabtoolbox for general utilities (also available at https://github.com/elmarmertens/em-matlabbox).
  • By default, estimation results are stored as *.mat files in the main folder of the replication package.
  • The subfolder foo will be created inside the main filder by our routines for creating tables and figures.

License for Code

The code is licensed under a BSD license. See LICENSE.txt for details. Toolbox code from Elmar Mertens is also licensed under a BSD license. See matlabtoolbox/LICENSE.txt.

Instructions to Replicators

The following instructions should be executed in a Matlab session with the current working directory set to the main folder of the replication package:

  • To employ parallel process of parfor loops employed by our codes create a parallel pool in Matlab, which requires availability of the Matlab Parallel Computing Toolbox (otherwise the loops will be executed sequentially). Choose a number of parallel workers suitable for your computing environment (in terms of available CPU and RAM memory). For example, to use the default setting for your system, simply use parpool; in order to use the code with 32 workers use parpool(32). When no parpool is created, parfor steps will be executed one-by-one. To employ parallel processing launch parpool prior to calling our routines. Depending on system defaults in your Matlab installation, Matlab might also launch parpool automatically when encountering the first parfor (or spmd) command. Also, depending on system defaults, please note that the parallel pool may automatically terminate when idle (and thus needs to be launched again prior to further use).

  • To launch a sequence of out-of-sample runs for all models and datasets considered in the paper, call runbatch.m, which calls various bot*.m files. Each file creates a *.mat file with model-specific results data that is stored in the repository's main directory.

  • To create all tables and figures for the paper and its supplementary appendix, call runtablesandfigures.m. This script requires that runbatch.m has finished (and the resulting *.mat files are stored in the repository's main directory). Outputs are stored in *.tex format (for tables) and *.eps format (for figures) and stored in a subfolder foo.

  • When all tables and figures are stored in foo, you can compile the LaTeX files CCMMpaperTablesAndFigures.tex and CCMMsupplementTablesAndFigures.tex to collect figures and tables as they are presented in paper and supplement.

  • In a Linux or macOS shell, you can also use the makefile provided with this replication package to perform the steps described above: make all performs estimation (in parallel mode), creates all tables and figures and compiles the two LaTeX files mentioned above. (If parallel mode is not available, please replace the makefile calls to goparbatch.sh by calls to goseqbatch.sh.)

Details

  • All scripts set the MATLAB path to point to toolboxes in matlabtoolbox. In addition, most scripts collect output in a temporary directory, which is by default created as subfolder foo within the main directory (if not present the folder will be created). Edit localtemp.m to change the location of this temp directory (or place an alternate copy of localtemp.m in the main directory of the repository).

  • Output is collected in a LaTeX file, which is also compiled at the end of each script (provided a LaTeX installation can be found on the path). To control the compilation of output, please edit finishwrap.m. To avoid collecting output files, comment out the call to initwrap in each script (and make sure to define instead a variable called wrap that is set to empty).

  • The codes employ parfor loops that are executed in parallel when a parpool has been created in Matlab, which requires availability of the Matlab Parallel Computing Toolbox (otherwise the loops will be executed sequentially).

  • All necessary input files are provided in the main folder of this repository. (See below for recreating or updating these inputs from source data files povided in the data folder of this repository.)

  • Each bot*m file is a copy of a corresponding go file, but with presets that apply the model to a particular dataset. In a bash shell, you can create this set of bot files, by calling the bash script preparebatch.sh and pass the appropriate go file names as argument; for example sh preparebatch.sh goVAR*.m prepares bot files for all go files in the repo and prepares estimation of each model both with and without longer-run yields data (as needed in the paper). For example, to rerun all results with a different number of MCMC draws, change the value of MCMCdraws on line 19 of preparebatch.sh.

  • The main directory contain the bash scripts goparbatch.sh and goseqbatch.sh that can be used to launch a sequence of multiple Matlab scripts from the shell. Both shell scripts expect that the names of the Matlab scripts to be executed should be passed as argument list. Both shell scripts execute the arguments in sequence and in separate Matlab sessions.

  • In case of goparbatch.sh, the Matlab session opens a parallel pool. For example, the shell command sh gobatch.sh goVAR.m goVARshadowrateBlockNonstructural.m goVARhybrid.m will launch a command line session of Matlab, start a parallel pool, and then execute goVAR.m; once goVAR.m has been executed, the Matlab sessions closes, a new one is reopened for execution of goVARshadowrateBlockNonstructural.m etc. (The shell script works with as many command line arguments as supported by bash and has been written for use on macOS and Linux.) Alternatively, Matlab scripts can, of course, also be called interactively on the Matlab GUI’s command line.

  • To launch out-of-sample runs for a given model, use scripts called go*.m. After computing the out-of-sample runs each of these go*.m scripts stores results for further post-processing in a *.mat file.

  • While looping over out-of-sample runs in our go*.m files, individual iterations may encounter (rare) errors due numerical issues, which are reported on screen. These errors do not lead to abortion of the program; instead, they are caught by the program and the iteration in question is relaunched.

References

Krippner, Leo (2015), Zero Lower Bound Term Structure Modeling: A Practitioner’s Guide. Palgrave Macmillan.

McCracken, Michael W. and Serena Ng (2016), “FRED-MD: A monthly database for macroeconomic research.” Journal ofBusiness & Economic Statistics, 34 (4), 574–589.

Wu, Jing Cynthia and Fan Dora Xia (2016), “Measuring the macroeconomic impact of monetary policy at the zero lower bound.” Journal of Money, Credit and Banking, 48 (2-3), 253–291.


About

replication code for „Forecasting with Shadow-Rate VARs“ by Carriero, Clark, Marcellino and Mertens

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages