Last modified: September 16, 2024

This article is written in: 🇺🇸

Seasonality and trends are fundamental components in time series data that significantly impact analysis and forecasting. Understanding and correctly modeling these elements are crucial for accurate predictions and effective time series modeling.

Seasonality

Seasonality refers to periodic fluctuations that repeat at regular intervals over time. These patterns are often driven by seasonal factors such as weather, holidays, or economic cycles.

Characteristics of Seasonality

Examples of Seasonal Patterns

Decomposing Seasonality

To analyze and remove seasonality, a time series can be decomposed into three main components:

  1. Trend Component (( T_t )): The long-term progression of the series.
  2. Seasonal Component (( S_t )): The repeating short-term cycle.
  3. Residual Component (( R_t )): The irregular or random fluctuations.

Mathematically, for an additive model:

[ X_t = T_t + S_t + R_t ]

For a multiplicative model:

[ X_t = T_t \times S_t \times R_t ]

Decomposition Methods
  1. Moving Average Method:

  2. Purpose: Estimate the trend component by smoothing the series.

  3. Procedure:

    • Apply a centered moving average of order equal to the seasonal period to ( X_t ).
    • Subtract the estimated trend ( T_t ) from ( X_t ) to obtain the seasonal component ( S_t ).
  4. Seasonal Decomposition of Time Series by Loess (STL):

  5. Purpose: Decompose the series into trend, seasonal, and residual components using local regression (loess).

  6. Advantages:
    • Handles both additive and multiplicative seasonality.
    • Robust to outliers.
    • Flexible in handling complex seasonal patterns.

Trend refers to the long-term movement or direction in the time series data. Trends can be:

Detrending Methods

  1. Differencing:

  2. First-order Differencing: [ Y_t = X_t - X_{t-1} ]

  3. Second-order Differencing: [ Y_t = (X_t - X_{t-1}) - (X_{t-1} - X_{t-2}) = X_t - 2X_{t-1} + X_{t-2} ]
  4. Purpose: Remove trends by analyzing changes between consecutive observations.

  5. Transformation:

  6. Logarithmic Transformation: [ Y_t = \log(X_t) ]

  7. Purpose: Stabilize variance and linearize exponential trends.

  8. Regression Modeling:

  9. Linear Trend Model: [ X_t = \beta_0 + \beta_1 t + \epsilon_t ]

  10. Nonlinear Trend Model: [ X_t = \beta_0 + \beta_1 t + \beta_2 t^2 + \epsilon_t ]
  11. Purpose: Fit a trend line to the data and analyze residuals.

Effectively modeling seasonality and trends is essential for accurate forecasting. Several models explicitly account for these components.

1. Seasonal ARIMA (SARIMA)

An extension of ARIMA models that includes seasonal terms to handle seasonality.

[ \Phi_P(B^s) \phi_p(B) (1 - B^s)^D (1 - B)^d X_t = \Theta_Q(B^s) \theta_q(B) \epsilon_t ]

2. Exponential Smoothing State Space Models (ETS)

A class of models using weighted averages of past observations, suitable for data with trends and seasonality.

3. Seasonal Decomposition of Time Series (STL) Forecasting

A two-step approach:

  1. Decomposition: Split the series into trend, seasonal, and residual components.
  2. Forecasting: Model and forecast each component separately, then recombine.

Seasonal ARIMA Processes (SARIMA)

Seasonal ARIMA (SARIMA) models are widely used for time series data exhibiting both trend and seasonal behaviors.

Mathematical Formulation

A SARIMA(( p, d, q \times P, D, Q ))(_s) model incorporates both non-seasonal and seasonal factors:

[ \Phi_P(B^s) \phi_p(B) (1 - B^s)^D (1 - B)^d X_t = \Theta_Q(B^s) \theta_q(B) \epsilon_t ]

Examples of SARIMA Models

Example 1: SARIMA(1, 0, 0)(1, 0, 0)(_{12})

Model Equation:

[ (1 - \phi_1 B)(1 - \Phi_1 B^{12}) X_t = \epsilon_t ]

Example 2: SARIMA(0, 1, 1)(0, 1, 1)(_{4})

Model Equation:

[ (1 - B)(1 - B^4) X_t = (1 + \theta_1 B)(1 + \Theta_1 B^4) \epsilon_t ]

Simplification and Expansion

Expanding the Differencing Operators:

Combining Differencing:

[ (1 - B)(1 - B^s) X_t = X_t - X_{t-1} - X_{t-s} + X_{t-s-1} ]

Stationarity and Invertibility Conditions

Seasonal Differencing

Autocorrelation Function (ACF) of SARIMA Processes

The ACF of a SARIMA model displays patterns reflecting both seasonal and non-seasonal behavior.

Example: SARIMA(0, 0, 1)(0, 0, 1)(_{12})

Model Specification:

[ X_t = \epsilon_t + \theta_1 \epsilon_{t-1} + \Theta_1 \epsilon_{t-12} + \theta_1 \Theta_1 \epsilon_{t-13} ]

Calculating Autocovariances

  1. Variance (( \gamma_0 )):

[ \gamma_0 = \text{Var}(X_t) = \sigma^2 \left(1 + \theta_1^2 + \Theta_1^2 + \theta_1^2 \Theta_1^2\right) ]

  1. Covariance at Lag 1 (( \gamma_1 )):

[ \gamma_1 = \text{Cov}(X_t, X_{t-1}) = \sigma^2 \theta_1 \left(1 + \Theta_1^2\right) ]

  1. Covariance at Lag 12 (( \gamma_{12} )):

[ \gamma_{12} = \sigma^2 \Theta_1 \left(1 + \theta_1^2\right) ]

  1. Covariance at Lag 13 (( \gamma_{13} )):

[ \gamma_{13} = \sigma^2 \theta_1 \Theta_1 \left(1 + \theta_1 \Theta_1\right) ]

Calculating Autocorrelations

[ \rho_k = \frac{\gamma_k}{\gamma_0} ]

Example: Monthly Airline Passenger Data

Consider a time series consisting of monthly airline passenger data. This particular time series is characterized by two distinct features: an upward trend indicating an increase in the number of passengers over time, and a seasonal pattern that repeats every 12 months, typically linked to factors such as holiday travel or seasonal tourism.

Steps to Model and Forecast the Time Series

I. Decompose the Time Series into Trend, Seasonal, and Residual Components:

II. Detrend the Time Series Using Differencing or Transformation:

III. Fit an Appropriate Model that Accounts for Both Trend and Seasonality:

IV. Forecast Future Values Using the Fitted Model:

seasonality_forecast

Seasonal Decomposition

Seasonal decomposition of time series is a technique that deconstructs a time series into its constituent components: trend, seasonal, and residual. The Seasonal-Trend decomposition procedure based on LOESS (STL) is a robust method for this decomposition. This method is particularly useful for analyzing time series data with complex seasonal and trend patterns.

Example

To illustrate STL decomposition, we'll generate a synthetic time series dataset that exhibits clear seasonal patterns, trends, and some random noise. We'll then apply STL decomposition to this data and visualize the components.

This plot shows the original synthetic time series data, combining seasonal, trend, and noise components.

output(3)

The original data exhibits an upward trend with clear seasonal fluctuations and some random noise. This visualization helps in understanding the overall structure and patterns in the time series.

By performing STL decomposition, we can separately analyze the trend, seasonal, and residual components, providing insights into the underlying structure of the time series data. This technique is particularly useful for identifying patterns and making more accurate forecasts.

output(4)

Seasonal Component: - The plot description shows the seasonal fluctuations in the data, which repeat annually. - The interpretation of this seasonal component highlights the repeating yearly pattern, demonstrating the synthetic seasonal effect added to the data, and shows how the values fluctuate within each year.

Trend Component: - The plot description represents the long-term progression of the data over the entire period. - The interpretation of the trend component reveals a clear upward trajectory, indicating a consistent increase in the data over time, which aligns with the linear trend added to the synthetic data.

Residual Component: - The plot description displays the residuals, showing the remaining variations in the data after removing the trend and seasonal components. - The interpretation of the residual component reflects random noise. Ideally, it shows no discernible pattern, suggesting that the trend and seasonality have been effectively removed, with residuals randomly distributed around zero, confirming that the decomposition has captured the main patterns in the data.

Table of Contents

  1. Seasonality and Trends in Time Series Analysis
    1. Seasonality
      1. Characteristics of Seasonality
      2. Examples of Seasonal Patterns
      3. Decomposing Seasonality
    2. Trends
      1. Identifying Trends
      2. Detrending Methods
      3. Visualization of Trends
    3. Modeling Seasonality and Trends
      1. 1. Seasonal ARIMA (SARIMA)
      2. 2. Exponential Smoothing State Space Models (ETS)
      3. 3. Seasonal Decomposition of Time Series (STL) Forecasting
    4. Seasonal ARIMA Processes (SARIMA)
      1. Mathematical Formulation
      2. Examples of SARIMA Models
      3. Stationarity and Invertibility Conditions
      4. Seasonal Differencing
    5. Autocorrelation Function (ACF) of SARIMA Processes
      1. Example: SARIMA(0, 0, 1)(0, 0, 1)(_{12})
      2. Calculating Autocovariances
      3. Calculating Autocorrelations
    6. Example: Monthly Airline Passenger Data
    7. Steps to Model and Forecast the Time Series
  2. Seasonal Decomposition
    1. Example