Economy business cycle prediction using LSTM neural networks

4 April 2022
Complete Guide for CTO & IT Directors
Microservices under X-Ray Three books image Download free ebook

Economy as a whole goes through business cycles that consist of alternating expansions and contractions. It is not immediately obvious  what cycle the economy is currently in; it is difficult to tell if it is at the peak of an expansion or the trough of a contraction. The ability to predict economy cycles would be invaluable.  Such insight would enable preparation for contraction periods such as asset protection.

Definitions of business cycles

Investopedia [1] defines the expansion and contraction business cycles as follows:

Gross Domestic Product (GDP) rises
Unemployment declines
Per capita income grows
Consumers start spending
Money is cheap to borrow

GDP declines
Unemployment rises
Per capita income declines
Consumers save money
Money is expensive to borrow

However, precisely defining terms such as “rise” and “decline” is not easy. According to most economists [2], contraction occurs when GDP declines for more than two consecutive quarters. Yet this is not always true, as illustrated by Figure 1. Grey regions mark contraction periods in the US economy as defined by the National Bureau of Economic Research (NBER). Consecutive declines in GDP appear only in the 1950s and during the 2008 crisis. Other contractions corresponded to at least some growth in GDP.

However, other business cycle indicators do behave according to the expectations of economists.  Two examples are Gross Domestic Product per Capita (GDPC1) and Unemployment Rate (UNRATE). GDPC1 seems to follow the rule of two consecutive quarters. Unemployment Rate typically increases during contractions, but there are some periods where UNRATE increased despite an expanding economy.

Regardless, the rule of two consecutive quarters cannot provide insight to whether a contraction is occurring sooner than six months after the contraction has begun; it has no predictive value.  However, there is a solution.  Machine learning can be used to capture the patterns that occur in economic indices and predict upcoming economic cycles.

You may have noticed that charts presented so far end at year 2020.  This is intentional, because changes in UNRATE and GDPC1 during the first months of the COVID-19 pandemic were so significant that they would skew the scale of the plot (and make it difficult to read). Everything discussed so far also applies to the COVID-19 crisis, as will be shown in the next section.

LSTM for economy cycle prediction

Long-Short Term Memory (LSTM) cells are neural network cells that can process sequences of data. This makes them particularly useful for analyzing text or time-series data. In our use case, economic indices are an example of multivariate time-series data; there are multiple variables for each time point.

Data preparation

We need at least six months of data to determine if GDP has decreased twice in a row. For our network, let’s choose 24 months of data to look at. Based on the last two years, the model will try to predict the economic cycle in the following month.
Economic indices data can be tricky to work with because some indices are updated monthly, like Unemployment Rate, and others quarterly, like GDP and GDPC1. Therefore, a table with monthly data values will have None for some fields, as shown in Table 1. This may be a problem during learning, since inputs with quarterly data will periodically go on and off even though GDP data was consistently available over the two years.
To solve this problem, we must divide the input data into two parts. The first part will contain 24 time points with data like UNRATE. The second part will be modified quarterly data such that all numeric values occupy the first 8 time points and the remaining 16 points (the Nones) will always be zeros. Dividing the data enables inputs to process either monthly or quarterly data.


Model predictions are shown in Figure 4. Colored regions correspond to periods of contraction. Green and blue regions represent months during which the model accurately and inaccurately predicted contractions, respectively. Red regions would correspond to months with contraction that were not predicted by the model; such months do not exist.
It can be concluded that the model performs satisfyingly well. It is overly pessimistic such that it indicates contraction sooner and longer than reality. But that is a good feature; it is better to be cautious with investments for an extra month or two rather than lose significant money during an unexpected crisis.

Definite confirmation of model correctness

The described model was developed during fall of 2020. At that time, the last known NBER decision was that the economy was at an expansion peak in February 2020. Theoretically, contraction should have lasted at least six months after that. However, the model consistently showed that contraction lasted no longer that three months. When NBER next convened, they decided that the COVID-19 contraction was only two months long, which confirmed the model’s predictions.


We created a successful model capable of predicting the economy cycle during the upcoming month. Model correctness was confirmed during the COVID-19 crisis. Using LSTM cells, we were able to improve insight to when contractions occur; instead of having to wait two consecutive quarters, we can predict contractions one month prior to when they start. With similar accuracy, we can predict when a contraction will stop.


Michał Olędzki

Talk with experts

We look forward to hearing from you to start expanding your business together.

Email icon [email protected] Phone icon +1 (888) 413 3806