Liberty Street Economics

« | Main | »

May 8, 2017

Forecasting with Julia

A little more than a year ago, in this post, we announced DSGE.jl—a package for working with dynamic stochastic general equilibrium (DSGE) models using Julia, the open-source computing language. At that time, DSGE.jl contained only the code required to specify, solve, and estimate such models using Bayesian methods. Now, we have extended the package to provide the additional code needed to produce economic forecasts, counterfactual simulations, and inference on unobservable variables, such as the natural rate of interest or the output gap. The old, pre-Julia version of the code, which was written in MATLAB and is posted here on Github, a public repository hosting service, also performed some of these functions, but not quite as fast.


So what does DSGE.jl version 2.0 do? Version 1.0 of the package just estimated the parameters of the model. While this is a necessary step, and perhaps the most challenging one from a computational point of view, it is by no means the end goal. The real questions that motivate the use of DSGE models are: What are output growth and inflation going to be over the next two years? What are the drivers of these forecasts? What were the causes of the slow recovery from the financial crisis (a slow recovery that, unlike most private forecasters, the FRBNY DSGE model predicted back in 2010)? What is the natural rate of interest—also known as r*—and how is it going to evolve in the future? We need to go beyond parameter estimation in order to address these questions.

The FRBNY DSGE is a linear state-space model. A state-space model is a dynamic system where the underlying “state of the economy,” which we do not directly observe, evolves over time, and where the variables that we observe and forecast—such as real GDP growth—are a function of this state of the economy. If we want to make projections, we therefore need to come up with an estimate of the state of the economy today, and use it to guess the economy’s future evolution. If we want to also characterize the uncertainty about the model’s forecasts—that is, to construct the blue shaded areas in the charts in this earlier post—we need to take into account that we don’t quite know the current state of the economy or its evolution, and that even if we did know, future shocks will hit the economy. This chapter in the Handbook of Economic Forecasting provides an overview of the algorithm just described, which is implemented by the codes.

When we want to plot the history of latent variables such as the natural rate of interest, a guess about the current state of the economy is not enough. We also need to conduct inference on the state of the economy in the past. For this type of inference, known as “smoothing,” we need another set of routines. The so-called “Kalman smoother” produces our average guess for the latent variables, while the “distribution smoother” produces the whole distribution. We build the former using an efficient algorithm developed by Koopman, and the latter using the approach of Durbin and Koopman (although code implementing an alternative approach by Carter and Kohn is also available). We use these very same techniques to extract the histories of the shocks that hit the economy over our estimation sample, and then use these histories to identify the drivers of economic fluctuations. Since all of these codes are also useful outside the realm of DSGE models, we made them available as a stand-alone package called StateSpaceRoutines.jl.

For those interested in the programming details, this technical post provides some information about the challenges we faced in writing the Julia code and how we addressed them. While the old estimation code was largely a direct port (in other words, a translation) of the original MATLAB code, we completely redesigned the forecast section to obtain code that is much faster and easier to use. Our efforts paid off to huge effect, with our most recent model running the full-distribution forecast step in approximately fifteen minutes, compared with the seventy minutes our old code took to perform the same tasks. In the technical post we discuss the design principles and Julia parallel computing tools that made these speedups possible.

LSE_2017_dsge-april_delnegro_2.5x3
The Federal Reserve Bank of New York recently lent its expertise in code development to other central banks eager to learn about this new open-source computing language. In March, two of us traveled to give Julia workshops organized by QuantEcon at the Reserve Banks of Australia and New Zealand. The workshops covered Julia syntax, important features, and packages relevant to statisticians and economists, as well as our experience with Julia in the FRBNY DSGE team. All of the workshop materials can be found on Github. The two kangaroos shown in the photo to the left came back with us from the trip to Australia. Their names are An&Schorfheide (small kangaroo) and Smets&Wouters (large).

Disclaimer

The views expressed in this post are those of the authors and do not necessarily reflect the position of the Federal Reserve Bank of New York or the Federal Reserve System. Any errors or omissions are the responsibility of the authors.

This post reflects the experience of the authors with Julia and MATLAB and does not represent an endorsement by the Federal Reserve Bank of New York or the Federal Reserve System of any particular product or service.



Gupta_AbhiAbhi Gupta is a senior research analyst in the Federal Reserve Bank of New York’s Research and Statistics Group.

Li_PearlPearl Li is a senior research analyst in the Bank’s Research and Statistics Group.

Moszkowski_ericaErica Moszkowski is a senior research analyst in the Bank’s Research and Statistics Group.

Del_negro_marcoMarco Del Negro is a vice president in the Bank’s Research and Statistics Group.

Giannoni_marcMarc Giannoni is an assistant vice president in the Bank’s Research and Statistics Group.

How to cite this blog post:

Abhi Gupta, Pearl Li, Erica Moszkowski, Marco Del Negro, and Marc Giannoni, “Forecasting with Julia,” Federal Reserve Bank of New York Liberty Street Economics (blog), May 8, 2017, http://libertystreeteconomics.newyorkfed.org/2017/05/forecasting-with-julia.html.

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

The comments to this entry are closed.

About the Blog

Liberty Street Economics features insight and analysis from New York Fed economists working at the intersection of research and policy. Launched in 2011, the blog takes its name from the Bank’s headquarters at 33 Liberty Street in Manhattan’s Financial District.

The editors are Michael Fleming, Andrew Haughwout, Thomas Klitgaard, and Asani Sarkar, all economists in the Bank’s Research Group.

Liberty Street Economics does not publish new posts during the blackout periods surrounding Federal Open Market Committee meetings.

The views expressed are those of the authors, and do not necessarily reflect the position of the New York Fed or the Federal Reserve System.

Economic Research Tracker

Image of NYFED Economic Research Tracker Icon Liberty Street Economics is available on the iPhone® and iPad® and can be customized by economic research topic or economist.

Economic Inequality

image of inequality icons for the Economic Inequality: A Research Series

This ongoing Liberty Street Economics series analyzes disparities in economic and policy outcomes by race, gender, age, region, income, and other factors.

Most Read this Year

Comment Guidelines

 

We encourage your comments and queries on our posts and will publish them (below the post) subject to the following guidelines:

Please be brief: Comments are limited to 1,500 characters.

Please be aware: Comments submitted shortly before or during the FOMC blackout may not be published until after the blackout.

Please be relevant: Comments are moderated and will not appear until they have been reviewed to ensure that they are substantive and clearly related to the topic of the post.

Please be respectful: We reserve the right not to post any comment, and will not post comments that are abusive, harassing, obscene, or commercial in nature. No notice will be given regarding whether a submission will or will
not be posted.‎

Comments with links: Please do not include any links in your comment, even if you feel the links will contribute to the discussion. Comments with links will not be posted.

Send Us Feedback

Disclosure Policy

The LSE editors ask authors submitting a post to the blog to confirm that they have no conflicts of interest as defined by the American Economic Association in its Disclosure Policy. If an author has sources of financial support or other interests that could be perceived as influencing the research presented in the post, we disclose that fact in a statement prepared by the author and appended to the author information at the end of the post. If the author has no such interests to disclose, no statement is provided. Note, however, that we do indicate in all cases if a data vendor or other party has a right to review a post.

Archives