Methods to handle seasonality for forecasting

This text is a follow-up to a previous post. There, we identified 3 kinds of seasonal patterns.
Here, we’ll:
- Learn the best way to describe the seasonality of a time series.
- Go over 8 approaches you should use to model seasonality.
Seasonality refers to repeatable patterns that recur over some period. It’s a vital source of variation that is vital to model.
There are several ways of handling seasonality. Some approaches remove the seasonal component before modeling. Seasonally-adjusted data (a time series minus the seasonal component) highlights long-term effects equivalent to trends or business cycles. Other approaches add extra variables that capture the cyclical nature of seasonality.
Before going over different methods, let’s create a time series and describe its seasonal patterns.
Evaluation example
We’ll use the identical process we did within the previous article (see also reference [1]):
period = 12 # monthly series
size = 120beta1 = np.linspace(-.6, .3, num=size)
beta2 = np.linspace(.6, -.3, num=size)
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.normal(scale=0.1, size=size))
yt = xt + beta1 * sin1 + beta2 * cos1 + np.random.normal(scale=0.1, size=size)
yt = pd.Series(yt)
Here’s what this series appear to be:
We will start by describing the seasonal pattern by its strength:
# https://github.com/vcerqueira/blog/tree/important/src
from src.seasonality import seasonal_strengthseasonal_strength(yt, period=12)
# 0.90