Tuesday, April 11, 2017

Determining recessions with an algorithm

This is still a work in progress, but I put together a simple algorithm that forecasts unemployment and determines recessions via the dynamic equilibrium model as the monthly data would have become available for the years 1984-2017. Data points for the previous month are released in the first week of the following month. The algorithm determines if the forecast is "good enough" (a tolerance that can be set), and if not it posits a shock.

The animation below shows this in action. The lines are the dates when the algorithm noticed there was a shock (these dates would have been November 1990, July 2001, and March 2008).

The gray dots are the data, and the blue ones are the data available at the time of the forecast (red line). That forecast goes one year ahead.

I definitely want to improve this a bit ‒ for example to use the estimated model error as an indicator of when to apply a shock instead of a fixed tolerance (or even optimize the tolerance value which I set at δ log u = 0.2 because reasons ... dropping this to 0.19 [1] finds the recessions a month earlier). I also need to distinguish between a positive and a negative shock. But I thought it was neat and I try to be open with this research. Please excuse the sorry shape of the code when I put it up on GitHub (ed. up now).

I asked on Twitter if anyone knew where to find out when the Fed or the US government noticed in real time whether there was a recession and am still waiting for input there. I did find this article in the New York Times from 26 September 1990:
At a time when many Americans believe that a recession has descended on the country, they are being told by Government officials to put their worries aside for the moment because other economic issues, mainly inflation, have to be dealt with first. 
This message is coming from the Federal Reserve, but the Bush Administration is not openly challenging the thesis. And the top financial officials of the six other major industrial nations, meeting in Washington this week, have also declared that recession, or the threat of it, is still a second-rung issue. ... 
Millions of Americans, in particular, are experiencing unemployment, wage freezes, bankruptcies and falling real estate prices, and concluding that what they are living through constitutes a recession. How can their perception, reported in public opinion polls, differ so strikingly from that of the Federal Reserve and its counterparts elsewhere? 
The answer is that the central banks remain more worried by the threat of inflation than of recession, and that to ignore the inflationary dangers now will only mean a deeper recession later. ...
This article from 16 November 1990 (which is after the algorithm above would have noticed) notes that economists thought we were in or on the verge of a recession:
President [G.H.W.] Bush conceded for the first time tonight that the country might face a recession, but he said his economic advisers did not believe a long and severe one was in the offing. ...
Most economists are saying that the economy, if not in a recession now, is on the verge of one.
As for July 2001, we have this "quote of the day" from Alan Blinder from the 15th (again, after the model would have noticed):
I'm worried about the consumer -- not putting away their wallets but using them a little less. It wouldn't take much downward movement in consumer spending to cause a recession.
As for March of 2008, Krugman's piece "Partying Like It's 1929" came out at the end of that month as we were all watching the financial system collapsing in the wake of the bubble. Lehman had yet to fail, but Bear Stearns would fail (14-16 March 2008) about a week after the data point the algorithm above would use to predict a recession (7 March 2008).


Update +4 hours

δ log = 0.17 predicts recessions as of September 1990, April 2001, and December 2007 (better than above by 2 months, 3 months, and 3 months, respectively):


Update +5 hours

I just though this was fun:



[1] I ran this again later with the new tolerance of 0.19:


  1. I like this idea a lot. Providing an early warning system for economic shocks is analogous to what we do with earthquakes. Note also that we train people on how to react to the early warning of an earthquake. We also design buildings to withstand a major earthquake and we plan how to recover from an earthquake before the event. Economics as analogous with geology is a better model for me than economics as physics as the important events in economics are probably unforecastable.

    This also raises the issue of why we collect macro data so infrequently. We would get better early warnings if unemployment data was available weekly or even daily. I am always surprised that economists don't see the collection of more detailed, more accurate and more timely data as their biggest challenge. I guess that would be boring science (and hard work) rather than the policy discussions that they enjoy.

    1. Hi Jamie,

      Sorry I missed this comment.

      I agree with more frequent data updates -- some kinds of employment data are available weekly (weekly unemployment claims).

      One issue with these however is that they depend on the various different programs in the individual states in the US as well as the kinds of jobs being lost or gained.

  2. Perhaps you would find daily Treasury receipts helpful too.


Comments are welcome. Please see the Moderation and comment policy.

Also, try to avoid the use of dollar signs as they interfere with my setup of mathjax. I left it set up that way because I think this is funny for an economics blog. You can use € or £ instead.