← Back to the Blog
How to Correctly Forecast Seasonal Marketing Trends with STL featured image

How to Correctly Forecast Seasonal Marketing Trends with STL


One of the largest challenges in accurately forecasting future marketing data is dealing with seasonal trends. STL, an abbreviation for Seasonal Trend Decomposition using LOESS, is a procedure that breaks time series down into three components:

  1. Overall Trend
  2. Seasonality
  3. Irregular remainder

LOESS is simply a method for local non-parametric regression. Essentially what happens here is, the seasonal values are removed from the raw data and the remainder is smoothed via LOESS to determine the overall trend. Here is a graphical example of STL Decomposition:
STL Graph
Source: Inside-R (http://www.inside-r.org)

As you can see, when looking at the raw data by itself, it appears difficult to predict the next points in the time series. However, once the oscillating seasonal component is removed, the overall trend can be more easily identified.

When forecasting the future, the overall trend can be forecasted using methods such as regression or ARIMA (AutoRegressive Integrated Moving Average). Then, the seasonal component can be added back in to create a more reliable seasonal forecast.

Here is an example of the basic usage of the STL function in R:

stl(x, s.window, s.degree = 0,
t.window = NULL, t.degree = 1,
l.window = nextodd(period), l.degree = t.degree,
s.jump = ceiling(s.window/10),
t.jump = ceiling(t.window/10),
l.jump = ceiling(l.window/10),
robust = FALSE,
inner = if(robust) 1 else 2,
outer = if(robust) 15 else 0,
na.action = na.fail)

Additional documentation on performing seasonal trend decomposition using R can be found here.

Liked this post? You should check out Levers.

Levers provides tools to forecast and model your marketing data - ecommerce, lead gen, social and more. Create a free Blueprint forecast for your Google Analytics profiles.