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
angular apps

Angular Apps: Top 7 Web Application Examples, Advantages, and Considerations

Angular is a leading development tool for building sophisticated web apps. Check out the top applications fueled by this Google-backed platform and learn about its strengths and weaknesses. Angular is a household name in the front-end development industry and the key competitor of React (aka ReactJS). As one of the leading web development frameworks, it […]

ux writing samples

UX Writing Samples. How to Enhance Usability With Effective Microcopy?

Text is an integral part of UI design and user experience. High-quality, usability-focused copy helps engage users and turn them into customers. User experience (UX) writing is much more than a buzzword. It combines writing proficiency and inventiveness with a strong focus on user actions. The goal is to make things smooth, easy, and informative […]

gregg castano news direct

How to Pick a Good Software Partner? Q&A with Gregg Castano of News Direct  

A few years ago, we had the opportunity to work with News Direct on developing their platform. After carefully analyzing their needs, we’ve helped them design the system and developed a microservices-based architecture incorporating state-of-the-art modern technology allowing for communication using both synchronous and asynchronous calls to ensure high system flexibility and scalability. The main […]

cert pinning android

Mobile Development and Security: Certificate Pinning on Android

In today’s increasingly interconnected digital world, the importance of security for mobile apps and web services cannot be overstated. As cyber threats evolve, so must the defenses and measures we deploy to safeguard sensitive data and maintain trust. One of the pivotal practices in enhancing network security is certificate pinning, a technique that ensures a […]

django apps

Django Apps, Projects, and Other Caveats

Django, emerging as a significant player in the realm of web frameworks, stands out as a Python-based toolset that revolutionizes the way developers approach web application development. It is not merely a framework but a holistic environment that encapsulates a developer’s needs for building robust, efficient, and scalable web applications. Born out of a practical […]

rxjs react

RxJs & React: Reactive State Management

In the ever-evolving realm of web development, the quest for efficient, scalable, and maintainable tools never ends. Two such tools, React and RxJS, have garnered significant attention in the recent past. React, the brainchild of Facebook focuses on crafting intuitive user interfaces by leveraging a component-based architecture. On the other hand, RxJS offers a fresh […]

Related posts
gregg castano news direct

How to Pick a Good Software Partner? Q&A with Gregg Castano of News Direct  

A few years ago, we had the opportunity to work with News Direct on developing their platform. After carefully analyzing their needs, we’ve helped them design the system and developed a microservices-based architecture incorporating state-of-the-art modern technology allowing for communication using both synchronous and asynchronous calls to ensure high system flexibility and scalability. The main […]

new york tech meetup

New York Tech Meetup Scene

In the bustling landscape of New York’s tech scene, a vibrant array of events and meetups provide a dynamic platform for knowledge exchange, networking, and innovation. Tech meetups, characterized by engaging presentations from industry experts, foster an atmosphere of collaborative learning and idea sharing. How to engage with that type of event? What To Expect […]

product roadmap example

Which Way To Go – Product Roadmap Example And Insights

A quick overview of product roadmaps, not only for product managers. Briefly, What Is A Product Roadmap? A product roadmap is a visual representation that outlines a product development and evolution over a defined period, serving as a communication tool to align stakeholders around the product’s direction, goals, and milestones. In general terms, the roadmap […]

smart retail

Smart retail solutions: how can they help your business grow?

Smart technologies are transforming the retail industry at an increasing rate. Brick-and-mortar stores are going digital to drive more sales and keep up with the competition. Find out about top solutions fueling retail growth and how they can benefit your business. Blockbuster, Borders, Barnes & Noble, Sears, and Toys R Us are but a few […]

predictive analytics retail

Predictive Analytics: Retail Industry Use Cases

Retail businesses have always been driven by data, whether it’s sales figures, inventory levels, or customer behavior. With the rise of predictive analytics, retailers have the ability to analyze large volumes of data to uncover data-driven insights and patterns that can help them make more informed decisions. Predictive analytics is a branch of advanced analytics […]

project manager vs product manager

Product Manager vs Project Manager: Main Differences and Similarities

In today’s fast-paced and highly competitive business world, organizations need to have a clear understanding of the differences between a product manager and a project manager. While both roles are critical to the success of a company, they have distinct roles and responsibilities. In this article, we will explore the similarities, differences, and roles of […]

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