Skip to content
Method note

STL decompositionSTL decomposition: separate trend, seasonality and residual, then judge each

STL decomposition (Seasonal-Trend decomposition using LOESS) is a filtering procedure, not a model. It repeatedly smooths the cycle-subseries, applies a low-pass filter and smooths the trend, with an outer loop that downweights outliers. It is excellent at separating scales and dangerous when the period is wrong.

Reproducible procedure

This is the procedure the workspace executes for this method, in order. Each step has an action, a rule that can stop the step, and a defined output.

  1. 01

    Identify the cycle length from date spacing or the autocorrelation function.

    Rule
    A period that cannot be identified blocks STL instead of falling back to a guess.
    Output
    The period and its source.
  2. 02

    Set the seasonal, trend and low-pass windows.

    Rule
    The seasonal window must be odd and at least 7; trend and low-pass must be odd and greater than the period.
    Output
    The three window parameters.
  3. 03

    Run the decomposition, with robust weights enabled by default.

    Rule
    Robust iteration down-weights outliers rather than deleting them, so no observation disappears from the record.
    Output
    Trend, seasonal and residual series.
  4. 04

    Audit the variance shares and the behaviour of the residual.

    Rule
    Above 50,000 observations the requested jump is raised to 2 and the effective value is published in the result metadata.
    Output
    Variance shares and the iteration count.

STL decomposition: trend, season and residual

The observed series is treated as trend plus seasonal plus residual. The trend is a smooth LOESS curve; the seasonal component is a repeating shape of fixed period; the residual contains everything else. The three components add back to the observed series by construction.

STL decomposition
y_t = T_t + S_t + R_t
What this computes:
Split the series into long-term direction + repeating cycle + leftover noise.
Example:
Monthly sales = long-term growth (trend) + yearly peak (season) + random wiggle (residual).
Caution:
A wrong period contaminates the residual.

Parameters and what they actually do

seasonal controls how smooth the repeating shape is within each cycle-subseries. trend controls the smoothness of the long-term direction. low_pass controls the filter that separates the seasonal shape from the trend. Degrees are 0 (local constant) or 1 (local linear). The jump parameters evaluate LOESS every k-th point and interpolate, trading accuracy for speed.

ParameterDefaultConstraintEffect
periodinferred from datainteger ≥ 2the cycle length; a wrong value contaminates everything
seasonal7odd, ≥ 3smoothness of the repeating shape
trendautoodd, > periodsmoothness of the long-term direction
low_passsmallest odd > periododd, ≥ 3separates seasonal from trend
seasonal_deg / trend_deg / low_pass_deg10 or 1local constant versus local linear
robusttrueforced defaultbisquare weights reduce outlier influence
jumps1 (2 above 50k rows)≥ 1evaluate every k-th point and interpolate

Robust weights and residual outliers

Robust mode computes a residual scale from the median absolute deviation and assigns bisquare weights. Points with weights near zero contribute almost nothing to the next inner loop. The final weights are returned with the result, so you can see which observations were effectively excluded.

After decomposition, a residual is flagged when |R − median(R)| exceeds k·MAD(R), with k = 3.5 by default. Flagged points stay in the data; they are excluded only inside the denoising pipeline, with the rule recorded.

Large samples and the honesty requirement

Above 50,000 observations the workspace raises all three jump parameters to 2. The requested and actual parameters are both written into the metadata and shown in the interface. A silent degradation would make two results incomparable while looking identical.

What to check afterwards

Plot the residual autocorrelation. If the residual still has structure, the period or the trend span is wrong. If the seasonal component drifts in amplitude, a fixed-period STL may not be appropriate. Compare the variance shares: a trend that explains almost everything deserves a second look at the raw series.

Common questions

How do I choose the STL period?

Use the sampling interval: 12 for monthly data with an annual cycle, 7 for daily data with a weekly cycle, 52 for weekly data with an annual cycle. If the period is not obvious, inspect the autocorrelation. A wrong period contaminates the residual and makes the seasonal test unreliable.

What does the STL robust parameter do?

Robust mode computes bisquare weights from the residuals, so extreme points contribute less to the next inner loop. The final weights are returned with the decomposition. It reduces the influence of outliers but does not remove them from the data.

What is the difference between STL trend, seasonal and residual?

Trend is the smooth long-term direction, seasonal is the repeating shape of fixed period, and residual is what remains. The three components add back to the observed series. Their variance shares show which scale dominates, but the shares need not add to exactly 100%.

Can I run STL decomposition in the browser?

Yes. The decomposition runs in a Web Worker on this device. Above 50,000 observations the LOESS jump parameters rise to 2 and the actual values are written into the result metadata, so a degraded run is never presented as identical to a full one.

Related method notes

Cite this page: Detrend, “STL decomposition: separate trend, seasonality and residual, then judge each”, https://detrend.datacorp.top/methods/stl-decomposition. Last updated 2026-11-15.

Verification matrixFAQAll method notesRSSllms.txt

Run this procedure on your own workbook

The workspace executes exactly these steps locally, selects the method from the diagnostics and keeps every alternative visible.

Open the workspace