How to Model Multiple Seasonality in Time Series | by Vitor Cerqueira | Jul, 2023


Handling seasonal effects in several periods

Vitor Cerqueira

Towards Data Science

Photo by Joshua Woroniecki on Unsplash

In this article, you’ll learn how to model multiple seasonality in time series. We’ll cover:

  • How to decompose a time series using MSTL
  • Creating explanatory variables that capture complex seasonality
  • Using off-the-shelf methods, with an example based on orbit’s forecasting package.

Seasonality refers to systematic changes that repeat with a regular periodicity. These patterns are connected with the frequency at which a time series is observed. A low-frequency time series usually contains a single seasonal period. For example, monthly time series exhibit yearly seasonality.

Increasingly, time series are collected at higher sampling frequencies, such as daily or hourly. This leads to larger datasets with a complex seasonality. A daily time series may show weekly, monthly, and yearly repeating patterns.

Here’s an example of an hourly time series with daily and weekly seasonality:

Hourly time series with daily and weekly seasonality. Artificial data and image created by author.

At first glance, it’s not clear that the above time series contains more than one seasonal pattern. Multiple seasonal effects can overlap each other, which makes it difficult to identify all relevant periods.

Decomposition methods aim at splitting time series into its basic parts: trend, seasonality, and residuals.

Most methods were designed to handle seasonality at a single predefined period. Examples include the classical method, x11, and STL, among others.

The STL method has been extended to handle multiple seasonality. MSTL (for Multiple STL) is available on statsmodels Python package:

import numpy as np
from statsmodels.tsa.seasonal import MSTL

# creating an artificial time series with complex seasonality
# daily and weekly seasonality
period1, period2 = 24, 24 * 7
# 500 data points
size = 500
beta1…



Source link

Leave a Comment