STL · SEASONAL-TREND DECOMPOSITION BY LOESS · SEASONAL ADJUSTMENT · RUNS IN YOUR BROWSER · NOTHING UPLOADED

Is it the season, or the trend?

Paste a series with dates: monthly sales, weekly sign-ups, daily website visits, hourly electricity load. STL (Cleveland, Cleveland, McRae & Terpenning 1990) splits it into a trend, a seasonal pattern that repeats every cycle and may change slowly, and a remainder. You get the seasonally adjusted series, how strong the trend and the seasonality are, which part of the cycle is high and low, and the points that stand out from both.

The period is read from your dates. Data with two cycles, such as hourly load with a daily and a weekly one, takes both periods at once (MSTL).

Nothing you enter leaves this browser tab. Statistical output from data you supply, not advice. Not legal, tax, or financial advice.

Your series

Rows are sorted by date; a missing value inside the series is filled by a straight line between its neighbours.

Method and citation

STL (Cleveland, Cleveland, McRae & Terpenning 1990) writes the series as Y = T + S + R and finds T and S by alternating two smoothers, each a loess fit (locally weighted linear regression with tricube weights; Cleveland 1979). In each pass of the inner loop it takes the trend off; smooths each cycle-subseries (every January together, every February together, ...) with a loess window of ns cycles, extending it one cycle past each end; removes any slow drift that leaked into that pattern with moving averages of length np, np and 3 followed by a loess of window nl; and smooths what is left after taking the seasonal off with a loess of window nt to get the new trend.

Robust mode adds the outer loop: after each fit, every point gets a bisquare weight (1 - (|R| / h)²)² with h = 6 × median |R|, so points far from trend plus season count for less (or nothing) in the next fit. The defaults follow statsmodels: ns = 7, nt the smallest odd integer at or above 1.5 n_p / (1 - 1.5 / n_s), nl the smallest odd integer above the period, 5 inner passes, or 2 inner and 15 outer when robust.

The strength of seasonality is max(0, 1 - Var(R) / Var(S + R)) and the strength of trend max(0, 1 - Var(R) / Var(T + R)) (Wang, Smith & Hyndman 2006, in the form of Hyndman & Athanasopoulos, Forecasting: Principles and Practice, section 4.3). A point is listed as standing out when its remainder is at least 3.5 robust standard deviations (1.4826 × the median absolute deviation) from the median remainder.

Several cycles at once (MSTL). Give more than one period and the tool runs MSTL (Bandara, Hyndman & Bergmeir 2021). The periods are sorted from shortest to longest. Starting from the data, each seasonal component in turn is put back into the deseasonalised series, re-estimated by STL at its own period and seasonal window, and taken out again; the whole round runs twice by default, so the daily pattern is estimated with the weekly one removed and the other way round. The trend and robustness weights are those of the last STL fit (the longest period), and the remainder is what is left. The default seasonal windows are 11, 15, 19, ... from the shortest period up, as in the paper and statsmodels; a period at least half as long as the series is left out with a note. Each component gets its own strength, max(0, 1 - Var(R) / Var(Si + R)).

Verified by tests in the source against statsmodels 0.15.0's STL: trend, seasonal, remainder and robustness weights agree to 1e-9 or better on nine cases (the CO₂ example with the default, robust, wide-window and degree-0-with-jumps settings; daily data with planted outliers, plain and robust; hourly data with a 24-step period; a quarterly series with even windows skipped by jumps; and a short series whose seasonal window is longer than each subseries). MSTL agrees with statsmodels 0.15.0's MSTL to 1e-8 or better on seven more cases: the hourly load example with periods 24 and 168, plain and robust; US daily births 1978 to 1988 with 7 and 365; three unsorted periods with their own windows and three passes; a period dropped for being too long; a single period; and jumps, degree 0 and a fixed trend window.

BibTeX

@misc{bandara2021mstl,
  author  = {Bandara, Kasun and Hyndman, Rob J. and Bergmeir, Christoph},
  title   = {{MSTL}: A Seasonal-Trend Decomposition Algorithm for Time Series with Multiple Seasonal Patterns},
  year    = {2021}, eprint = {2107.13462}, archivePrefix = {arXiv}
}
@article{cleveland1990stl,
  author  = {Cleveland, Robert B. and Cleveland, William S. and McRae, Jean E. and Terpenning, Irma},
  title   = {{STL}: A Seasonal-Trend Decomposition Procedure Based on Loess},
  journal = {Journal of Official Statistics},
  volume  = {6}, number = {1}, pages = {3--73}, year = {1990}
}
@article{cleveland1979robust,
  author  = {Cleveland, William S.},
  title   = {Robust Locally Weighted Regression and Smoothing Scatterplots},
  journal = {Journal of the American Statistical Association},
  volume  = {74}, number = {368}, pages = {829--836}, year = {1979},
  doi     = {10.1080/01621459.1979.10481038}
}
@article{wang2006characteristic,
  author  = {Wang, Xiaozhe and Smith, Kate and Hyndman, Rob},
  title   = {Characteristic-Based Clustering for Time Series Data},
  journal = {Data Mining and Knowledge Discovery},
  volume  = {13}, number = {3}, pages = {335--364}, year = {2006},
  doi     = {10.1007/s10618-005-0039-x}
}

Limits

Questions

What does STL decomposition do?

It splits a series into three parts that add back up to it: a slowly moving trend, a seasonal pattern that repeats every cycle (every year for monthly data, every week for daily data) and is allowed to change slowly, and a remainder, what neither explains. STL stands for Seasonal-Trend decomposition using Loess.

How do I seasonally adjust my data?

Subtract the seasonal component from each value. The tool does this for you: the seasonally adjusted series is trend plus remainder, so a month that is up only because it is always up at that time of year no longer looks like growth.

What period should I use?

The number of steps in one cycle: 12 for monthly data with a yearly cycle, 4 for quarterly, 7 for daily data with a weekly cycle, 24 for hourly data with a daily cycle. With a date column the tool infers it; type another number to look for a different cycle. You need at least two full cycles of data, and three or more give a steadier result.

My data has two cycles, a day and a week. Can it fit both?

Yes. Type both periods, separated by a comma, for example 24, 168 for hourly data (a day and a week) or 7, 365 for daily data (a week and a year). The tool then runs MSTL (Bandara, Hyndman and Bergmeir 2021): it fits one seasonal component per period with STL, shortest first, and goes round all of them twice so each is estimated with the others taken out. You get a seasonal component, a strength and a profile for every cycle.

What do the seasonal and trend windows change?

The seasonal window is how many cycles each point of the seasonal pattern is smoothed over: 7 lets the pattern change from year to year, a large number such as 35 makes it nearly fixed. The trend window is how many steps the trend is smoothed over: smaller follows turns faster, larger is smoother. Both must be odd.

When should I use robust mode?

When the series has one-off spikes or drops, such as a promotion, an outage or a data error. Robust mode runs 15 extra passes that give such points less weight, so they show up in the remainder instead of bending the trend and the seasonal pattern.

What is the strength of seasonality?

A number from 0 to 1, from Wang, Smith and Hyndman (2006): one minus the variance of the remainder divided by the variance of seasonal plus remainder. Near 1 the seasonal pattern dominates the noise; below about 0.4 there is little seasonality to speak of. The strength of trend is the same with the trend in place of the seasonal.

Is my data uploaded anywhere?

No. The series is read and decomposed by JavaScript in this browser tab. There are no accounts, cookies or analytics vendors.

Example data: monthly mean CO₂ at Mauna Loa Observatory, Hawaii, from the NOAA Global Monitoring Laboratory file co2_mm_mlo.csv (gml.noaa.gov/ccgg/trends), May 1974 to September 2026, retrieved 2026-11-13. The NOAA file's own deseasonalized column is kept beside it for comparison; NOAA computes it by a different method.