Dynamic stochastic general equilibrium (DSGE) models are a mainstay of economic modelling at central banks, but they are big beasts, consuming large quantities of computing power and time to run.

That is not about to change, but researchers at the Federal Reserve Bank of New York, in co-operation with Thomas Sargent and John Stachurski's QuantEcon project, have taken a big step towards streamlining the process.

Stachurski, a professor at the Australian National University, approached the New York Fed in 2015 about the possibility of translating a model for policy analysis into a new programming language.

The NY Fed had already published the code underlying its DSGE model, originally written in Matlab, and was pleased to take up Stachurski's suggestion.

The team chose to translate into Julia, a relatively new open source programming language designed to be easy to learn and focused on efficient mathematical programming.

Marco Del Negro and Marc Giannoni, both assistant vice-presidents in the NY Fed's research department, headed the project. "One of the arguments for going with Julia was it is fairly close to Matlab," says Giannoni. "People who are familiar with Matlab can at least read code written in Julia. There are a lot of subtleties to Julia you must get familiar with, but at least you can get started."

Lengthy translation

Research analysts Erica Moszkowski and Micah Smith, and summer intern Pearl Li, took on the bulk of the translation work, with QuantEcon economists acting as consultants.

The three had some coding experience, and Moszkowski had studied part of the QuantEcon course in computational economics, but it was still a steep learning curve.

The translation process for the estimation step took the summer and autumn to complete, and the team published the results in early December 2015. Work on translating the forecasting step and other features is ongoing.

By the time they had finished, the team had managed to cut the number of lines of code nearly in half – from 6,300 to 3,700 – and cut the time it takes to run some sections by as much as 90%. Overall, the model now runs around four times faster.

"The final product was much more expressive and elegant, I think, than the original Matlab code," says Smith.

The process was not as simple as recreating the Matlab code like-for-like. "A significant amount of the time was spent on design challenges, to make the code as clear and elegant and user-friendly as possible," explains Moszkowski.

Adaptation

All the code for the estimation step is now available on GitHub, an online repository for open-source code. Anyone can therefore download and run it with only a limited grasp of programming in Julia required (see box below). It comes pre-packed with sample dataset and configuration.

By making the model free, the hope is coders will take the model and suggest improvements, so it can evolve over time – indeed, it already draws on code originally written by economist Christopher Sims.

Other central banks and researchers can also take the model and adapt it to their needs, and many have already expressed an interest. "The whole point of putting our code on the web is for others to use it and adapt it to their needs," says Del Negro.

The model is designed as a flexible framework, allowing users to easily change it to match local conditions by adding their own equilibrium conditions, parameters and other settings. Applying it to other economies is "well within the scope" of the model, says Smith.

The NY Fed has been quick to recognise the potential in hiring economists who can code. Research analysts joining the NY Fed have typically studied some computer science at the undergraduate level, and many are studying the QuantEcon course to improve their skills.

During the development of the Matlab code, the NY Fed adopted a do-it-yourself approach rather than using a modelling package such as Dynare, which is in use at many central banks. Del Negro says this helped build the coding know-how to take on the Julia project.

Not all central banks can draw on this depth of expertise, but adapting and running the model requires much less coding knowledge than translating it.

Next steps

The focus for the team is now on building the parts of the model most useful for policy-making, such as forecasting. When that is done, the plan is to try and improve the code, possibly drawing on some of the higher-quality packages built by the coding community.

One key goal is to adapt the current linear model into a non-linear model, particularly useful when dealing with financial frictions. To do this, the team is planning to add a particle filter, or sequential Monte Carlo method, in the place of the current Kalman filter.

Translating other models into Julia is also "definitely" a possibility, says Del Negro, pointing to the NY Fed's nowcasting model as a likely candidate. The model incorporates various data releases into a more timely estimate of GDP growth than official statistics can manage.

There remains a debate over the value of DSGE models, as other models often perform better in specific areas, though DSGE methods have improved significantly in recent years.

Del Negro comes to their defence: "They are not the best athlete in all competitions, but they are up there. They do pretty well at a variety of things – forecasting, policy analysis, and a structural understanding of the economy. I guess we are pretty happy with it so far."