09 — Classical Models

SARIMA#

ClassicalStatistical 1 min read
◆ The PatternARIMA with seasonal intelligence

SARIMA(p,d,q)(P,D,Q)m adds seasonal AR, differencing, and MA terms at seasonal lag m. This captures repeating patterns at fixed intervals — weekly (m=7), monthly (m=12), quarterly (m=4).

SARIMA(p,d,q)(P,D,Q)m
Lowercase = non-seasonal orders. Uppercase = seasonal orders at lag m. The model simultaneously captures short-term dynamics and periodic patterns.
// Interactive — seasonal pattern visualization
Season (m)12
Seasonal Strength60
Pattern bridge: Seasonal patterns in time series are the same calendar seasonality that drives market cycles. The Fourier terms in SARIMA connect to Fourier seasonality in Prophet.
Worked example

Eight years of monthly data with a strong annual cycle. Forecasting the last year by repeating the last month gives a mean absolute error of 11.48; repeating the same month last year — the seasonal naive forecast — gives 2.86. Any seasonal model has to beat that second number to earn its parameters.

Where it misleads
  • Seasonal differencing assumes a season of fixed length and shape; moving holidays such as Easter, or several seasonalities at once (daily and weekly in hourly data), break it.
  • Searching the many (p,d,q)(P,D,Q) orders for the best AIC is a garden of forking paths of its own: check the chosen model on data it was not selected on.
  • Long seasonal periods (52 weeks, 24 hours × 7 days) make SARIMA slow and unstable; Fourier terms or other models handle them better.
In code
rng = np.random.default_rng(6)
t = np.arange(96)
y = 100 + 0.2 * t + 15 * np.sin(2 * np.pi * t / 12) + rng.normal(0, 2, 96)   # eight years, monthly
train, test = y[:84], y[84:]
naive = np.full(12, train[-1])                    # repeat the last month
seasonal_naive = train[-12:]                      # repeat the same month last year
mae = lambda f: np.abs(test - f).mean()
Python, in your browser — edit the code and run it again

Assumes import numpy as np and import pandas as pd. Each snippet simulates or makes up its own series, as the comments say.

The same idea with a library
# Python — SARIMA
from statsmodels.tsa.statespace.sarimax import SARIMAX

model = SARIMAX(series,
                order=(1, 1, 1),
                seasonal_order=(1, 1, 1, 12)).fit()
forecast = model.get_forecast(steps=24)
ci = forecast.conf_int(alpha=0.05)
Sources
  • Time Series Analysis: Forecasting and Control (5th ed.), G. E. P. Box, G. M. Jenkins, G. C. Reinsel & G. M. Ljung, Wiley, 2015
  • R. J. Hyndman & Y. Khandakar, “Automatic Time Series Forecasting: The forecast Package for R”, Journal of Statistical Software 27(3), 2008
  • Forecasting: Principles and Practice (3rd ed.), R. J. Hyndman & G. Athanasopoulos, OTexts, 2021

Last reviewed October 2026 · How this site checks its content · Report a mistake

Linked from 1
← Previous
ARIMA
Open in the full reader, with the topic sidebar