Time Series Lesson 17 – SARIMA | Dataplexa

SARIMA – Modeling Trend and Seasonality Together

In the previous lesson, ARIMA helped us solve one major problem: trend.

But real-world time series rarely stop there. Most of them also repeat patterns at fixed intervals.

This lesson answers one important question:

What if the data has both trend and seasonality?


Why ARIMA Still Fails for Seasonal Data

Consider these examples:

  • Retail sales spike every December
  • Electricity demand rises every summer
  • Website traffic peaks every weekend

Even after removing trend using differencing, the seasonal pattern still remains.

ARIMA does not understand repeating cycles. It only sees short-term correlations.


The Idea Behind SARIMA

SARIMA simply extends ARIMA by adding:

Seasonal AR, Seasonal MA, and Seasonal Differencing

So instead of modeling only:

Past values and errors

We also model:

Past values and errors from previous seasons


SARIMA Model Structure

SARIMA is written as:

SARIMA(p, d, q)(P, D, Q, m)

  • p, d, q → non-seasonal ARIMA
  • P, D, Q → seasonal ARIMA
  • m → length of season

Example:

SARIMA(1,1,1)(1,1,1,12)

This means:

  • Monthly data
  • Yearly seasonality
  • Trend + seasonal differencing

Real-World Analogy

Imagine tracking gym attendance:

  • Overall attendance grows year by year (trend)
  • Attendance drops every weekend (seasonality)

ARIMA handles the growth. SARIMA handles the weekend pattern.

Both are required for accurate forecasting.


Step 1: Create Seasonal Time Series

Let’s simulate data with:

  • Upward trend
  • Clear repeating seasonality
Python: Trend + Seasonality
import numpy as np
import matplotlib.pyplot as plt

np.random.seed(2)
time = np.arange(120)
trend = time * 0.3
seasonal = 15 * np.sin(2 * np.pi * time / 12)
noise = np.random.normal(0, 3, 120)

series = trend + seasonal + noise

plt.plot(series)
plt.title("Seasonal Time Series")
plt.show()

This is what the data actually looks like:

Observation:

  • Overall upward movement
  • Repeating wave every 12 steps
  • Random fluctuations

Step 2: Seasonal Differencing

Seasonal differencing removes repeating cycles.

If season length is 12:

value(t) − value(t−12)

Python: Seasonal Differencing
season_diff = series[12:] - series[:-12]

plt.plot(season_diff)
plt.title("Seasonally Differenced Series")
plt.show()

Here is the seasonal differenced plot:

What changed?

  • Seasonal wave disappears
  • Series fluctuates around zero
  • Much more stable

Step 3: Combine with Trend Differencing

Sometimes one seasonal difference is not enough. We may also apply regular differencing.

This removes:

  • Long-term trend
  • Seasonal repetition

At this stage, the series becomes suitable for AR and MA modeling.


Why SARIMA Works So Well

  • AR → short-term memory
  • MA → error correction
  • d → trend removal
  • D → seasonal removal

Each part solves a specific real-world behavior.


When Should You Use SARIMA?

  • Clear repeating patterns
  • Fixed seasonal interval
  • Strong historical structure

Examples:

  • Monthly sales forecasting
  • Electricity demand
  • Tourism and hotel bookings

Common Mistakes

  • Using ARIMA when seasonality exists
  • Wrong season length (m)
  • Over-differencing the data

Always visualize before modeling.


Practice Questions

Q1. What does “m” represent in SARIMA?

Length of the seasonal cycle (e.g., 12 for monthly data).

Q2. Why is seasonal differencing important?

It removes repeating patterns that ARIMA alone cannot handle.

Key Takeaways

  • ARIMA handles trend
  • SARIMA handles trend + seasonality
  • Visualization is critical before modeling

Next, we’ll see how to add external factors that influence the time series.