SARIMA: Complete Guide to Seasonal Time Series Forecasting with Implementation
Back to Writing

SARIMA: Complete Guide to Seasonal Time Series Forecasting with Implementation

Michael BrenndoerferNovember 12, 202527 min read6,478 wordsInteractive

Learn SARIMA (Seasonal AutoRegressive Integrated Moving Average) for forecasting time series with seasonal patterns. Includes mathematical foundations, step-by-step implementation, and practical applications.

Data Science Handbook Cover
Part of Data Science Handbook

This article is part of the free-to-read Data Science Handbook

View full handbook
Reading Level

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

SARIMA (Seasonal AutoRegressive Integrated Moving Average)

Concept

SARIMA (Seasonal AutoRegressive Integrated Moving Average) is a powerful time series forecasting model that extends the ARIMA framework to handle seasonal patterns in data. While ARIMA models capture trends and irregular components, SARIMA adds the ability to model and forecast seasonal variations that repeat at regular intervals.

The model combines three key components: the non-seasonal ARIMA(p,d,q) part that handles trend and irregular patterns, and the seasonal ARIMA(P,D,Q) part that specifically addresses seasonal patterns. The "I" in both parts refers to differencing, which helps make the time series stationary by removing trends and seasonal effects. This dual structure allows SARIMA to capture both short-term dependencies and long-term seasonal cycles simultaneously.

SARIMA is particularly valuable when dealing with time series data that exhibits clear seasonal patterns, such as monthly sales data with yearly cycles, daily temperature readings with annual seasons, or quarterly economic indicators with yearly patterns. Unlike simpler models that might ignore seasonality or treat it as noise, SARIMA explicitly models these recurring patterns, leading to more accurate forecasts and better understanding of the underlying data structure.

The model's strength lies in its ability to decompose a time series into its constituent parts: trend, seasonal component, and irregular (random) component, then model each part separately before recombining them for forecasting. This systematic approach makes SARIMA one of the most comprehensive and widely-used methods for seasonal time series forecasting.

Advantages

SARIMA models offer several significant advantages for seasonal time series forecasting. First, they provide a systematic framework for handling both trend and seasonal components simultaneously, which is crucial for many real-world time series that exhibit both patterns. The model's ability to explicitly separate and model seasonal effects means that forecasts can capture the expected seasonal variations, leading to more accurate predictions than models that ignore seasonality.

The model is also highly interpretable, as each parameter has a clear statistical meaning. The autoregressive terms capture how current values depend on past values, the moving average terms capture how current values depend on past forecast errors, and the seasonal terms capture how current values depend on values from the same season in previous years. This interpretability makes SARIMA valuable not just for forecasting but also for understanding the underlying dynamics of the time series.

Additionally, SARIMA models are robust and well-established, with extensive theoretical foundations and practical applications across many domains. The model's flexibility in parameter selection allows it to adapt to different types of seasonal patterns, from simple annual cycles to complex multi-seasonal patterns. The built-in differencing mechanism also helps handle non-stationary data automatically, making the model applicable to a wide range of time series without extensive preprocessing.

Disadvantages

Despite its strengths, SARIMA models have several limitations that practitioners should be aware of. The model assumes that seasonal patterns are deterministic and repeat exactly, which may not hold for all real-world time series. In reality, seasonal patterns can evolve over time, with changing amplitudes, phases, or even the emergence of new seasonal cycles, which SARIMA cannot easily accommodate.

The model also requires careful parameter selection, which can be computationally intensive and subjective. Determining the optimal values for p, d, q, P, D, Q, and the seasonal period s requires iterative testing and validation, often involving multiple diagnostic tests and model comparisons. This process can be time-consuming and may not always lead to a single, clearly optimal model.

Another significant limitation is that SARIMA models assume linear relationships between variables and cannot capture complex nonlinear patterns or interactions between different time series. They also assume that the error terms are normally distributed and homoscedastic (constant variance), which may not hold for all datasets. When these assumptions are violated, the model's forecasts may be unreliable or biased.

Finally, SARIMA models can become quite complex with many parameters, leading to potential overfitting, especially with limited data. The model's performance can also degrade when dealing with very long-term forecasts, as small errors in parameter estimation can compound over time, leading to increasingly inaccurate predictions.

Formula

The SARIMA model is denoted as SARIMA(p,d,q)(P,D,Q)s, where the first set of parameters (p,d,q) refers to the non-seasonal components and the second set (P,D,Q) refers to the seasonal components, with s being the seasonal period.

The Problem: Why We Need SARIMA

Imagine you're forecasting monthly sales for a retail store. You notice two distinct patterns: sales tend to be higher this month if last month was high (short-term memory), and sales in December are consistently higher than in January (seasonal pattern). A simple ARIMA model can handle the first pattern, but it struggles with the second because seasonal effects operate on a different timescale—comparing December to November misses the crucial comparison to December of last year.

This is the fundamental challenge SARIMA addresses: time series often exhibit both short-term dependencies (consecutive observations are related) and long-term seasonal cycles (observations separated by the seasonal period are related). The SARIMA model structure emerges naturally from this dual nature of seasonal time series.

The Foundation: Understanding Stationarity

Before we can build a predictive model, we need to understand an important concept: stationarity. A stationary time series has statistical properties (mean, variance, and patterns) that remain constant over time. Think of it like a well-behaved process where the rules don't change—if we understand how it behaved in the past, we can predict its future.

Most real-world time series are non-stationary. Sales might trend upward over years, or temperatures might have seasonal cycles. These changing patterns make prediction difficult because the "rules" keep changing. This is why differencing is important—it transforms a non-stationary series into a stationary one by removing trends and seasonal effects, creating a stable foundation for modeling.

Differencing is the mathematical tool that makes non-stationary series stationary. The key insight is simple: instead of modeling the raw values (which change over time), we model the changes between values (which are more stable).

The SARIMA model uses two types of differencing:

  1. Non-seasonal differencing removes trends by computing differences between consecutive observations. If sales increase by roughly the same amount each month, taking differences removes that trend.
  2. Seasonal differencing removes seasonal patterns by computing differences between observations separated by the seasonal period. If December sales are typically higher than other months, comparing each month to the same month last year removes that seasonal effect.

Mathematically, we express differencing using the backshift operator B, where BXt=Xt1BX_t = X_{t-1} means "shift the series back by one period." This notation allows us to write differencing compactly:

dsDXt=(1B)d(1Bs)DXt\nabla^d \nabla_s^D X_t = (1-B)^d (1-B^s)^D X_t

Here's what each part means:

  • d\nabla^d: Non-seasonal differencing applied d times
  • sD\nabla_s^D: Seasonal differencing applied D times with seasonal period s
  • (1B)d(1-B)^d: The mathematical operation that computes d-th order differences
  • (1Bs)D(1-B^s)^D: The operation that computes D-th order seasonal differences

To see why this works, consider first-order non-seasonal differencing (d=1): we compute XtXt1X_t - X_{t-1}. If the original series had a constant upward trend, the differenced series will have a constant mean near zero. For seasonal differencing with s=12, we compute XtXt12X_t - X_{t-12}, comparing each month to the same month last year. This removes the annual seasonal pattern while preserving other relationships.

Out[2]:
Visualization
Notebook output

This visualization demonstrates the differencing transformation process. The top panel shows the original non-stationary series with both an upward trend and seasonal fluctuations. The middle panel shows the result after non-seasonal differencing: the trend has been removed, leaving a series that oscillates around a stable mean, but seasonal patterns remain. The bottom panel shows the final result after seasonal differencing: both trend and seasonality have been removed, creating a stationary series suitable for ARMA modeling. Notice how the mean approaches zero and the variance becomes more stable after each differencing step.

Step 2: Modeling Dependencies with Autoregressive Terms

Once we have a stationary series through differencing, we can model how current values depend on past values. This is where autoregressive (AR) terms come in. The intuition is straightforward: in many time series, today's value is related to yesterday's value, and yesterday's value is related to the day before, creating a chain of dependencies.

SARIMA extends this idea to two timescales:

  • Non-seasonal AR terms capture short-term dependencies: how this month relates to last month
  • Seasonal AR terms capture long-term seasonal dependencies: how this December relates to last December

The non-seasonal autoregressive polynomial is:

ϕ(B)=1ϕ1Bϕ2B2ϕpBp\phi(B) = 1 - \phi_1 B - \phi_2 B^2 - \cdots - \phi_p B^p

Each term ϕiBi\phi_i B^i represents the influence of the value i periods ago. The coefficient ϕi\phi_i tells us how strong that influence is. For example, if ϕ1=0.7\phi_1 = 0.7, it means that 70% of the current value's deviation from the mean can be explained by the previous value's deviation.

The seasonal autoregressive polynomial works similarly but at seasonal lags:

Φ(Bs)=1Φ1BsΦ2B2sΦPBPs\Phi(B^s) = 1 - \Phi_1 B^s - \Phi_2 B^{2s} - \cdots - \Phi_P B^{Ps}

Here, BsB^s shifts back by s periods (e.g., 12 months), so Φ1B12\Phi_1 B^{12} captures how this month relates to the same month last year. The seasonal AR terms allow the model to "remember" seasonal patterns across years.

Step 3: Learning from Forecast Errors with Moving Average Terms

Autoregressive terms capture how values depend on past values, but they miss an important source of information: past forecast errors. If we consistently over-predict in certain situations, we should adjust our forecasts accordingly. This is what moving average (MA) terms do—they allow the model to learn from its mistakes.

Moving average terms capture how current values depend on past forecast errors. Like AR terms, SARIMA includes both non-seasonal and seasonal MA components:

  • Non-seasonal MA terms: How this month's forecast error relates to last month's forecast error
  • Seasonal MA terms: How this month's forecast error relates to the forecast error from the same month last year

The non-seasonal moving average polynomial is:

θ(B)=1+θ1B+θ2B2++θqBq\theta(B) = 1 + \theta_1 B + \theta_2 B^2 + \cdots + \theta_q B^q

Note the plus signs here (unlike the minus signs in AR terms). This reflects that MA terms model the error structure, not the value structure. A positive θ1\theta_1 means that if we over-predicted last period, we're likely to over-predict this period too (the errors are correlated).

The seasonal moving average polynomial is:

Θ(Bs)=1+Θ1Bs+Θ2B2s++ΘQBQs\Theta(B^s) = 1 + \Theta_1 B^s + \Theta_2 B^{2s} + \cdots + \Theta_Q B^{Qs}

This captures how forecast errors from the same season in previous years influence current errors. For example, if we consistently under-predict December sales, the seasonal MA term helps the model learn this pattern.

Step 4: Combining Everything into the Complete SARIMA Model

Now we can assemble the complete SARIMA model by combining differencing, autoregressive terms, and moving average terms:

ϕ(B)Φ(Bs)dsDXt=θ(B)Θ(Bs)ϵt\phi(B) \Phi(B^s) \nabla^d \nabla_s^D X_t = \theta(B) \Theta(B^s) \epsilon_t

This equation systematically combines all the components we've discussed:

  • Left side: The differenced series (dsDXt\nabla^d \nabla_s^D X_t) is modeled by autoregressive polynomials that capture dependencies at both short-term (ϕ(B)\phi(B)) and seasonal (Φ(Bs)\Phi(B^s)) timescales
  • Right side: The error structure is modeled by moving average polynomials at both short-term (θ(B)\theta(B)) and seasonal (Θ(Bs)\Theta(B^s)) timescales
  • Error term: ϵt\epsilon_t represents white noise—random, unpredictable fluctuations with mean 0 and constant variance σ2\sigma^2

The multiplicative structure (AR terms multiplied together, MA terms multiplied together) is important. It means that seasonal and non-seasonal effects interact. For example, the interaction between non-seasonal and seasonal AR terms captures how this month's relationship to last month might be different in December (holiday season) versus January (post-holiday).

Why This Mathematical Structure Works

The SARIMA formulation works because it mirrors the actual structure of seasonal time series. Real-world seasonal data exhibits dependencies at multiple timescales simultaneously:

  1. Short-term memory: Recent values influence current values (captured by non-seasonal AR terms)
  2. Seasonal memory: Values from the same season in previous years influence current values (captured by seasonal AR terms)
  3. Error learning: Past forecast errors inform current predictions (captured by MA terms at both timescales)
  4. Stability: Differencing ensures the underlying process is stationary, making all these relationships stable and predictable

The backshift operator B allows us to express complex lag structures compactly. The polynomial notation makes it clear how different lags combine, and the multiplicative structure captures the interaction between seasonal and non-seasonal effects.

For example, in monthly sales data, the model might learn that:

  • This month's sales depend on last month's sales (non-seasonal AR)
  • December sales depend on previous December sales (seasonal AR)
  • These effects interact—the December-to-December relationship might be stronger than the January-to-January relationship
  • Forecast errors from holiday seasons tend to persist (seasonal MA), requiring adjustments in future holiday forecasts

This comprehensive structure allows SARIMA to capture the rich, multi-scale dependencies present in real seasonal time series, making it an effective method for seasonal forecasting.

Mathematical properties

The SARIMA model has several important mathematical properties that make it suitable for time series forecasting. The model is stationary when the roots of both the non-seasonal autoregressive polynomial ϕ(B)\phi(B) and the seasonal autoregressive polynomial Φ(Bs)\Phi(B^s) lie outside the unit circle in the complex plane. This condition ensures that the time series doesn't exhibit explosive growth or decay.

The model is also invertible when the roots of both the non-seasonal moving average polynomial θ(B)\theta(B) and the seasonal moving average polynomial Θ(Bs)\Theta(B^s) lie outside the unit circle. Invertibility ensures that the model can be expressed in terms of past observations rather than past forecast errors, which is important for forecasting and interpretation.

The forecast function of a SARIMA model has a specific structure: short-term forecasts are dominated by the autoregressive and moving average terms, while long-term forecasts converge to the seasonal pattern. This property makes SARIMA particularly useful for forecasting seasonal time series, as it can capture both immediate dependencies and long-term seasonal cycles.

Visualizing SARIMA

Let's create a comprehensive visualization that demonstrates the key components and behavior of a SARIMA model. We'll generate a synthetic time series with both trend and seasonal components, then show how SARIMA decomposes and models this data.

Out[3]:
Visualization
Notebook output

This visualization shows how SARIMA decomposes a time series into its fundamental components. The original series exhibits both a clear upward trend and regular seasonal fluctuations. The decomposition reveals the underlying trend component that captures the long-term growth pattern, the seasonal component that shows the repeating annual cycle, and the residual component that contains the random noise and any patterns not captured by trend and seasonality.

Out[4]:
Visualization
Notebook output

The ACF and PACF plots reveal the autocorrelation structure of the time series, which is crucial for determining the appropriate SARIMA model parameters. The ACF shows significant correlations at lags 12 and 24, indicating strong seasonal patterns with a 12-month cycle. The PACF helps identify the order of autoregressive terms by showing the partial correlations after removing the effects of intermediate lags.

Example

Let's work through a concrete example using monthly sales data to see how the SARIMA formula translates into practice. We'll trace each component of the model to understand how they work together to produce forecasts.

The Data: Monthly Sales with Clear Patterns

Suppose we have monthly sales data for a retail store over 3 years (36 months). The sales show two clear patterns:

  • An upward trend: sales gradually increase over time
  • Strong seasonality: December sales consistently spike due to holiday shopping, then drop in January

For the first 12 months, our data (in thousands of dollars) looks like:

  • January: 45, February: 48, March: 52, April: 55, May: 58, June: 62
  • July: 65, August: 68, September: 70, October: 75, November: 85, December: 120

The December spike (120) is nearly three times the January value (45), and we see a steady upward progression throughout the year. These patterns—trend and seasonality—are exactly what SARIMA is designed to handle.

Step 1: Understanding Why We Need Differencing

The first challenge is that our data is non-stationary. The mean changes over time (trending upward), and the variance changes (December values are much higher). To apply ARMA components, we need a stationary series.

Non-seasonal differencing addresses the trend. We compute first differences: Xt=XtXt1\nabla X_t = X_t - X_{t-1}. For example:

  • February difference: 48 - 45 = 3
  • March difference: 52 - 48 = 4
  • December difference: 120 - 85 = 35

The differenced series has a more stable mean, but we still see the December spike because seasonal patterns remain.

Seasonal differencing addresses the seasonality. We compute seasonal differences: 12Xt=XtXt12\nabla_{12} X_t = X_t - X_{t-12}. This compares each month to the same month last year:

  • January 2021 vs January 2020
  • December 2021 vs December 2020

After both types of differencing, we have a stationary series where the statistical properties are constant, making it suitable for ARMA modeling.

Step 2: Identifying the Model Structure

To determine which SARIMA model fits our data, we examine the autocorrelation structure of the differenced series using ACF (Autocorrelation Function) and PACF (Partial Autocorrelation Function) plots.

From these plots, we observe:

  • Non-seasonal patterns: The ACF cuts off after lag 1, suggesting q=1 (one moving average term). The PACF cuts off after lag 1, suggesting p=1 (one autoregressive term).
  • Seasonal patterns: Significant spikes at lags 12 and 24 in both ACF and PACF suggest we need both seasonal AR (P=1) and seasonal MA (Q=1) terms.

This analysis leads us to a SARIMA(1,1,1)(1,1,1)12 model. The notation tells us:

  • (1,1,1): One AR term, first-order differencing, one MA term (non-seasonal)
  • (1,1,1): One seasonal AR term, first-order seasonal differencing, one seasonal MA term
  • 12: The seasonal period (12 months = 1 year)

Step 3: Understanding the Model Equation

For our SARIMA(1,1,1)(1,1,1)12 model, the general equation:

ϕ(B)Φ(B12)12Xt=θ(B)Θ(B12)ϵt\phi(B) \Phi(B^{12}) \nabla \nabla_{12} X_t = \theta(B) \Theta(B^{12}) \epsilon_t

expands to:

(1ϕ1B)(1Φ1B12)12Xt=(1+θ1B)(1+Θ1B12)ϵt(1 - \phi_1 B)(1 - \Phi_1 B^{12}) \nabla \nabla_{12} X_t = (1 + \theta_1 B)(1 + \Theta_1 B^{12}) \epsilon_t

Let's break down what each part does:

  1. (1ϕ1B)(1 - \phi_1 B): The non-seasonal AR term. This captures how this month's sales relate to last month's sales. If ϕ1=0.6\phi_1 = 0.6, it means 60% of this month's deviation from the mean is explained by last month's deviation.

  2. (1Φ1B12)(1 - \Phi_1 B^{12}): The seasonal AR term. This captures how this month's sales relate to the same month last year. If Φ1=0.8\Phi_1 = 0.8, it means December 2021 sales are strongly influenced by December 2020 sales.

  3. 12Xt\nabla \nabla_{12} X_t: The differenced series. This is the stationary series we're actually modeling.

  4. (1+θ1B)(1 + \theta_1 B): The non-seasonal MA term. This captures how this month's forecast error relates to last month's forecast error.

  5. (1+Θ1B12)(1 + \Theta_1 B^{12}): The seasonal MA term. This captures how this month's forecast error relates to the forecast error from the same month last year.

The multiplicative structure means these effects interact. For example, the interaction term ϕ1Φ1\phi_1 \Phi_1 captures how the December-to-December relationship might be different from the January-to-January relationship.

Step 4: How Forecasting Works

Once we've estimated the parameters (typically using maximum likelihood), we can generate forecasts. The forecasting process involves three steps:

  1. Apply differencing: Transform the original series to the differenced, stationary series
  2. Forecast the differenced series: Use the ARMA components to predict future values of the differenced series
  3. Reverse the differencing: Transform the forecasted differenced values back to the original scale

For a one-step-ahead forecast, the formula becomes:

X^t+1=ϕ1Xt+Φ1Xt11ϕ1Φ1Xt12+θ1ϵt+Θ1ϵt11+θ1Θ1ϵt12\hat{X}_{t+1} = \phi_1 X_t + \Phi_1 X_{t-11} - \phi_1 \Phi_1 X_{t-12} + \theta_1 \epsilon_t + \Theta_1 \epsilon_{t-11} + \theta_1 \Theta_1 \epsilon_{t-12}

This equation shows how the forecast combines multiple sources of information:

  • ϕ1Xt\phi_1 X_t: The non-seasonal AR contribution—how last month's value influences this month
  • Φ1Xt11\Phi_1 X_{t-11}: The seasonal AR contribution—how the same month last year influences this month
  • ϕ1Φ1Xt12-\phi_1 \Phi_1 X_{t-12}: The interaction term—how the combined seasonal and non-seasonal effects interact
  • θ1ϵt\theta_1 \epsilon_t: The non-seasonal MA contribution—adjusting for last month's forecast error
  • Θ1ϵt11\Theta_1 \epsilon_{t-11}: The seasonal MA contribution—adjusting for the forecast error from the same month last year
  • θ1Θ1ϵt12\theta_1 \Theta_1 \epsilon_{t-12}: The interaction of error terms

Why This Example Illustrates the Formula

This example demonstrates how each component of the SARIMA formula addresses a specific aspect of seasonal time series:

  • Differencing removes the non-stationary elements (trend and seasonality), creating a stable foundation
  • Non-seasonal AR/MA terms capture short-term dependencies and error patterns
  • Seasonal AR/MA terms capture long-term seasonal dependencies and seasonal error patterns
  • The multiplicative structure allows these effects to interact, capturing the complex relationships in real seasonal data

The result is a model that can forecast both the short-term progression (month-to-month changes) and the long-term seasonal patterns (year-to-year cycles) simultaneously, which makes SARIMA effective for seasonal forecasting.

Implementation in Statsmodels

Now let's see how the SARIMA formula we've discussed translates into actual code. We'll implement SARIMA using the statsmodels library, which provides comprehensive time series analysis tools. As we work through the implementation, you'll see how each component of the formula—differencing, autoregressive terms, and moving average terms—is handled by the library, making the connection between theory and practice concrete.

Statsmodels is a good choice here because it offers robust statistical inference, diagnostic tools, and detailed model summaries that are important for understanding SARIMA model performance.

In[5]:
1import numpy as np
2import pandas as pd
3import matplotlib.pyplot as plt
4from statsmodels.tsa.arima.model import ARIMA
5from statsmodels.tsa.seasonal import seasonal_decompose
6from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
7from statsmodels.stats.diagnostic import acorr_ljungbox
8import warnings
9warnings.filterwarnings('ignore')
10
11# Generate realistic monthly sales data with trend and seasonality
12np.random.seed(42)
13n_months = 60  # 5 years of data
14dates = pd.date_range(start='2019-01-01', periods=n_months, freq='M')
15
16# Create components: trend, seasonal, and noise
17trend = np.linspace(100, 150, n_months)  # Gradual upward trend
18seasonal = 25 * np.sin(2 * np.pi * np.arange(n_months) / 12) + 15 * np.cos(2 * np.pi * np.arange(n_months) / 6)
19noise = np.random.normal(0, 8, n_months)
20
21# Combine components
22sales_data = trend + seasonal + noise
23sales_series = pd.Series(sales_data, index=dates, name='Monthly_Sales')
24
25# Calculate summary statistics
26mean_sales = sales_series.mean()
27std_sales = sales_series.std()
Out[6]:
Generated time series with 60 months of data
Mean: 123.76, Std: 24.44

First 12 months of sales data:
January 2019: $118.97K
February 2019: $119.74K
March 2019: $121.03K
April 2019: $124.73K
May 2019: $115.67K
June 2019: $122.36K
July 2019: $132.72K
August 2019: $107.07K
September 2019: $73.87K
October 2019: $71.97K
November 2019: $75.62K
December 2019: $100.60K

The generated time series shows a clear upward trend from approximately $100K to $150K over 5 years, with seasonal fluctuations. The mean and standard deviation provide a baseline for understanding the data's central tendency and variability before modeling.

In[7]:
1# Fit SARIMA model - we'll use SARIMA(1,1,1)(1,1,1)12
2# This means: p=1, d=1, q=1 (non-seasonal) and P=1, D=1, Q=1 (seasonal) with s=12
3sarima_model = ARIMA(sales_series, order=(1,1,1), seasonal_order=(1,1,1,12))
4sarima_fit = sarima_model.fit()
Out[8]:
SARIMA Model Summary:
                                    SARIMAX Results                                     
========================================================================================
Dep. Variable:                    Monthly_Sales   No. Observations:                   60
Model:             ARIMA(1, 1, 1)x(1, 1, 1, 12)   Log Likelihood                -170.784
Date:                          Sun, 16 Nov 2025   AIC                            351.568
Time:                                  23:32:56   BIC                            360.819
Sample:                              01-31-2019   HQIC                           355.049
                                   - 12-31-2023                                         
Covariance Type:                            opg                                         
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
ar.L1         -0.0350      0.264     -0.133      0.895      -0.552       0.482
ma.L1         -0.8402      0.168     -4.988      0.000      -1.170      -0.510
ar.S.L12       0.0022      0.427      0.005      0.996      -0.836       0.840
ma.S.L12      -0.9982    153.067     -0.007      0.995    -301.004     299.008
sigma2        54.3107   8293.703      0.007      0.995   -1.62e+04    1.63e+04
===================================================================================
Ljung-Box (L1) (Q):                   0.30   Jarque-Bera (JB):                 3.01
Prob(Q):                              0.58   Prob(JB):                         0.22
Heteroskedasticity (H):               0.89   Skew:                             0.61
Prob(H) (two-sided):                  0.82   Kurtosis:                         2.81
===================================================================================

Warnings:
[1] Covariance matrix calculated using the outer product of gradients (complex-step).

The model summary provides diagnostic information including parameter estimates, standard errors, confidence intervals, and information criteria. The coefficients indicate how strongly current values depend on past values and past forecast errors, both for non-seasonal and seasonal components.

Out[9]:
Key Model Parameters:
Non-seasonal AR coefficient (φ₁): -0.0350
Non-seasonal MA coefficient (θ₁): -0.8402
Seasonal AR coefficient (Φ₁): 0.0022
Seasonal MA coefficient (Θ₁): -0.9982
Model AIC: 351.57
Model BIC: 360.82

The parameter values indicate the strength of relationships in the model. Positive AR coefficients suggest that high values tend to follow high values, while MA coefficients capture how the model adjusts based on past forecast errors. The AIC and BIC values allow comparison with alternative model specifications, with lower values typically indicating better model fit adjusted for complexity.

In[10]:
1# Generate forecasts for the next 12 months
2forecast_steps = 12
3forecast_result = sarima_fit.forecast(steps=forecast_steps)
4forecast_ci = sarima_fit.get_forecast(steps=forecast_steps).conf_int()
5
6# Create forecast dates
7forecast_dates = pd.date_range(start=sales_series.index[-1] + pd.DateOffset(months=1), 
8                              periods=forecast_steps, freq='M')
Out[11]:
12-Month Forecast:
January 2024: $168.33K (95% CI: $152.39K - $184.27K)
February 2024: $164.23K (95% CI: $148.17K - $180.28K)
March 2024: $163.14K (95% CI: $146.90K - $179.38K)
April 2024: $166.81K (95% CI: $150.38K - $183.24K)
May 2024: $167.12K (95% CI: $150.51K - $183.72K)
June 2024: $177.60K (95% CI: $160.82K - $194.39K)
July 2024: $174.12K (95% CI: $157.16K - $191.08K)
August 2024: $156.33K (95% CI: $139.19K - $173.46K)
September 2024: $127.92K (95% CI: $110.61K - $145.23K)
October 2024: $117.24K (95% CI: $99.76K - $134.72K)
November 2024: $132.24K (95% CI: $114.59K - $149.89K)
December 2024: $155.07K (95% CI: $137.25K - $172.88K)

The forecasts show expected values for the next 12 months along with 95% confidence intervals. The confidence intervals widen as we forecast further into the future, reflecting increasing uncertainty. The forecasts capture both the upward trend and seasonal patterns observed in the historical data.

Out[12]:
Visualization
Notebook output

The implementation demonstrates the SARIMA modeling process. We generate realistic sales data with both trend and seasonal components, fit a SARIMA(1,1,1)(1,1,1)12 model, and generate 12-month forecasts with confidence intervals. The model captures both the upward trend and the seasonal patterns, providing forecasts for future periods.

Key Parameters

Below are some of the main parameters that affect how the SARIMA model works and performs.

  • order: A tuple (p, d, q) specifying the non-seasonal ARIMA parameters. p is the order of the autoregressive part, d is the degree of differencing, and q is the order of the moving average part. Common starting values are (1,1,1) for many time series.

  • seasonal_order: A tuple (P, D, Q, s) specifying the seasonal ARIMA parameters. P is the seasonal autoregressive order, D is the seasonal differencing order, Q is the seasonal moving average order, and s is the seasonal period (e.g., 12 for monthly data with annual seasonality). Start with (1,1,1,12) for monthly data.

  • trend: Optional parameter to include a constant term in the model. Can be 'c' for constant, 't' for linear trend, 'ct' for both, or 'n' for neither. Default is 'c' which includes a constant term.

  • enforce_stationarity: Boolean (default: True) that determines whether to enforce stationarity constraints on autoregressive parameters. Setting to False allows non-stationary models but may lead to unreliable forecasts.

  • enforce_invertibility: Boolean (default: True) that determines whether to enforce invertibility constraints on moving average parameters. Invertibility ensures the model can be expressed in terms of past observations.

  • method: Optimization method for parameter estimation. Options include 'css-ml' (conditional sum of squares then maximum likelihood, default), 'ml' (maximum likelihood), or 'css' (conditional sum of squares). 'css-ml' typically provides good balance between speed and accuracy.

Key Methods

The following are the most commonly used methods for interacting with SARIMA models.

  • fit(): Estimates model parameters using maximum likelihood or conditional sum of squares. Returns a fitted model object with parameter estimates, diagnostics, and forecast capabilities.

  • forecast(steps): Generates point forecasts for the specified number of steps ahead. Returns a pandas Series with forecasted values.

  • get_forecast(steps): Generates forecasts with confidence intervals. Returns a forecast object with .predicted_mean for point forecasts and .conf_int() for confidence intervals.

  • predict(start, end): Generates in-sample or out-of-sample predictions for specified time periods. Useful for generating predictions on historical data or specific future dates.

  • summary(): Displays a comprehensive model summary including parameter estimates, standard errors, confidence intervals, information criteria (AIC, BIC), and diagnostic statistics.

Practical implications

SARIMA models are valuable in industries and applications where seasonal patterns are fundamental to the business or phenomenon being modeled. Retail and e-commerce companies often use SARIMA for sales forecasting, as consumer behavior exhibits seasonal patterns around holidays, back-to-school periods, and weather-related shopping. The model's ability to capture both short-term trends and long-term seasonal cycles makes it useful for inventory management, staffing decisions, and revenue planning.

In the energy sector, SARIMA models are effective for electricity demand forecasting, where consumption patterns vary by season (heating in winter, cooling in summer) and by day of the week. Utility companies use these forecasts for capacity planning, pricing strategies, and grid management. Similarly, in agriculture, SARIMA helps predict crop yields and commodity prices that follow natural seasonal cycles.

The model is also widely used in tourism and hospitality, where demand patterns are influenced by seasons, school holidays, and cultural events. Hotels, airlines, and travel companies use SARIMA forecasts for pricing optimization, capacity planning, and revenue management. The model's ability to handle multiple seasonal patterns (daily, weekly, annual) makes it valuable for these applications.

Best Practices

To achieve good results with SARIMA models, follow several best practices. First, use information criteria such as AIC or BIC for model selection rather than relying solely on visual inspection of ACF and PACF plots. These criteria provide a quantitative basis for comparing models and help balance model fit with complexity. When selecting parameters, start with simpler models (lower p, d, q, P, D, Q values) and gradually increase complexity only if it improves the information criteria.

It is also important to perform diagnostic checks after fitting the model. Use the Ljung-Box test to verify that residuals are white noise, and examine residual plots to check for patterns that might indicate model misspecification. If residuals show autocorrelation or heteroscedasticity, consider adjusting the model parameters or exploring alternative specifications. Additionally, use out-of-sample validation by holding back the most recent data to evaluate forecast accuracy before deploying the model in production.

When working with multiple seasonal patterns, consider using multiple seasonal periods in the model specification. For example, daily data might exhibit both weekly (s=7) and annual (s=365) seasonality. Some implementations support multiple seasonal orders, though this increases model complexity. Validate that the additional complexity improves forecast accuracy on held-out data.

Data Requirements and Preprocessing

SARIMA models require sufficient historical data to reliably estimate seasonal patterns. As a rule of thumb, you typically need at least 2-3 complete seasonal cycles (e.g., 24-36 months for monthly data with annual seasonality) to identify and estimate seasonal parameters effectively. With insufficient data, the model may not capture seasonal patterns accurately, leading to poor forecasts. For weekly data with annual seasonality, aim for at least 104-156 weeks of data.

The model assumes that seasonal patterns are relatively stable over time, which may not hold for rapidly changing markets or businesses undergoing structural changes. Before applying SARIMA, check for structural breaks or regime changes in your data. If you detect significant changes in the seasonal pattern over time, consider using shorter time windows for estimation or exploring alternative approaches like dynamic linear models or machine learning methods that can adapt to changing patterns.

Data preprocessing is typically minimal for SARIMA models, as differencing handles trends and seasonality automatically. However, you should handle missing values appropriately. For small gaps, linear interpolation or forward-fill methods often work well. For larger gaps, consider more sophisticated imputation methods or exclude periods with extensive missing data. Outliers can also affect parameter estimation, so identify and handle extreme values before fitting the model.

Common Pitfalls

Several common pitfalls can undermine the effectiveness of SARIMA models if not carefully addressed. One frequent mistake is over-differencing the series, which can introduce artificial patterns and reduce forecast accuracy. Verify stationarity after differencing using statistical tests like the Augmented Dickey-Fuller test rather than relying solely on visual inspection. If the series becomes stationary after first-order differencing, avoid applying second-order differencing unless necessary.

Another issue arises when practitioners ignore diagnostic checks after model fitting. Failing to verify that residuals are white noise can lead to unreliable forecasts, as autocorrelated residuals indicate that the model has not captured all patterns in the data. Perform the Ljung-Box test and examine residual plots to ensure model adequacy before using the model for forecasting.

Selecting model parameters based solely on in-sample fit without considering out-of-sample performance is also problematic. Models that fit the training data well may not generalize to new data, especially if they are over-parameterized. Validate model performance on held-out data and use information criteria to balance model complexity with forecast accuracy. Finally, assuming that seasonal patterns remain constant over time can lead to poor forecasts when patterns evolve. Regularly retrain the model with recent data to capture changing seasonal dynamics.

Computational Considerations

SARIMA models are computationally efficient for most practical applications, making them suitable for real-time forecasting systems. Model fitting typically scales linearly with the number of observations, so datasets with thousands of points can often be processed quickly. However, model selection (choosing optimal p, d, q, P, D, Q parameters) can be computationally intensive, especially when using grid search or information criteria optimization across many parameter combinations.

For high-frequency data or large-scale applications, consider using automated model selection tools like auto_arima functions that efficiently search the parameter space. These tools use heuristics to narrow the search space and can significantly reduce computation time. Parallel processing can also speed up parameter optimization when evaluating multiple models simultaneously.

Memory requirements are generally modest for SARIMA models, as they primarily store parameter estimates and recent observations rather than the entire dataset. However, when working with very long time series (tens of thousands of points), consider using rolling window approaches that fit the model on recent data rather than the entire history. This approach reduces memory usage and can improve forecast accuracy when patterns change over time.

Performance and Deployment Considerations

Evaluating SARIMA model performance requires multiple metrics to assess different aspects of forecast quality. Use point forecast accuracy metrics like Mean Absolute Error (MAE) or Root Mean Squared Error (RMSE) to measure average forecast errors. For applications where over- and under-prediction have different costs, consider asymmetric loss functions or quantile forecasts. Additionally, evaluate forecast intervals by checking whether the actual coverage matches the nominal confidence level (e.g., 95% intervals should contain approximately 95% of actual values).

When deploying SARIMA models in production, establish a retraining schedule to update parameters as new data becomes available. For stable seasonal patterns, monthly or quarterly retraining may be sufficient, while rapidly changing patterns may require more frequent updates. Monitor forecast errors over time and set up alerts for when errors exceed acceptable thresholds, which may indicate that the model needs retraining or that the underlying data generating process has changed.

Consider the tradeoff between model complexity and forecast accuracy. More complex models with higher parameter counts may fit historical data better but can overfit and perform poorly on new data. Use information criteria and out-of-sample validation to find the optimal balance. For production systems, simpler models are often preferable because they are more interpretable, faster to train, and less prone to overfitting. Document the model selection process and maintain version control for model parameters to ensure reproducibility and enable rollback if new models perform worse than previous versions.

Summary

SARIMA models provide a comprehensive framework for forecasting time series data with seasonal patterns, combining the flexibility of ARIMA models with explicit seasonal modeling capabilities. The model's strength lies in its systematic approach to decomposing time series into trend, seasonal, and irregular components, then modeling each component separately before recombining them for forecasting. This decomposition not only improves forecast accuracy but also provides valuable insights into the underlying dynamics of the time series.

The mathematical foundation of SARIMA, with its dual autoregressive and moving average components for both non-seasonal and seasonal patterns, makes it particularly well-suited for applications where seasonal effects are fundamental to the data generating process. The model's interpretability and statistical rigor make it valuable not just for forecasting but also for understanding the relationships between current and past values in seasonal contexts.

While SARIMA models have limitations, particularly around the assumption of stable seasonal patterns and linear relationships, they remain widely used and reliable methods for seasonal time series forecasting. The model's balance of sophistication and interpretability, combined with robust statistical foundations and extensive practical applications, makes it an important tool in the time series analyst's toolkit. For practitioners working with seasonal data, SARIMA provides a solid starting point that can be enhanced with additional techniques as needed for specific applications.

Quiz

Ready to test your understanding? Take this quick quiz to reinforce what you've learned about SARIMA models.

Loading component...

Reference

BIBTEXAcademic
@misc{sarimacompleteguidetoseasonaltimeseriesforecastingwithimplementation, author = {Michael Brenndoerfer}, title = {SARIMA: Complete Guide to Seasonal Time Series Forecasting with Implementation}, year = {2025}, url = {https://mbrenndoerfer.com/writing/sarima-seasonal-time-series-forecasting}, organization = {mbrenndoerfer.com}, note = {Accessed: 2025-11-16} }
APAAcademic
Michael Brenndoerfer (2025). SARIMA: Complete Guide to Seasonal Time Series Forecasting with Implementation. Retrieved from https://mbrenndoerfer.com/writing/sarima-seasonal-time-series-forecasting
MLAAcademic
Michael Brenndoerfer. "SARIMA: Complete Guide to Seasonal Time Series Forecasting with Implementation." 2025. Web. 11/16/2025. <https://mbrenndoerfer.com/writing/sarima-seasonal-time-series-forecasting>.
CHICAGOAcademic
Michael Brenndoerfer. "SARIMA: Complete Guide to Seasonal Time Series Forecasting with Implementation." Accessed 11/16/2025. https://mbrenndoerfer.com/writing/sarima-seasonal-time-series-forecasting.
HARVARDAcademic
Michael Brenndoerfer (2025) 'SARIMA: Complete Guide to Seasonal Time Series Forecasting with Implementation'. Available at: https://mbrenndoerfer.com/writing/sarima-seasonal-time-series-forecasting (Accessed: 11/16/2025).
SimpleBasic
Michael Brenndoerfer (2025). SARIMA: Complete Guide to Seasonal Time Series Forecasting with Implementation. https://mbrenndoerfer.com/writing/sarima-seasonal-time-series-forecasting
Michael Brenndoerfer

About the author: Michael Brenndoerfer

All opinions expressed here are my own and do not reflect the views of my employer.

Michael currently works as an Associate Director of Data Science at EQT Partners in Singapore, where he drives AI and data initiatives across private capital investments.

With over a decade of experience spanning private equity, management consulting, and software engineering, he specializes in building and scaling analytics capabilities from the ground up. He has published research in leading AI conferences and holds expertise in machine learning, natural language processing, and value creation through data.

Stay updated

Get notified when I publish new articles on data and AI, private equity, technology, and more.