STL Decomposition

Classical decomposition is a lovely first teacher, but it is rigid: it assumes a fixed seasonal shape, it surrenders the endpoints to its moving averages, and a single wild outlier can smear across the whole trend. Real series misbehave in all three ways — seasonal patterns evolve, the latest data matters most, and outliers happen. STLSeasonal-Trend decomposition using Loess, introduced by Cleveland and colleagues in 1990 — was built to fix exactly these shortcomings, and it has become the default decomposition in modern forecasting practice.

Like everything in this module, STL splits an additive series into three pieces,

y_t = T_t + S_t + R_t,

but it estimates them with a smarter, more flexible tool — loess — applied over and over in a loop until the pieces settle.

Loess: smoothing by local regression

The whole method rests on one idea, so it is worth building intuition for. Loess (LOcal regrESSion) estimates a smooth curve not by fitting one global line but by fitting a little regression around every point:

The result is a smooth curve that bends freely to follow local structure, unlike the stiff straight-average of a moving average. The width of the neighbourhood (the span) is loess's smoothness dial, playing the same bias–variance role the window width m plays in moving-average smoothing.

How STL uses loess: the two loops

STL is loess applied cleverly and repeatedly. Conceptually there are two nested loops.

Because the seasonal component is re-smoothed each pass from the actual data, it is allowed to change gradually over the years — and the robustness loop is what makes STL shrug off spikes that would wreck a classical decomposition.

The STL panels

STL delivers the same four-panel plot as classical decomposition — observed, trend, seasonal, remainder — but with two visible differences: the trend reaches all the way to both ends (no chopped endpoints), and the seasonal band's shape can drift across the record rather than being a perfect stencil repeated forever.

Look closely at the seasonal panel below: its amplitude grows a little from left to right. A classical decomposition would have forced one fixed shape there; STL lets the season breathe.

Why STL wins (and its price)

The costs are real but modest: STL is additive only (see the warning below), it does not automatically handle calendar effects like trading days or moving holidays the way X-13ARIMA-SEATS does, and its output depends on the smoothing spans you choose. For description, exploration, and as a front-end to forecasting, it is usually the first tool to reach for.

STL only ever fits the additive model y_t = T_t + S_t + R_t. Hand it a series whose seasonal swings fan out with the level — the multiplicative pattern of the airline-passengers series — and STL will do its best with a fixed additive band, leaving a tell-tale residual seasonality in the remainder. The fix is the same trick as everywhere else in this module: decompose \log y_t instead. On the log scale the multiplicative structure becomes additive, STL fits it cleanly, and you exponentiate the components back if you need them in the original units. So the reflex for strictly-positive data with growing seasonality is: take logs first, then STL.

It is a small joke by the statisticians who built it. Loess (and its older sibling lowess, locally weighted scatterplot smoothing) is a deliberate pun on the geological term loess — the fine, wind-blown sediment that settles into smooth, gently-layered deposits. A loess smoother likewise lays a smooth surface over scattered data. William Cleveland, who developed both loess and STL at Bell Labs in the 1980s, was one of the great champions of looking at data; STL is very much a tool built by someone who trusted the eye, giving you honest, robust, visual components you can actually inspect.