Economy business cycle prediction using LSTM neural networks

Tags
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:

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

Contraction
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.

Results

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.

Summary

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.

[1] https://www.investopedia.com/terms/e/expansion.asp[2] https://www.investopedia.com/terms/c/contraction.asp

Michał Olędzki

Latest Posts
now next later roadmap

Navigate Easily: A Step-by-Step Guide to the Now Next Later Roadmap

Let’s be honest – strategic planning is essential for successful product management. The Now-Next-Later roadmap is a powerful tool that helps teams prioritize tasks, streamline efforts, and align stakeholders. This guide delves into the intricacies of this roadmap, providing a comprehensive overview of its benefits and implementation. But first, let’s get some basics down for […]

/

Scrum: How to Work Together

With the popularity of the scrum framework among software development teams, it’s growingly important to learn how a scrum team works to meet its goals. Scrum Process Overview Scrum is an agile project management framework widely used in IT but can be applied to other fields as well. The framework facilitates the management of complex […]

/
event storming

Event Storming: How to Boost Your Software Development Process with a Simple Technique?

Event storming is a dynamic workshop technique that supports domain-driven design in software development. It can boost the team’s efficiency and reduce error risk, minimizing the back-and-forth in the development lifecycle. If you haven’t been living under a rock, you’re probably familiar with the concept of brainstorming. It’s a widely used term for the process […]

/
rails vs sinatra

Rails vs Sinatra

In the rapidly evolving world of software development, web frameworks have become essential tools for building robust and scalable web applications. These frameworks provide a structured environment that streamlines the development process, offering pre-written code, libraries, and guidelines that help developers avoid repetitive coding tasks, thus significantly enhancing productivity and ensuring best practices. Within the […]

/
android webstockets

Introduction to Android WebSocket

WebSockets have become a pivotal technology in enabling real-time communication for Android apps, offering a dynamic way to send and receive messages instantaneously. This technology facilitates a persistent connection between the client (Android app) and the server, bypassing the traditional HTTP request-response model to allow continuous data flow through a single TCP connection. The WebSocket […]

/
smart contracts audit

Introduction to Smart Contract Audits

In the blockchain world, smart contracts are key to decentralized applications (dApps), automating transactions and enforcing agreements without intermediaries. These contracts handle significant digital assets and perform crucial operations, making their security paramount. Smart contract audits are thus essential, scrutinizing the contract’s code for vulnerabilities to prevent potential security breaches. These audits are crucial for […]

/
Related posts
data science for finance

Data Science in Finance: Who is a Data Scientist and What They Do?

In the dynamic world of finance, staying ahead of the curve requires more than just traditional methods. As technology continues to evolve, the role of data science becomes increasingly crucial in deciphering complex financial landscapes. In this article, we’ll delve into the significance of data science in finance, its applications, the responsibilities of financial data […]

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

/
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