What does STL decomposition give you that a classical moving-average decomposition does not?
answer
- loess instead of fixed windows
- seasonality need not be frozen
- two smoothing windows you must choose
- outliers down-weighted, not absorbed
- additive only, so log first if needed
basics
~20 sSTL uses local regression instead of fixed averages, so the seasonal shape may change over time, trend and seasonal smoothness are tunable, and a robust variant pushes outliers into the remainder instead of letting them bend the trend.
solid answer
~50 sSTL stands for Seasonal and Trend decomposition using Loess, and it replaces the fixed moving averages of the classical method with iterated local regressions. Four differences matter. First, the seasonal component is allowed to **evolve**: you control how fast through the seasonal smoothing window, so a weekly pattern on daily sign-ups that changed after a launch is tracked rather than averaged into one compromise shape. Second, there is a **robust** mode that down-weights extreme observations, so a one-day spike lands in the remainder rather than dragging the trend up across a whole window. Third, trend smoothness is a separate tunable, not a by-product of the seasonal period. Fourth, it estimates trend to the very ends instead of leaving a half-window bare. The costs are that it is additive only, so a series whose swing grows with its level needs a log first, and that you now own two smoothing parameters that change the answer.
go deeper
Know what the letters stand for and the headline difference: STL smooths locally, so the seasonal pattern is allowed to change over the history instead of being one fixed shape.
Be ready to explain the two smoothing windows, what each controls, and why a robust variant sends an outlier to the remainder while a plain moving average spreads it into the trend.
Show judgment about when the extra flexibility earns its keep, and name the costs out loud: additive only, no calendar awareness, and two tuning choices that materially change the split you report.
Own the standard your team applies: which method is the default, whether smoothing parameters are fixed across series or tuned per series, and how component splits that revise with new data are communicated.
## What STL is STL stands for Seasonal and Trend decomposition using Loess. Loess is local regression: to estimate a smooth value at a point, you fit a low-order polynomial to the nearby observations, weighted so nearer points count more, and read off the fitted value. STL runs an inner loop that alternates between two of these smooths: smooth the values belonging to each position in the season across cycles to update the seasonal component, subtract it, then smooth what is left to update the trend, subtract it, and repeat. An outer loop optionally computes robustness weights from the size of each remainder and re-runs the inner loop with badly-fitting points down-weighted. ## The four practical gains **Seasonality is allowed to change.** Classical decomposition estimates a single seasonal index per position by averaging over the whole history, so the January effect of the first year and of the last year are forced to be identical. STL instead smooths each position's values *along the years*, and the width of that smoother is yours to choose. Set it wide and you approach the classical fixed-seasonality behaviour; set it narrower and the seasonal shape can drift. This matters for any series whose rhythm genuinely changed: a weekly sign-up pattern that flattened when the product went international is a real change, not noise, and forcing one shape onto both regimes leaves that change sitting in the remainder. **Robustness.** In the robust variant, points with large remainders get low weights on the next pass. A one-off extreme observation therefore stops pulling the trend and the seasonal shape toward itself, and instead shows up clearly in the remainder. With a plain moving average, that same point is smeared across an entire window and quietly biases both other components. If your downstream use of the remainder is to notice unusual behaviour, a robust fit is close to mandatory, because a non-robust fit partially absorbs the very thing you are looking for. **Separate control of trend smoothness.** In the classical method the trend smoother is pinned to the seasonal period; you cannot ask for a stiffer or more flexible level without breaking the seasonal cancellation. STL exposes a trend window independently, so you can decide how much of the medium-run movement counts as trend rather than remainder. **Estimates at the ends.** Loess fits at the boundary using the data that exists on one side, so the trend and seasonal components are defined for the first and last observations. A centred 7-day moving average leaves three days bare at each end; STL does not. Boundary estimates are still the least certain part of the fit and will revise as new data arrives, but you get a number and a fitted structure rather than a gap. ## What STL does not do for you - **It is additive.** STL fits `y = T + S + R`. A series whose seasonal swing grows in proportion to its level has to be log-transformed first, decomposed, and back-transformed, with the usual caveats that logs need strictly positive data and that exponentiated components are ratios. - **It has no notion of the calendar.** STL knows only a period length. It does not know that a month has 28 to 31 days, that a holiday moves between two months from year to year, or that some months contain five weekends and others four. Those effects have to be handled before or alongside the decomposition; STL will happily bury them in the seasonal component or spray them across the remainder. - **It fits one seasonal period at a time in its classic formulation.** Daily data that has both a weekly and an annual rhythm needs an extension or a staged approach. - **Its parameters are real choices.** A seasonal window that is too narrow lets the seasonal component chase noise and even absorb genuine level shifts, so the trend looks artificially calm and the remainder looks artificially small. Too wide and you have paid for flexibility you did not use. Same trade on the trend window. These are not defaults to accept silently; they are assumptions to state. ## How to talk about the choice A good answer frames it as a trade rather than a ranking. The classical method is transparent and parameter-free once the period is fixed, which is a real virtue when the output is going into a report someone else must defend. STL is more flexible and far more forgiving of messy data, at the price of two tuning decisions and of a fit that is harder to reproduce by hand. Pick classical when the seasonality is genuinely stable and the audience needs a simple story; pick STL, in robust mode, when the seasonal shape moved, the data has outliers, or you intend to read the remainder as a signal. ## A diagnostic worth naming Whichever method you use, look at the remainder before you believe the split. Repetition at the seasonal period means the seasonal component is mis-specified. Amplitude that grows with the level means you needed a multiplicative structure. A run of same-signed remainders means the trend smoother is too stiff. STL gives you more knobs to fix these, but the diagnosis comes from the same plot.
- What goes wrong if you set STL's seasonal smoothing window too narrow?The seasonal component becomes free to change from cycle to cycle, so it starts fitting noise and can even absorb genuine level shifts that belong to the trend. The result looks deceptively good, with a small remainder and a calm trend, while the seasonal component quietly carries movements that are not seasonal at all. Widening the window forces the shape to be more nearly constant.
- STL is additive only. How do you use it on a series whose seasonal swing grows with the level?Take logs first, since the log of a product is the sum of logs, run the additive decomposition on the transformed series, then exponentiate the components to read them as multiplicative factors. This requires strictly positive data, and remember that back-transformed components are ratios around 1 rather than differences in the original units.
- When would you still prefer a classical moving-average decomposition over STL?When the seasonal pattern is genuinely stable, the data is clean, and the output has to be simple to reproduce and defend. The classical method has no tuning parameters once the period is fixed, so nobody can ask why you chose one smoothing width over another. The price is no robustness, a frozen seasonal shape, and no trend near either end.
saying these in an interview costs you the question
- Calls STL strictly better without naming a cost
- Thinks STL handles multiplicative seasonality directly
- Accepts default smoothing windows without stating them
- Assumes STL understands holidays or month lengths
- Believes a non-robust fit leaves outliers in the remainder