Liberty Street Economics

« | Main | »

December 3, 2015

The FRBNY DSGE Model Meets Julia

We have implemented the FRBNY DSGE model in a free and open-source language called Julia. The code is posted here on GitHub, a public repository hosting service. This effort is the result of a collaboration between New York Fed staff and folks from the QuantEcon project, whose aim is to coordinate development of high performance open-source code for quantitative economic modeling.


You may wonder why we wrote our code, which was originally in MATLAB and made available here, in Julia. MATLAB is a widely used, mature programming language that has served our purposes very well for many years. However, Julia has two main advantages from our perspective. First, as free software, Julia is more accessible to users from academic institutions or organizations without the resources for purchasing a license. Now anyone, from Kathmandu to Timbuktu, can run our code at no cost. Second, as the models that we use for forecasting and policy analysis grow more complicated, we need a language that can perform computations at a high speed. Julia boasts performance as fast as that of languages like C or Fortran, and is still simple to learn. (Read this post, written by the creators of the language, to understand why Julia fits the bill.) We want to address hard questions with our models—from understanding financial markets developments to modeling households’ heterogeneity—and we can do so only if we are close to the frontier of programming.

We tested our code and found that the model estimation is about ten times faster with Julia than before, a very large improvement. Our ports (computer lingo for “translations”) of certain algorithms, such as Chris Sims’s gensys (which computes the model solution), also ran about six times faster in Julia than the MATLAB versions we had previously used. (These results should not be interpreted as a broad assessment of the speed of Julia relative to MATLAB, as they apply only to the code we have written.) This document written by the New York Fed and QuantEcon collaborators, who did the real work on the port, documents the speed improvements and offers an overview of the hurdles encountered in the translation of a large codebase from one language to another. We hope it will be of use to other central banks and researchers embarking on similar projects.

We posted our code on GitHub because it is a natural home for open-source projects like ours. Anyone can easily download the code and—most importantly from our point of view—offer suggestions on how to improve it by posting enhanced versions and extensions of our routines. This release also provides an opportunity for the research community to experiment with an open-source, large-scale dynamic stochastic general equilibrium (DSGE) model that is actively used in a research and policy setting. The point of collaborative programming goes beyond the joy of sharing; it is a form of “model validation.” We constantly test the accuracy of our code (and the process of translation into Julia led to yet another line-by-line examination), but we also believe that the best way of making sure that the code is accurate is by letting the rest of the world be our reviewers. If there are inaccuracies or inefficiencies, somebody will find them. If there is a way to make the code faster, somebody will suggest it.

Finally, we want to thank our friends from QuantEcon, Zac Cranko, Spencer Lyon, and Pablo Winant, who worked elbow to elbow on the code with our staff, as well as John Stachurski, who made the collaboration possible. We are not done with this project: what we posted was just the DSGE model estimation part of the code, and a lot more is yet to come. Check out our code, and stay tuned!

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.


Del Negro MarcoMarco Del Negro is an assistant vice president in the Federal Reserve Bank of New York’s Research and Statistics Group.

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

Pearl Li is a undergraduate at the Wharton School of the University of Pennsylvania, and was a summer intern in the Group during the summer of 2015.

Erica Moszkowski is a research analyst in the Group.

Micah Smith is a senior research analyst in the Group.

Comments

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

Excellent! Open code that runs on a multiplatform, free language. This is the kind of initiative that will make empirical economics move forward. Thanks!

It looks like you are using the inverse of the Hessian at the posterior mode as an (initial) proposal covariance. Have you tried scaling this, as in Roberts and Rosenthal, “Examples of adaptive MCMC” (2009)? Not sure if this will help if you’re modifying the proposal later. Also, it looks like you can evaluate the Hessian of your posterior at an arbitrary point, not just the mode. Have you considered using a Hessian-exploiting version of Metropolis-Hastings, like stochastic Newton (e.g. arXiv:stat/1502.02008)?

I think this is exciting on two dimensions. First, as one of the co-inventors of Julia, I am really glad to see Julia being used by researchers at the NY Fed. This is a dream come true – these are the kinds of things we imagined Julia will enable. Secondly, and perhaps even more important, is the fact that the DSGE code is open sourced. Increasingly, as results from complex codebases feed into decision making and policy, it is great to have a robust body of open source code that can be examined by anyone. I personally hope to see more central banks open sourcing their work and collaborating on foundational libraries.

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