Introduction to SARIMA Models
Introduction to SARIMA Models
• Seasonal ARIMA (SARIMA) models are an extension of ARIMA models that
specifically account for seasonality in the data. An ARIMA model has three
parameters:
• p: the number of lag observations included in the model (autoregressive
part)
• d: the number of times that the raw observations are differenced (degree
of differencing)
• q: the size of the moving average window (moving average part)
• A SARIMA model adds additional parameters to account for seasonality:
• P: the number of seasonal lag observations included in the model
(seasonal autoregressive part)
• D: the number of seasonal differences
• Q: the size of the seasonal moving average window
• s: the number of time steps for a single seasonal period
Best Model
• Data Collection: Gather the time series data (e.g., number of internet users over time).
• Data Preprocessing:
• Plot the data to understand its trend and seasonality.
• Check for stationarity. If the data is non-stationary, apply differencing.
• Model Identification:
• Use autocorrelation function (ACF) and partial autocorrelation function (PACF) plots to identify
potential values for p, d, q, P, D, and Q.
• Use information criteria like AIC (Akaike Information Criterion) and BIC (Bayesian Information
Criterion) to compare different models and select the best one.
• Parameter Estimation:
• Fit the SARIMA model using the identified parameters.
• Use statistical software or programming languages like Python (with libraries such as statsmodels)
for model fitting.
• Model Diagnostics:
• Check the residuals of the fitted model to ensure they resemble white noise.
• Use diagnostic plots and statistical tests to validate the model.
• Forecasting:
• Use the validated SARIMA model to forecast future values.
MODEL SELECTION CRITERIA
Identification of Model Orders (p, d, q,
P, D, Q, s):
Preliminary Analysis:
Stationarity and Differencing:
Model Selection and Fitting:
Diagnostic Checking:
Model Validation:
Parameter Significance:
• Check the significance of the parameters in
the model. Non-significant parameters might
indicate an overfitted model and can be
excluded.
Re-evaluation:
• If the selected model does not perform well
based on the above criteria, re-evaluate the
choice of (p, d, q) and (P, D, Q, s) and try
different combinations.
Impulse Response Function (IRF)
• The Impulse Response Function (IRF) is a
powerful tool used to analyze the dynamic
response of a time series to shocks in the system.
• It shows the effect of a one-time shock to one of
the innovations on current and future values of
the endogenous variables.
• When comparing different models, IRFs can help
to understand how different specifications
respond to shocks over time.
Fit SARIMA Models:
• from [Link] import
SARIMAX
• model1 = SARIMAX(time_series_data, order=(p1,
d1, q1), seasonal_order=(P1, D1, Q1, s))
• model_fit1 = [Link](disp=False)
• model2 = SARIMAX(time_series_data, order=(p2,
d2, q2), seasonal_order=(P2, D2, Q2, s))
• model_fit2 = [Link](disp=False)
Generate Impulse Response
Functions:
• irf1 =
model_fit1.impulse_responses(steps=30) #
Change steps as needed
• irf2 =
model_fit2.impulse_responses(steps=30)
Plot and Compare IRFs:
• import [Link] as plt
• [Link](figsize=(12, 6))
• [Link](irf1, label='Model 1', linestyle='--')
• [Link](irf2, label='Model 2', linestyle='-')
• [Link]('Impulse Response Functions')
• [Link]('Steps')
• [Link]('Response')
• [Link]()
• [Link]()
Comparing Impulse Response
Functions for Competing Models
Comparing Impulse Response
Functions for Competing Models
• from [Link] import SARIMAX
• # Fit Model 1
• model1 = SARIMAX(time_series_data, order=(1, 1, 1),
seasonal_order=(1, 1, 1, 12))
• model_fit1 = [Link](disp=False)
• # Fit Model 2
• model2 = SARIMAX(time_series_data, order=(2, 1, 2),
seasonal_order=(0, 1, 1, 12))
• model_fit2 = [Link](disp=False)
• # Generate IRFs
• irf1 = model_fit1.impulse_responses(steps=30)
• irf2 = model_fit2.impulse_responses(steps=30)
• # Plot IRFs
• import [Link] as plt
• [Link](figsize=(12, 6))
• [Link](irf1, label='Model 1', linestyle='--')
• [Link](irf2, label='Model 2', linestyle='-')
• [Link]('Impulse Response Functions')
• [Link]('Steps')
• [Link]('Response')
• [Link]()
• [Link]()