#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
Module 9
11 min read

Trend & Seasonality

Understand patterns in time series data

What You'll Learn

  • Time series components
  • Identifying trends
  • Detecting seasonality
  • Decomposition methods
  • Detrending and deseasonalizing

What is Time Series Data?

Definition: Data points collected over time at regular intervals

Examples:

  • Daily sales
  • Monthly revenue
  • Hourly website traffic
  • Quarterly earnings
  • Annual GDP

Key feature: Order matters! (Unlike cross-sectional data)

Time Series Components

Four main components:

1. Trend (T) Long-term increase or decrease

2. Seasonality (S) Regular patterns repeating at fixed intervals

3. Cyclical (C) Longer-term fluctuations (business cycles)

4. Irregular/Noise (I) Random variation

Decomposition: Observed = Trend + Seasonal + Cyclical + Irregular

Trend

What it is: Long-term direction of the data

Types:

Upward trend: Sales increasing over years

Downward trend: Newspaper circulation declining

No trend: Stationary data, fluctuating around constant mean

Identifying trend:

  • Visual inspection (line plot)
  • Moving average
  • Regression (time as predictor)

Example: E-commerce sales: $100K (2020) → $150K (2021) → $200K (2022) Clear upward trend!

Seasonality

What it is: Patterns that repeat at fixed, known periods

Common periods:

  • Daily (hourly traffic patterns)
  • Weekly (weekend vs weekday)
  • Monthly (end-of-month effects)
  • Quarterly (seasonal business)
  • Yearly (holidays, weather)

Examples:

Retail sales: Peak in November-December (holidays) Drop in January

Ice cream sales: High in summer Low in winter

Website traffic: High during business hours Low at night

Identifying Seasonality

Visual methods:

1. Line plot Look for repeating patterns

2. Seasonal subseries plot Plot each season separately

3. Autocorrelation plot Spikes at seasonal lags

Statistical tests:

  • Check if pattern repeats
  • Compare variance across seasons

Example: Monthly sales show same pattern each year → Yearly seasonality

Additive vs Multiplicative

Additive model: Y = T + S + I Seasonal variations are constant

Example: Sales always +$10K in December

Multiplicative model: Y = T × S × I Seasonal variations proportional to level

Example: Sales increase by 20% in December

Which to use?

  • Constant seasonal swing → Additive
  • Growing seasonal swing → Multiplicative

Visual test: Plot data

  • Constant amplitude → Additive
  • Increasing amplitude → Multiplicative

Decomposition Methods

Classical decomposition:

Steps:

  1. Calculate trend (moving average)
  2. Remove trend (detrend)
  3. Calculate seasonal component
  4. What remains is irregular

Example (Additive):

  1. Trend: 12-month moving average
  2. Detrended = Observed - Trend
  3. Seasonal: Average detrended values by month
  4. Irregular = Observed - Trend - Seasonal

Moving Average for Trend

Simple moving average: Average of k most recent values

Example: 3-month MA Jan: 100, Feb: 110, Mar: 105 MA for Mar = (100+110+105)/3 = 105

Centered moving average: Better for odd periods

12-month centered MA: Average of months t-6 to t+5 (Centers on month t)

Effect: Smooths out short-term fluctuations Reveals underlying trend

Detrending

Purpose: Remove trend to see other patterns

Methods:

1. Differencing New series = Yt - Yt-1 Removes linear trend

2. Subtraction (Additive) Detrended = Observed - Trend

3. Division (Multiplicative) Detrended = Observed / Trend

Use: Analyze seasonality without trend interference

Seasonal Indices

Additive seasonal indices: Average deviation from trend in each period

Example (Monthly): Jan: -5, Feb: -3, ..., Dec: +15

Interpretation: December sales average $15K above trend

Multiplicative seasonal indices: Average ratio to trend

Example: Jan: 0.95, Feb: 0.97, ..., Dec: 1.15

Interpretation: December sales are 115% of trend

Constraint: Indices should sum to 0 (additive) or average to 1 (multiplicative)

Excel Implementation

Steps:

1. Plot data Insert → Line Chart

2. Calculate moving average Data Analysis → Moving Average

3. Calculate trend Add trendline to chart

4. Detrend =Observed - Trend

5. Calculate seasonal indices =AVERAGE() by period

Formulas:

  • 12-month MA: =AVERAGE(B2:B13)
  • Detrend: =Observed - MA
  • Seasonal: =AVERAGEIF(Month, "Jan", Detrended)

Python Implementation

import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.seasonal import seasonal_decompose

# Load data
df = pd.read_csv('sales.csv', parse_dates=['date'], index_col='date')

# Decompose
decomposition = seasonal_decompose(df['sales'], model='additive', period=12)

# Plot components
fig, axes = plt.subplots(4, 1, figsize=(10, 8))
decomposition.observed.plot(ax=axes[0], title='Observed')
decomposition.trend.plot(ax=axes[1], title='Trend')
decomposition.seasonal.plot(ax=axes[2], title='Seasonal')
decomposition.resid.plot(ax=axes[3], title='Residual')
plt.tight_layout()

# Get seasonal indices
seasonal_indices = decomposition.seasonal.groupby(decomposition.seasonal.index.month).mean()
print(seasonal_indices)

Real-World Example

E-commerce sales (monthly):

Observed pattern:

  • Growing over time (trend)
  • Peaks every December (seasonality)
  • Random fluctuations (noise)

Decomposition:

Trend: Steady growth from $100K to $200K over 3 years

Seasonality:

  • Jan-Oct: Below trend
  • Nov: Slightly above
  • Dec: Significantly above (+30%)

Irregular: Random ups and downs

Insight: Remove seasonality to see true growth Adjust forecasts for December spike

Applications

Business planning: Account for seasonal hiring needs

Inventory management: Stock up before peak season

Marketing: Time campaigns around seasonal patterns

Budgeting: Adjust expectations by season

Forecasting: Incorporate seasonal patterns

Handling Missing Seasonality

If no clear seasonality:

  • May not exist (B2B sales)
  • Period too short to detect
  • Seasonality is weak
  • Data is already deseasonalized

Don't force seasonality!

Deseasonalizing Data

Purpose: Remove seasonal effect to see adjusted values

Additive: Deseasonalized = Observed - Seasonal component

Multiplicative: Deseasonalized = Observed / Seasonal index

Use: Compare periods fairly "Seasonally adjusted" figures in economics

Example: Retail sales always high in December Deseasonalize to compare December to other months

Calendar Effects

Special considerations:

Number of days: February has fewer days

Trading days: Month with more weekends has fewer sales

Holidays: Easter moves between March and April

Solution:

  • Adjust for calendar days
  • Use daily rates instead of monthly totals
  • Account for moving holidays

Cyclical vs Seasonal

Seasonal:

  • Fixed period (monthly, quarterly, yearly)
  • Predictable timing
  • Regular pattern

Cyclical:

  • Variable length (2-10 years)
  • Economic cycles, business cycles
  • Irregular timing

Example:

Seasonal: Ice cream sales peak every summer Cyclical: Housing market boom-bust over ~8 years

Stationarity

Stationary series:

  • Constant mean over time
  • Constant variance
  • No trend, no seasonality

Non-stationary:

  • Trending data
  • Seasonal data
  • Changing variance

Why it matters: Many forecasting methods require stationarity

Make stationary:

  • Differencing (remove trend)
  • Deseasonalizing (remove seasonality)
  • Log transform (stabilize variance)

Practice Exercise

Monthly website traffic (thousands): Jan: 100, Feb: 105, Mar: 110, Apr: 115, May: 120, Jun: 125 Jul: 130, Aug: 135, Sep: 140, Oct: 145, Nov: 150, Dec: 180

Questions:

  1. Is there a trend?
  2. Is there seasonality?
  3. Calculate 3-month moving average for Mar-May
  4. What's unusual about December?

Answers:

  1. Yes, upward trend (increasing monthly)
  2. Weak, but December spike suggests yearly seasonality
  3. Mar: (100+105+110)/3 = 105, Apr: 110, May: 115
  4. December jumps to 180 (much higher than trend)

Common Patterns

Linear trend + yearly seasonality: Retail sales

No trend + daily seasonality: Website traffic (new site)

Exponential trend + quarterly seasonality: SaaS revenue

Multiple seasonality: Hourly + daily + weekly (restaurant sales)

Next Steps

Learn about Moving Averages!

Tip: Always plot your time series first to see patterns visually!

SkillsetMaster - AI, Web Development & Data Analytics Courses