Time Series and Trend Analysis Challenge Inspired by Real World Datasets

by
0 comments
Time Series and Trend Analysis Challenge Inspired by Real World Datasets

Time Series and Trend Analysis Challenge
Image by author | Canva

, Introduction

Time series data is everywhere. Stock prices jump every day. Temperature changes. Website traffic spikes and crashes. Most people draw a line. Then they stop.

But here’s what a single chart won’t tell you: Is the trend bullish? slowing down? Is it going to completely reverse?

In this article, we will analyze actual inflation expectations using three complementary techniques: moving average, year-on-year changeAnd Bollinger Bands,

Time Series and Trend Analysis ChallengeTime Series and Trend Analysis Challenge
Image by author

Each method answers a different question about the same data. Moving averages highlight the direction of the trend, year-to-year changes highlight changes in momentum, and Bollinger Bands highlight periods of extreme movement.

We will use those techniques to analyze the 5-year inflation data trend from October 2020 to October 2025.

, Understanding our dataset: Decoding the 10-year breakeven inflation rate

To understand our dataset, we first need to understand the metric it is built on: the 10-year breakeven inflation rate (T10YIE).

T10YIE represents the market’s inflation expectations over the next decade. Simple math: Subtract the inflation-protected Treasury yield from the regular Treasury yield.

, What does it mean?

If T10YIE = 2.5%, the market expects 2.5% average annual inflation over 10 years. Higher values ​​indicate stronger inflation expectations. Lower values ​​indicate weak inflation or deflation fears.

, Why economists and the Fed watch this rate like hawks

The Federal Reserve watches this metric closely. Rising disbursement rates indicate inflation concerns that could trigger Federal Reserve increases interest ratesA sharp decline could signal recession fears or deflationary pressures,

, Our data at a glance: 5 years of inflation expectations (2020-2025)

Now we will use it dataset

Time Series and Trend Analysis ChallengeTime Series and Trend Analysis Challenge
Screenshot | fred

Click “Download” to save the file to your machine.

If you’re interested in exploring similar real-world datasets and practicing data analysis and visualization, check out stratscratchIt is a platform to access authentic datasets used in finance, technology and public data sources,

, Getting familiar with data: structure, sources, and summary statistics

Here is some information about our dataset:

  • Source: Federal Reserve Economic Data (FRED).
  • Time Period: October 2020 – October 2025 (5 years).
  • Frequency: Daily observation.
  • Total observations: 1,305 data points.
  • Range: 1.64% to 3.02%.
  • Average: 2.33%.

Let’s read this dataset and look at the first few lines. Here is the code:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

df= pd.read_csv("T10YIE.csv")
df.head()

Here is the output:

Time Series and Trend Analysis ChallengeTime Series and Trend Analysis Challenge

This is a simple dataset, with only two columns: observation_date And T10YIE,

, Trend Analysis: Three Techniques for Time Series Insights

We will start with the moving average technique.

, Technique 1: Moving Average

Moving averages smooth out short-term fluctuations. They reveal underlying tendencies. Take the 30-day moving average. It calculates the mean of the last 30 days. outcome? A smooth line that filters out daily noise.

Financial markets are disorganized. Daily rates increase in response to news headlines. They decline to report earnings. Geopolitical events push them aside. Moving averages cut through all this. They show you the real trend direction beneath the chaos.

Type:

  • Short-term MA (30 days): Reflects recent changes.
  • Long-term MA (90 days): Shows the broad trend direction.
    • Crossover: When the shorter MA crosses above the longer MA = uptrend signal.

Here is the code:

df('T10YIE') = df('T10YIE').ffill()
df('MA_30') = df('T10YIE').rolling(window=30).mean()
df('MA_90') = df('T10YIE').rolling(window=90).mean()

plt.figure(figsize=(15, 7))

plt.plot(df.index, df('T10YIE'), label="Daily Rate", alpha=0.4, linewidth=0.8, color="gray")
plt.plot(df.index, df('MA_30'), label="30-Day MA", linewidth=2, color="blue")
plt.plot(df.index, df('MA_90'), label="90-Day MA", linewidth=2, color="red")

plt.axvspan(0, 200, color="palegreen", alpha=0.3, label="Phase 1: Recovery")
plt.axvspan(200, 500, color="lightcoral", alpha=0.3, label="Phase 2: Volatility")
plt.axvspan(500, 1000, color="lightblue", alpha=0.3, label="Phase 3: Decline")
plt.axvspan(1000, df.index(-1), color="plum", alpha=0.3, label="Phase 4: Stabilization")

plt.title('Breakeven Inflation Rate with Highlighted Phases', fontsize=14, fontweight="bold")
plt.ylabel('Inflation Rate (%)')
plt.xlabel('Date')
plt.grid(True, alpha=0.3)

plt.legend(loc="upper right")

plt.tight_layout()
plt.show()

Here is the output:

Time Series and Trend Analysis ChallengeTime Series and Trend Analysis Challenge

, Results and interpretation

Moving averages of inflation expectations reveal different patterns over five years.

Phase 1: Acute Recovery (Days 0-200)
Both averages climb sharply from 1.7% to 2.4%. The 30-day MA rises sharply. This period captures economic reopening after covidon a large scale fiscal stimulus Inflation expectations moved upward.

Phase 2: High Volatility Period (Days 200-500)
Daily rates increase to 3.0% around day 400. The 30-day MA reaches 2.9%. this matches 2022 inflation increase, supply chain disruption Strike. Russia invaded Ukraine, Energy prices explode,

Stage 3: Decline (days 500-1000)
The 30-day MA has a sharp falling trend, falling to 2.2% near 1000 day. Fed raises rates aggressively through 2022 and 2023As the policy worked, inflation expectations declined,

Phase 4: Recent Stabilization (Days 1000-1300)
The 30-day MA hovers around 2.3% to 2.4%. Minimum fluctuations. Market confident that inflation is nearing normal Fed’s 2% target, rate hike halted,

Key Insights
The 30-day MA caught every important turning point early. When it rose sharply in early 2021, inflation increased. When it declined in mid-2022, a cooldown began. The current stability suggests that the market is confident that the inflation shock has passed.

, Technique 2: Year-to-Year Variation

Year-over-year (YoY) change compares today’s value with the same day a year ago. The answer is: “Are inflation expectations higher or lower than 12 months ago?”

It removes seasonal noise and shows pure directional motion. Positive values ​​= increasing expectations year after year. Negative value = falling expectations year-over-year. Zero = flat trend.

Here is the formula to calculate the year-on-year change, where ( V_t ) is the current price and ( V_{t-365} ) is the price from one year ago (about 252 trading days):

,
text{YoY Change} = V_t – V_{t-365}
,

In code, it looks like this:

import pandas as pd
import matplotlib.pyplot as plt

df('T10YIE') = df('T10YIE').ffill()
# Calculating diff based on trading days (approx 252 per year)
df('YoY_Change') = df('T10YIE').diff(252)

fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(14, 10), sharex=True)

ax1.plot(df.index, df('T10YIE'), color="blue", linewidth=1)
ax1.set_ylabel('Inflation Rate (%)')
ax1.set_title('Breakeven Inflation Rate (Original)', fontsize=12, fontweight="bold")
ax1.grid(True, alpha=0.3)

ax2.plot(df.index, df('YoY_Change'), color="darkred", linewidth=1.5)
ax2.axhline(y=0, color="black", linestyle="--", linewidth=1.5, alpha=0.7)

ax2.fill_between(df.index, df('YoY_Change'), 0,
    where=(df('YoY_Change') > 0), color="green", alpha=0.3, label="Rising YoY")
ax2.fill_between(df.index, df('YoY_Change'), 0,
    where=(df('YoY_Change') <= 0), color="red", alpha=0.3, label="Falling YoY")
ax2.set_ylabel('YoY Change (%)')
ax2.set_xlabel('Date')
ax2.set_title('Year-over-Year Change in Inflation Expectations', fontsize=12, fontweight="bold")
ax2.grid(True, alpha=0.3)

# First Green Zone (Days 250-500)
ax1.axvspan(250, 500, color="palegreen", alpha=0.4, label="First Green Zone")
ax2.axvspan(250, 500, color="palegreen", alpha=0.4)

# Red Zone (Days 500-1000)
ax1.axvspan(500, 1000, color="lightcoral", alpha=0.4, label="Red Zone")
ax2.axvspan(500, 1000, color="lightcoral", alpha=0.4)

# Second Green Zone (Days 1000-1300)
ax1.axvspan(1000, df.index(-1), color="mediumaquamarine", alpha=0.4, label="Second Green Zone")
ax2.axvspan(1000, df.index(-1), color="mediumaquamarine", alpha=0.4)

ax1.legend(loc="upper left")
ax2.legend(loc="upper left")

plt.tight_layout()
plt.show()

Here is the output:

Time Series and Trend Analysis ChallengeTime Series and Trend Analysis Challenge

, Results and interpretation

The year-on-year change chart divides inflation expectations into green and red areas. Green means to accelerate. Red means reducing speed. This shows that the momentum completely changes the fundamental rate chart.

First Green Zone (days 250-500)
Inflation expectations rose sharply. The year-over-year change peaked at +1.0%. this period? 2021 to 2022. Supply chains collapsed, Stimulus checks flood the economy, Russia invaded Ukraine, Energy prices explode,

Red Zone (days 500-1000)
Hopes were dashed. They fell by -0.75% year-on-year. Federal Reserve raises rates aggressively through 2022 and 2023Markets were confident that inflation would calm down, They were right,

Second green zone (day 1000-1300)
Small positive changes returned. They oscillated between +0.1% and +0.3%. Expectations stopped falling. They began to stabilize above last year’s levels. This is a sign of normalization, not panic.

signs for the future
The recent green spots pale in comparison to the 2022 surge. Year-over-year change below +0.25%? Hopes remain dashed. Sustained speed above +0.5%? This will renew inflation concerns worth watching.

, Technique 3: Bollinger Bands (Volatility Envelope)

Bollinger Bands create an upper and lower bound around a moving average using the standard deviation. The bands expand during volatile periods and contract during calm periods.

Shows when inflation expectations are “normal” (inside the band) versus “excessive” (outside the band). When the rate touches the upper band, it is abnormally high. When it touches the lower band, it is abnormally low.

Structure:

  • Middle band: 20-day moving average.
  • Upper band: middle + (2 × standard deviation).
  • Lower band: Middle – (2 × standard deviation).

The range created means that 95% of the data should fall within the band. This can be formally expressed as:

,
text{upper} = mu_{20} + (2 times sigma_{20})
,
,
text{bottom} = mu_{20} – (2 times sigma_{20})
,

Here is the code:

df('T10YIE') = df('T10YIE').ffill()

window = 20
df('BB_Middle') = df('T10YIE').rolling(window=window).mean()
df('BB_Std') = df('T10YIE').rolling(window=window).std()
df('BB_Upper') = df('BB_Middle') + (2 * df('BB_Std'))
df('BB_Lower') = df('BB_Middle') - (2 * df('BB_Std'))

plt.figure(figsize=(15, 7))

plt.plot(df.index, df('T10YIE'), label="Daily Rate", color="black", linewidth=0.8)
plt.plot(df.index, df('BB_Middle'), label="20-Day MA", color="blue", linewidth=1.5)
plt.plot(df.index, df('BB_Upper'), label="Upper Band", color="red", linewidth=1, linestyle="--")
plt.plot(df.index, df('BB_Lower'), label="Lower Band", color="green", linewidth=1, linestyle="--")
plt.fill_between(df.index, df('BB_Upper'), df('BB_Lower'), alpha=0.1, color="gray")

plt.axvspan(350, 450, color="gold", alpha=0.3, label="Band Expansion (Volatility↑)")
plt.axvspan(800, 1200, color="lightblue", alpha=0.3, label="Band Contraction (Volatility↓)")

plt.axvspan(190, 210, color="lightcoral", alpha=0.5, label="Upper Breach (~Day 200)")
plt.axvspan(390, 410, color="lightcoral", alpha=0.5, label="Upper Breach (~Day 400)")

plt.axvspan(1040, 1060, color="palegreen", alpha=0.5, label="Lower Touch (~Day 1050)")

plt.title('Breakeven Inflation Rate with Bollinger Bands & Key Events', fontsize=14, fontweight="bold")
plt.ylabel('Inflation Rate (%)')
plt.xlabel('Date')
plt.grid(True, alpha=0.3)
plt.legend(loc="upper left")

plt.tight_layout()
plt.show()

Here is the output:

Time Series and Trend Analysis ChallengeTime Series and Trend Analysis Challenge

, Results and interpretation

Bollinger Bands identify when inflation expectations were normal versus extreme.

Band expansion (day 350-450)
As the daily rate repeatedly breaks the upper band, reaching 3.0%, the band widens dramatically. captured this period 2022 inflation terror during Russia-Ukraine war When market volatility was at its peak.

upper band violation
Repeated touching of the upper band (day 200, 400) indicates nervousness in the market, expectations go beyond the normal range. Each breach warned that inflation fears were intensifying.

Band contraction (days 800-1200)
The bands become much narrower with increasing residence rate. This shows that volatility has collapsed Fed rate hike worked And the markets reached a consensus.

Lower Band Touch (Day 1050)
The rate briefly touched the lower band of 2.05%, indicating unusual pessimism towards the end of 2023 fear of recession,

signs for the future
The current narrow band and stable rate (2.35%) indicate normal market behavior. A new upper band breach above 2.5% would signal renewed inflation concerns.

, Different techniques, different stories

Trend analysis is not about predicting the future; It’s about understanding what the data is telling you. The 10-year breakeven inflation rate from 2020 to 2025 revealed different patterns using each technique.

Even though global events such as the Russia–Ukraine invasion or the energy crisis affect all analyses, each technique interprets their impact differently. A moving average can show a gradual trend change, a year-to-date change can highlight sharp ups and downs, while Bollinger Bands can depict the same period as a spike in volatility.

That’s why choosing your trend analysis technique matters; It shapes how you see the story in your data. The same phenomenon may look like recovery, volatility, or normalization depending on the analytical lens you use.

, conclusion

The real lesson is not which technology is best; It’s about knowing when to use which one. These three approaches work on stock prices, web traffic, sales data, or anything that increases over time. The patterns are there. You just need the right equipment to see them.

In other words, data rarely speaks with one voice. The method you choose determines the message you hear. That’s why trend analysis is as much about interpretation as it is about calculation.

Nate Rosidi Is a data scientist and is into product strategy. He is also an adjunct professor teaching analytics, and is the founder of StratScratch, a platform that helps data scientists prepare for their interviews with real interview questions from top companies. Nate writes on the latest trends in the career market, gives interview advice, shares data science projects, and covers everything SQL.

Related Articles

Leave a Comment