Time Series • Statistics Background for Forecasting
Time Series / P3.10 Seasonal SARIMA Forecasting

P3.10 Seasonal SARIMA Forecasting

Practical 3 Statistics Background for Forecasting

Using a constructed monthly seasonal series, inspect seasonality, fit a small SARIMA, and forecast one year. Explain seasonal order in words.

Practical / Solution

P3.10 Seasonal SARIMA Forecasting

Problem Statement

Using a constructed monthly seasonal series, inspect seasonality, fit a small SARIMA, and forecast one year. Explain seasonal order in words.

Learning Outcomes

  • Identify period 12 from the plot/ACF.
  • Fit a small seasonal ARIMA and forecast.

Theory

Seasonal ARIMA adds seasonal AR, differencing and MA at lag s (s = 12 for months). A teaching starting point is often a small model such as (0,1,1)(0,1,1,12) after seeing trend plus yearly seasonality, then checking residuals. Do not start with a large grid of orders.

Dataset / Data Source

Constructed 72 monthly observations with trend and yearly season. Teaching data, airline-passenger-like in spirit, not a downloaded file.

Kaggle-style Workflow

  • Inspect and plot
  • ACF at seasonal lags
  • Choose a small seasonal order
  • Fit on train months
  • Forecast 12 months
  • MAE/RMSE on hold-out year if length allows

Analysis / Program

import numpy as np import pandas as pd import matplotlib.pyplot as plt from statsmodels.tsa.statespace.sarimax import SARIMAX idx = pd.date_range("2019-01-01", periods=72, freq="MS") t = np.arange(72) y = pd.Series(0.4 * t + 8 * np.sin(2 * np.pi * t / 12) + 50, index=idx) train, test = y.iloc[:-12], y.iloc[-12:] fit = SARIMAX(train, order=(0, 1, 1), seasonal_order=(0, 1, 1, 12), enforce_stationarity=False, enforce_invertibility=False).fit(disp=False) fc = fit.get_forecast(12).predicted_mean mae = np.mean(np.abs(test - fc)) print(fit.summary()) print("Hold-out MAE:", round(mae, 3)) train.plot(label="train") test.plot(label="test") fc.plot(label="SARIMA forecast", style="--") plt.legend() plt.tight_layout() plt.show()

Expected Output

A SARIMAX summary, a 12-month forecast line, and hold-out MAE for this constructed series. Seasonal wiggles in the forecast should resemble the yearly pattern.

Result / Interpretation

s = 12 because the data are monthly. Seasonal differencing D = 1 is motivated by a repeating yearly shape plus a drifting level. Residual plots should still be checked before trusting the forecast.

Note

Seasonal ARIMA is for repeating calendar patterns. It is not the first tool in Unit 1.