in

8 Strategies to Mannequin Seasonality | by Vitor Cerqueira | Jul, 2023


Methods to deal with seasonality for forecasting

Picture by Clark Young on Unsplash

This text is a follow-up to a previous post. There, we recognized 3 varieties of seasonal patterns.

Right here, we’ll:

  • Learn to describe the seasonality of a time sequence.
  • Go over 8 approaches you should use to mannequin seasonality.

Seasonality refers to repeatable patterns that recur over some interval. It is a crucial supply of variation that’s vital to mannequin.

A time sequence and its seasonally-adjusted model. The information supply is within the subsequent part. Picture by creator.

There are a number of methods of dealing with seasonality. Some approaches take away the seasonal part earlier than modeling. Seasonally-adjusted knowledge (a time sequence minus the seasonal part) highlights long-term effects such as trends or business cycles. Different approaches add further variables that seize the cyclical nature of seasonality.

Earlier than going over completely different strategies, let’s create a time sequence and describe its seasonal patterns.

Evaluation instance

We’ll use the identical course of we did within the previous article (see additionally reference [1]):

interval = 12 # month-to-month sequence
measurement = 120

beta1 = np.linspace(-.6, .3, num=measurement)
beta2 = np.linspace(.6, -.3, num=measurement)
sin1 = np.asarray([np.sin(2 * np.pi * i / 12) for i in np.arange(1, size + 1)])
cos1 = np.asarray([np.cos(2 * np.pi * i / 12) for i in np.arange(1, size + 1)])

xt = np.cumsum(np.random.regular(scale=0.1, measurement=measurement))

yt = xt + beta1 * sin1 + beta2 * cos1 + np.random.regular(scale=0.1, measurement=measurement)

yt = pd.Sequence(yt)

Right here’s what this sequence appear like:

Synthetic time sequence with a stochastic stationary seasonality. Picture by creator.

We are able to begin by describing the seasonal sample by its power:

# https://github.com/vcerqueira/weblog/tree/principal/src
from src.seasonality import seasonal_strength

seasonal_strength(yt, interval=12)
# 0.90

Python Lists Vs. NumPy Arrays: A Deep Dive into Reminiscence Format and Efficiency Advantages | by Peng Qian | Jul, 2023

Fixing Geographic Travelling Salesman Issues utilizing Python | by Mike Jones | Jul, 2023