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

Latest Posts
invision vs figma

InVision vs. Figma: Key Features, Differences, and Similarities.

Figma and InVision rank among the best UI design tools. Learn about their key features and how they can speed up front-end development. It’s hard to overstate the importance of UI design in web and mobile development. To be successful a digital product needs to be an eye-pleaser and a UX gem, in addition to […]

flutter language logo

Flutter: the number one framework for building cross-platform apps

Flutter is an SDK for building fast apps for different platforms. It comes with comprehensive development tools and streamlines designing high-performance UIs. Find out why Flutter is a top-quality and cost-effective alternative to native app development. Flutter is Google’s open-source toolkit for developing high-fidelity cross-platform applications. It allows you to create native software for Android […]

django hosting

Hosting for Django? Here’s what you need to know.

Django is a robust web framework for Python that enables programmers to swiftly build web apps. But once you’ve built your application, the next step is to get it online and available to the world. That’s where hosting comes in. In this article, we will explore the various options available for hosting Django applications. Types […]

front end technologies

Top-ranking front-end technologies. Best tools to speed up UI development in 2023

Flawless UI is a must if your app is headed for success. Designing a high-quality front-end can be costly and time-consuming, but not so much if you’re able to choose the right toolset for your product. Find out the best front-end development options to consider in 2023. Back-end powers the functionality of the system, while […]

nodejs books

Top 7 Node.js Books for Both Beginner and Professional Developers

Looking to advance your expertise in Node.js? If you’re tired of chaotic online resources, try good old-fashioned books. They will provide you with structured knowledge and give you a clear understanding of even the most complex programming concepts. Node.js is an asynchronous, event-driven, backend JavaScript runtime designed to develop scalable network applications. As a cross-platform […]

AR in fashion

AR in Fashion. Key Benefits and Real Use Cases

AR technology has already taken root in many industries. One of them is fashion. Clothing, beauty, and retail brands have long been leveraging AR solutions to attract customers and boost sales. According to recent estimates, the number of mobile augmented reality (AR) users worldwide will reach 1.7 billion by 2024 – a huge rise from […]

Related posts
App Store Optimization Google Play

App Store Optimization: Google Play Store

Whenever new mobile apps for Android are released, one of the essential things to do is Google Play store app optimization. After all, the more target users you reach, the better the chance of success and the more user feedback you can gather. The two main app stores for listing mobile applications are Google Play […]


Let’s meet at TechCrunch Disrupt 2022!

Hi! My name is Marcin and I’m the CEO of NG Logic LLC. I’m on the TC Disrupt 2022 and luckily so are you! If you only wish for it I’ll be happy to meet you and talk about your company’s software challenges. Why should we meet? I can think of a few reasons. We […]


NG Logic is One of the Top 100 Companies in Clutch this 2022

At NG Logic, we focus on creating and developing innovative IT and software solutions and building software product development teams for our clients. With over 2 decades of experience in the market, we are confident that we are equipped with the right tools and experience to handle any project that you may have. Our bespoke […]


Diversify your portfolio by adding single stock

The main strategy for creating a successful portfolio is to diversify your investments. If you put all your funds into one asset, you can easily lose a lot of money. When you invest in assets that behave differently on the market, you minimize the risk that all of them will lose their value simultaneously. Expert […]


Economy business cycle prediction using LSTM neural networks

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 […]


NG Logic Proud to be Named a Top Development Firm by Clutch

Here at NG Logic, we know how difficult it can be to achieve your goals while also making sure your staff remains healthy during the ongoing COVID-19 pandemic. Rest assured that we’re here to help craft wonderful innovative IT solutions that will help you grow your business during these troubling times. We design custom applications to perform […]

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