Time series and trend analysis challenges inspired by real-world datasets

by SkillAiNest

Time Series and Trend Analysis ChallengeTime Series and Trend Analysis Challenge
Photo by author Canva

# Introduction

Time series data is everywhere. Stock prices jump daily. Temperature shift. Website traffic spikes and crashes. Most people plan a line. Then they stopped.

But here’s what a single chart won’t tell you: Is the trend accelerating? Getting lazy? Is it completely reversible?

In this article, we will analyze real inflation expectations using three complementary techniques: Moving averagefor , for , for , . Changes from year to yearand Bollinger Bands.

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

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

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

# Making sense of our dataset: Decoding the 10-year breakeven inflation rate

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

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

// What does it mean?

If T10yie = 2.5%, the market expects average annual inflation over 10 years. Higher values ​​tend to strengthen inflation expectations. Lower values ​​imply weak inflation or deflation fears.

// Why Economists and the Fed Watch the Rate Like Hawks

The Federal Reserve watches this metric closely. A rising breakeven rate signals concerns about inflation that could be mobilizing Federal Reserve interest rate hikes. Sharp drops can indicate recessionary concerns or deflationary pressures.

// Our data at a glance: 5 years of inflation expectations (2020–2025)

Now we will use This The 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 stratascratch. It is a platform for accessing authoritative datasets used in finance, technology, and public data sources.

// Getting to Know Statistics: 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 observations.
  • 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 rows. The code is:

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()

The output is:

Time Series and Trend Analysis ChallengeTime Series and Trend Analysis Challenge

This is a simple dataset, containing 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 Averages

Moving average smooths short-term fluctuations. They show basic trends. Take the 30-day moving average. It calculates the average of the last 30 days. The result? A smooth line that filters out everyday noise.

Financial markets are in turmoil. News headlines increase at daily rates. They fall on earnings reports. Geopolitical events send them that way. Average by cutting them all. They show you the actual trend direction beneath the chaos.

Types:

  • Short-term MA (30 days): Captures recent shifts.
  • Long-term MA (90 days): Shows the direction of the broader trend.
    • Crossovers: When the short MA crosses over the long MA = uptrend signal.

The code is:

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()

The output is:

Time Series and Trend Analysis ChallengeTime Series and Trend Analysis Challenge

// Results and interpretation

Moving averages show distinct patterns over the five years of inflation expectations.

Step 1: Fast Recovery (Days 0-200)
Both averages climb sharply from 1.7% to 2.4%. The 30-day MA is bullish. This period captured him After the subsequent economic reopening. On a large scale Financial incentives Inflation expectations pushed upward.

Phase 2: Period of High Volatility (Days 200-500)
The daily rate increases to 3.0% around day 400. The 30-day MA reaches 2.9%. It is similar 2022 inflation increase. Constraints in the supply chain hit Russia invaded Ukraine. Energy prices exploded.

Phase 3: Decline (Days 500-1000)
The 30-day MA tends to be bullish, falling to 2.2% near day 1000. The Fed hikes aggressively in 2022 and 2023. Inflation expectations cooled as policy worked.

Phase 4: Recent Stabilization (Days 1000-1300)
The 30-day MA hovers around 2.3% to 2.4%. Minimum volatility. Markets seem confident that inflation is near normal Fed’s 2% target. Rate hikes stalled.

Key insights
The 30-day MA captured every milestone quickly. When it climbed sharply in early 2021, a rise in inflation resulted. When it falls in mid-2022, cooling begins. The current stability suggests that markets believe that the inflationary shock has passed.

// Technique 2: Change from year to year

The year-over-year (YOY) change compares the price on the same day a year ago. The answer is: “Are inflation expectations higher or lower than they were 12 months ago?”

It removes seasonal noise and shows pure directional speed. Positive values ​​= Expectations are increasing year on year. Negative values ​​= expectations fall year over year. Zero = flat trend.

Here is the formula to calculate the YOY change, where \(V_T\) is the current price and \(V_{T-365}\) is the price for one year (about 25 252 trading days): First:

$$
\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()

The output is:

Time Series and Trend Analysis ChallengeTime Series and Trend Analysis Challenge

// Results and interpretation

The YOY change chart divides inflation expectations into green and red zones. Green means speed up. Red means crap. This suggests that the velocity has completely missed the actual rate chart.

First Green Zone (Days 250-500)
Inflation expectations rose sharply. Year-on-year changes came in at +1.0%. This period? 2021 to 2022. The supply chain collapsed. Stimulus checks flooded the economy. Russia invaded Ukraine. Energy prices exploded.

Red Zone (Days 500-1000)
Expectations were shattered. They fell to -0.75% year-on-year. The Federal Reserve hikes aggressively in 2022 and 2023. Markets believed that inflation would cool down. They were right.

Second Green Zone (Days 1000-1300)
Small positive changes returned. They fluctuate between +0.1% and +0.3%. Expectations stopped falling. They started consolidating above last year’s levels. Don’t worry about it, as usual.

Signals for the future
Recent green patches pale in comparison to the 2022 surge. YOY changes below +0.25%? Expectations remain anchored. Sustained movement above +0.5%? This will help to address the concerns of renewed inflation.

// Technique 3: Bollinger Bands (Volatility Envelope)

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

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

Composition:

  • Middle band: 20-day moving average.
  • Upper band: median + (2 × standard deviation).
  • Lower Band: Median – (2 × Standard Deviation)

The created threshold 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{less} = \mu_{20} – (2 \times \sigma_{20})
$$

The code is:

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()

The output is:

Time Series and Trend Analysis ChallengeTime Series and Trend Analysis Challenge

// Results and interpretation

Bollinger bands identify when inflation expectations were extreme compared to normal.

Band Extension (Days 350-450)
The daily rate repeatedly breaks the upper band, targeting 3.0%. This period captured him 2022 inflation panics During the Russia-Ukraine War When the market fluctuates.

Upper band violation
The upper band (day 200, 400) signals several touches of market panic, with expectations moving beyond normal ranges. Each breach has warned that inflationary concerns are escalating.

Band Contraction (Days 800-1200)
Bands become significantly narrower as they stay within the band. This shows that the volatility collapsed as soon as it collapsed The Fed rate hike worked And the markets reached a consensus.

Lower Band Touch (Day 1050)
The rate briefly hit the lower band at 2.05%, indicating unusual bearishness at the end of 2023. There is a fear of recession.

Signals for the future
The current narrow band and stable rate (2.35%) indicates normal market behavior. A breach of a new upper band above 2.5 percent would signal fears of renewed inflation.

# 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 rates from 2020 to 2025 revealed different patterns using each technique.

Although global events such as the Russia-Ukraine invasion or the energy crisis affect all analyses, each technique interprets their impact differently. Moving averages can show a gradual trend shift, a year-over-year change can highlight a sharp swing, while Bollinger Bands can develop the same period as an increase in volatility.

That’s why it’s important to choose your trend analysis technique. It shapes how you see the story in your data. Depending on your analytical lens, the same event can look like recovery, instability, or normalcy.

# The result

The real lesson is not which technique is best. It’s knowing which one to use. All three approaches work on stock prices, web traffic, sales figures, or anything that moves over time. The patterns are there. You just need the right tools to see them.

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

Nate Rosedy A data scientist and product strategist. He is also an adjunct professor teaching analytics, and the founder of StrataScratch, a platform that helps data scientists prepare for their interviews with real interview questions from top companies. Netcareer writes on the latest trends in the market, gives interview tips, shares data science projects, and covers everything SQL.

You may also like

Leave a Comment

At Skillainest, we believe the future belongs to those who embrace AI, upgrade their skills, and stay ahead of the curve.

Get latest news

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

@2025 Skillainest.Designed and Developed by Pro