The Fed's New Dot Plot in Python

Fabian Scheler
April 27, 2022
Dots are to be taken with a big, big grain of salt

Jerome Powell

While excessive leverage in the U.S. banking system and the country's housing market were the ultimate cause of the Great Financial Crisis in 2008, the Fed's aggressive monetary policy tightening under its then-chairman Alan Greenspan played a role. Unfortunately, Greenspan was not exactly renowned for his exceptional communicational skills, and his 17 rate hikes between 2004 and 2006 gave markets and borrowers little time to prepare.

During the next crisis, which is widely considered the worst since the Great Depression in 1929, the central bank was quickly forced to reduce interest rates to zero, and the slow recovery meant they were pretty much stuck there for almost a decade. With interest rate policy constrained by the zero lower bound, the Fed resolved to alternative monetary policy tools, including outright purchasing government bonds to control longer-term benchmark interest rates.

I guess I should warn you, if I turn out to be particularly clear, you've probably misunderstood what I've said.

Alan Greenspan

Beyond that, having learned from the experiences made under Greenspan and as a complementary tool, the Federal Open Market Committee (FOMC) started to provide much more comprehensive forward guidance. This includes the regular publication of a set of economic projections, and the most famous part of this dataset is arguably the so-called Dot Plot. The Dot Plot provides an easy-to-understand overview of all FOMC members' key interest rate expectations for the current and the following two years and their longer-term projections. Each point in the chart represents one committee member. Consequently, the plot also gives an idea of the dispersion of opinions within the committee. Towards the end of each year, the Dots for the current year will converge to the actual Federal Funds Rate.

The FED's Dot Plot in March 2022

It is noteworthy that Jerome Powell warned investors of taking the Dots too literally. While the Dot Plot is widely followed, regular readers of the FOMC's projections will quickly note how volatile the committee's predictions are, given the generally high uncertainty about future economic developments. Nevertheless, there is still value in it.

First of all, the Dots for the current year help investors gauge the near-term development of the Federal Funds Rate and thus help fix short-term interest rates. The FOMC's longer-run rate expectation, on the other hand, has so far remained pretty stable and reflects the bank's assessment of long-term equilibrium growth and inflation dynamics.

“They’re not a committee forecast, they’re not a plan. The dots are not a great forecaster of future rate moves. And that’s because it’s so highly uncertain.”

Jerome Powell

Obviously, you can see the Dot Plot in the FOMC's materials, so why should you replicate it myself?

This blog post addresses a whole bunch of challenges related to data retrieval, processing and visualization:

  • How to automatically retrieve the FOMC's projections and make them machine-readable in Python?
  • How to construct the Dot Plot in Python using Plotly?
  • How to export the Plotly graphic as a static image or dynamic HTML file?
  • How to create a dynamic, animated version of it that allows us to put the current Dots historically into perspective?
  • How to host the dynamic HTML version of our graphic on GitHub?

How can we efficiently retrieve the FOMC's projections and make them machine-readable in Python?

While the Dots are the most recognized part of the FOMC's projections, the committee also provides a growing set of other predictions that can be relevant for the assessment of the current economic outlook and historical analysis. Of course, you can access the website and copy/paste the data into excel. This becomes pretty painful, though, once you want to access all historical datasets, making it hard to maintain.

I used to replicate the DotPlot in Excel years ago and had to regularly update it for marketing publications - a process that is painfully cumbersome and highly error-prone. Fortunately, Rubén Hernández-Murillo from the Federal Reserve Bank of Cleveland did the heavy lifting years ago and was so kind to share his Python script on his website.

He also published a javascript code for the creation of the Dot Plot. However, I prefer a pure Python implementation and implemented the DotPlot with Plotly.
While Hernández-Murillo's code still works almost perfectly well after five years, there are a few small things that I had to amend and that users should pay attention to.
First of all, the structure of the FOMC's projection materials changes over time as tables are added or removed.

In the function that downloads and processes the data, you will find the following line of code that selects the correct table. When Hernández-Murillo published his script, the table needed for the Dots was the last one in the dataset. This changed in June 2020, so I introduced a flexible variable that allows the user to point to the correct table.

Secondly, the number of columns changes over the course of each year. The FOMC publishes projections for the current and the next two years in March and June but adds another year in September and December. There are various ways of tackling this, but I simply added a procedure to my function that removes the third year in September and December. Of course, this results in loss of information, but the longer the horizon, the more unstable the forecasts, and for the dynamic version, this guarantees the required consistency.

Last but not least, I wrapped all this in a simple function. This allows us to easily download the data for different periods. We only need to provide the URL of the HTML version of the projection materials and point to the correct target table. The function also converts the data into a format that the chart can handle. For this, we need to "spread out" the dots on the x-axis.

This is the most tricky part of the exercise, turning the development of the Dot Plot into a nice intellectual challenge. In my function, I solved the problem with the help of NumPy's linspace function, which returns evenly spaced numbers over a specified interval. A flexible variable 'spacing' allows the user to specify how tightly the dots should be grouped.

The complete function can be found below.

Let's finally use this, to retrieve the latest Dots.

How to construct the static Dot Plot?

Once the challenging part of bringing the data into the correct format has been solved, constructing the Dot Plot itself is a relatively simple exercise.

How to export our Plotly graphic?

This graphic can now be saved as an image in png or SVG format using the functions provided here. However, I find that this tends to be a bit unstable, and sometimes the write_image part actually crashes my editor. In this case, it is good to know how to save the chart as an HTML file and manipulate Plotly's toolbar so you can subsequently store it in your format of choice by clicking on the camera icon. The code below is universal and quite useful when working with Plotly graphics in web applications.

What's even more exciting, we can use the HTML file and host it somewhere to embed it into websites, blogs or other applications. An excellent blog post on Towards Data Science explains how to host Plotly graphics on Chart Studio or Github.

On top of that, I have attached my step-by-step guide for hosting on GitHub below.

Personally, I GitHub over Chart Studio for hosting graphics, and you can find my animated, dynamic version of the DotPlot here. After that, we just need to add a little bit of code around the URL to convert it into an iframe that can be embedded in a website.

Enjoy the dance of the Dots.

How to build a dynamic, animated Dot Plot

This brings us to the last step of creating the animated Dot Plot. Obviously, there are various ways to put the latest data into perspective and visualise the Dot's progression over time. You could also compare the median, min or max forecasts in a simple line chart. That's rather boring, though, and this exercise can also be an excellent showcase of Plotly's animation capabilities.

For this, we first need to download the historical datasets. Finding the URLs is only a little manual work as their structure doesn't change and always contains the publication date at the end. Once we have loaded the data, we can concatenate it into one data frame and proceed to build the animated plot with the following code. My implementation may not be the prettiest, but I haven't found a better way of doing it yet.