- Introduced by
- Cleveland, Cleveland, McRae & Terpenning
- Year
- 1990
- Type
- nonparametric iterative smoother
- Family
- Trend & seasonality
What does it do?
STL Decomposition, introduced by Cleveland, Cleveland, McRae, and Terpenning (1990), separates a time series with a fixed seasonal period into trend, seasonal, and remainder components.
It uses iterated loess smoothing, a local regression technique, and includes a robustness loop that down-weights observations with large remainders. It is an alternative to classical decomposition in which the seasonal pattern is allowed to change over time.
The intuition behind the method
Think of a monthly sales series as a mixture of a slow-moving drift (trend), a repeating yearly pattern (seasonality), and everything else (remainder). STL estimates each part in turn while holding the others fixed, much like adjusting one equalizer band at a time, and repeats this cycle for a set number of passes. Because the seasonal part is estimated with loess, a local curve-fitting technique, the seasonal shape can shift gradually over time rather than being forced into one fixed pattern.
History
STL was published in the Journal of Official Statistics in 1990 by Robert Cleveland, William Cleveland, Jean McRae, and Irma Terpenning. It was presented as a loess-based procedure that decomposes a seasonal time series into trend, seasonal, and remainder parts, and as an alternative to classical decomposition methods. Implementations are available in R and Python.
When to use it
Use STL for a univariate series with a clear seasonal pattern of known, fixed period when you want trend and seasonal estimates that tolerate outliers and allow the seasonal shape to evolve. The period must be a fixed whole number of observations per cycle, as with monthly or quarterly data observed over a whole number of periods per year. A cycle that does not contain a whole number of observations, such as an annual cycle in weekly data, does not fit this requirement directly and must be handled by an approximation or by another method. The method assumes an approximately additive structure, so apply a log transform first if seasonal variation grows with the level of the series. Do not use it where calendar effects such as trading days or holidays must be adjusted explicitly, since X-13ARIMA-SEATS is the alternative designed for that purpose. It is also a poor fit when formal inference on the components is required. When the series spans too few seasonal cycles to estimate the seasonal pattern, classical decomposition or ARIMA-based models are worth considering. The minimum length depends on the period and the chosen windows, so check that the seasonal estimate remains stable when the sample is shortened.
Limitations and considerations
- The model is additive; multiplicative seasonality must be removed first, for example by a log transform.
- Calendar effects such as trading days and holidays are not modelled, so they remain in the seasonal or remainder component.
- The seasonal and trend bandwidths are chosen by the analyst and can change the estimated components materially.
- The procedure returns component estimates without standard errors or confidence intervals.
- The original procedure handles one fixed seasonal period at a time.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Each seasonal position is smoothed on its own subseries, so the seasonal shape can change gradually over time instead of being fixed across the whole sample.
- Any fixed, known seasonal period expressed as a whole number of observations can be specified, and the procedure does not require a particular calendar frequency.
- Robustness weights computed from the remainder reduce the influence of large, isolated remainders on the trend and seasonal estimates.
- The analyst sets the smoothing bandwidths directly, so the responsiveness of the trend can be controlled explicitly.
- The output is a simple additive split into trend, seasonal, and remainder that can be inspected component by component.
Applications
- Separating trend and seasonality in monthly retail sales or energy consumption data
- Anomaly detection by examining the remainder component for unusual spikes
- Pre-processing economic time series before ARIMA modelling or forecasting
- Visualising long-run trend shifts in climate or environmental monitoring datasets
- Decomposing web traffic or app usage series with weekly seasonality for business reporting
How it works
How it works
Each inner pass alternates two smoothing steps: the seasonal component is estimated by smoothing each periodic subseries, and the trend is estimated by smoothing the seasonally adjusted series. The series is modelled as Y = T + S + R, and the passes are repeated a set number of times rather than until a stated convergence criterion is met.
Formula
\text{For each pass: } Y_t = T_t + S_t + R_t, \quad T_t = \mathcal{L}(\{Y_t - S_t\}),\; S_t = \mathcal{L}(\text{subseries}_k)For each position within the period (for example, each month), loess is fitted to the detrended values Y minus T across all occurrences of that position in the series. Because each subseries is smoothed on its own, the seasonal shape can drift in amplitude and timing over the sample.
Formula
\hat{S}_t^{(k)} = \text{Loess}\!\left(\left\{Y_{t-p\cdot j} - T_{t-p\cdot j}\right\}_{j}\right), \quad p = \text{period}After the seasonal estimate is subtracted from the data, a second loess smoother with a user-chosen bandwidth is applied to the seasonally adjusted series. The bandwidth controls how quickly the trend can change; a wider window gives a smoother, slower-moving trend.
Formula
\hat{T}_t = \text{Loess}\!\left(\left\{Y_t - \hat{S}_t\right\}_{t=1}^{N};\, q_{\text{trend}}\right)The outer loop computes bisquare robustness weights from the remainder, scaled by six times the median absolute remainder. Observations with large remainders receive weights near zero, and these weights are fed back into the inner-loop loess fits, so that the final trend and seasonal estimates are less affected by outliers without the analyst removing them in advance.
Formula
\rho_t = B\!\left(\frac{|R_t|}{6\,\text{median}(|R_t|)}\right),\quad B(u)=(1-u^2)^2\,\mathbf{1}_{[0,1)}(u)Common pitfalls
- A trend window that is too narrow lets the trend follow seasonal variation, which distorts both the trend and the seasonal estimate.
- Applying STL to a multiplicative series without a transform produces remainders whose spread changes with the level of the series, which biases the components.
- Skipping or disabling the robustness iterations when outliers are present lets anomalous observations contaminate the trend and seasonal estimates.
- Robustness weights depend on remainder size, so a sustained shift that the trend cannot follow may not be down-weighted. The remainder should be checked for autocorrelation or remaining structure rather than assumed to be white noise.
Frequently asked questions
How do I choose the seasonal and trend window parameters?
The seasonal window controls how quickly the seasonal shape may change: a short window lets it change faster, while a long window makes it nearly constant. The trend window must be wide enough that the trend does not absorb seasonal variation. In practice, compare decompositions across several bandwidth values and check whether the remainder still shows structure, since no single automatic rule fits every series.
Can STL handle multiple seasonal periods, such as daily and weekly patterns?
The original STL procedure handles one fixed period at a time. For data with several seasonal cycles, such as hourly series with both daily and weekly patterns, extensions such as MSTL and STR have been developed to address multiple periods. These are not part of the 1990 procedure, so their assumptions and implementations should be checked separately before use.
Is STL suitable for forecasting?
STL is a decomposition procedure, not a forecasting model. A common workflow is to forecast the seasonally adjusted series, for example with exponential smoothing or ARIMA, extrapolate or otherwise forecast the seasonal component, and recombine the parts. The choice of model for each component is a separate decision and should be justified on its own.
Related methods
Sources
Cleveland, R. B., Cleveland, W. S., McRae, J. E., & Terpenning, I. (1990). STL: A seasonal-trend decomposition procedure based on loess. Journal of Official Statistics, 6(1), 3–73.
Open publication reference