TL;DR
A time series is often a mix of a slow level that drifts, a pattern that repeats every season, and whatever is left over. Time series decomposition estimates each part separately, so the series can be read as trend plus season plus remainder. The most common version is additive, . It is a descriptive tool: it shows what is going on, and it is the usual first step before seasonal adjustment or forecasting.
Builds on: Stochastic Process, Linear Regression · Leads to: seasonal adjustment and forecasting of each component
Where it's used
Seasonal adjustment of official statistics. Retail sales rise every December for reasons that have nothing to do with the economy's direction. Statistics offices decompose the series, remove the seasonal part, and publish the adjusted figure, so that a real change is not hidden or invented by the calendar.
Electricity and energy demand. A city's daily demand has a weekly cycle, with weekdays busier than weekends, and a slow trend that follows growth or decline. Decomposition separates the weekly pattern from the trend, and the remainder shows unusual days such as public holidays or a heatwave.
Website and app traffic. A product team sees daily visits with a long upward trend and a strong weekly rhythm. Decomposing the series lets them judge whether a launch lifted the trend or just landed on a busy weekday.
How it works
Here is one tiny instance traced from start to finish. The series is quarterly, so the season repeats every 4 steps. It was built from a trend and a seasonal pattern , with no noise. Over eight quarters it reads 13, 12, 11, 14, 17, 16, 15, 18.
- Start with the series. The values for to are 13, 12, 11, 14, 17, 16, 15 and 18. Check: there are eight values, and the pattern goes up and down in a four-step rhythm.
- Estimate the trend with a centred moving average. For a quarterly series, average each point with its neighbours, giving the two ends of the window half weight: . This needs two points on each side, so to get a trend, giving 13, 14, 15 and 16. Check: the trend rises by one each step, as the trend does.
- Remove the trend. Subtract it from the series at those four times: , , , and . Check: these are the seasonal values with the trend gone.
- Average each season. Quarter 1 gives (time 5), quarter 2 gives (time 6), quarter 3 gives (time 3), and quarter 4 gives (time 4). Their sum is 0, so the pattern is already centred. Check: .
- Compute the remainder. At each time, subtract the trend and the seasonal value: at , . Check: every remainder here is 0, because the series had no noise.
- Read the result. The series is exactly trend plus season. The trend is the rising level, and the seasonal pattern is the four-step rhythm.
The diagram shows the four stages in order.
flowchart LR A[Series y] --> B[Trend by centred moving average] B --> C[Detrended values y minus trend] C --> D[Average by season, then centre] B --> E[Remainder y minus trend minus season] D --> E
The math
A series with period is written as
where is the trend, is the seasonal component with , and is the remainder. The seasonal values are centred so that they sum to zero over one period. For a series whose seasonal swings grow with its level, the multiplicative form fits better. Taking logarithms turns it into the additive form for .
Step 1 in symbols: the trend
For an even period , the classical trend is a centred moving average, with half weight on the two end points:
For this is the formula in the walkthrough. Because it needs points on each side, the first and last times have no trend estimate. A moving average is a simple smoothing device, and the Exponential Moving Average is a related one that weights recent points more.
Step 2 in symbols: the detrended series
Let at every time with a trend. In the walkthrough, , , and .
Step 3 in symbols: the seasonal component
Let be the season index of time , from 1 to . The raw seasonal value for season is the average of the detrended values in that season,
where is the number of such times. Averaging by season is the same as a regression of the detrended values on season indicators. Then centre the values, , so that they sum to zero. In the walkthrough each season has one value, so , which already sums to zero.
Step 4 in symbols: the remainder
The remainder at each time is . For , . In a real series the remainder carries the noise and any unusual events, and it is the part that should look structureless.
Worked examples
Suppose the averaged seasonal values for a quarterly series are .
- Their sum is .
- The centring shift is , the average of the four values.
- Subtract the shift from each value: .
- Check: the new values sum to .
- Interpretation: the centring moves the overall level into the trend, so the seasonal part only says how each quarter differs from the average quarter.
A monthly series has 36 months and period 12. The classical trend needs 6 months on each side, so it exists from month 7 to month 30. The numbers are illustrative.
- Months with a trend: , which are months 7 to 30.
- Months per season: each season index appears in those 24 months exactly twice, since .
- Each seasonal value is the average of its two detrended values, so every season has an estimate.
- The remainder exists only for months 7 to 30, so the first and last 6 months have no decomposition.
- Interpretation: a 36-month series gives 24 usable points for the trend and the remainder, which is why longer series give more reliable decompositions.
Try it: a monthly series runs for 60 months. How many months have a trend estimate, and how many detrended values does each season have? Answer: months have a trend, and detrended values fall in each season.
A utility has three years of daily demand, with a weekly period of 7 days. Because 7 is odd, the centred moving average is a single window of 7 days, with 3 days on each side. The numbers are invented for illustration.
- Days in three years: .
- Days with a trend: , since 3 days are lost at each end.
- Each weekday has about detrended values, so the weekly seasonal value for each weekday is an average over about 155 days.
- The seasonal values show the weekly rhythm, for example higher weekday demand than weekend demand.
- The remainder is examined for spikes. A public holiday falling on a weekday shows as a large negative remainder, because demand fell below what the trend and the weekly pattern predict.
- Interpretation: the decomposition separates a growing trend and a steady weekly rhythm from the days that break the pattern, so the utility can plan capacity from the trend and treat the remainder as events to explain.
Try it: a utility has two years of daily data, with the same weekly period. How many days have a trend estimate? Answer: days.
Common mistakes and tradeoffs
It is tempting to think a decomposition is the true trend and the true season. In fact the parts depend on the method and on the period chosen. Different methods, such as the classical moving-average method and the robust STL method, can give different trends for the same data, and none is the uniquely correct one.
It is tempting to think the additive form always fits. In fact if the seasonal swings grow as the level grows, the additive model mixes up the trend and the season. Use the multiplicative form, or take logarithms and decompose again.
It is tempting to think the remainder is always just noise. In fact the remainder can hide structure, such as holidays, a level shift, or a seasonal pattern that changes over the years. Check it for patterns, for example with the autocorrelation function, before trusting it.
It is tempting to think decomposition makes a forecast. In fact it describes the past. To forecast, each component needs its own assumption, such as a trend that continues and a season that repeats, and those assumptions must be tested.
| Method | Trend estimate | Notes |
|---|---|---|
| Classical additive | Centred moving average | Simple and transparent, but the seasonal pattern is fixed over time |
| Classical multiplicative | Centred moving average on the original scale | For swings that grow with the level |
| STL | Repeated local regression (local regression) | Lets the seasonal pattern change and resists outliers |
When to use it. Use decomposition to describe a series with a clear season, to seasonally adjust before comparing periods, and to spot unusual values in the remainder.
When not to use it. Avoid it when the series is too short for even a few seasons, or when the seasonal pattern is so irregular that a single average season misleads.
History
Early in the twentieth century economists and statisticians tracking business activity began separating the regular calendar effects from the underlying movement of the economy. Methods based on ratios to moving averages became the standard for decades, and statistics offices used them to publish seasonally adjusted figures.
In 1990 Cleveland and colleagues introduced STL, a method that estimates the trend and seasonal parts with repeated local regression. It was designed to cope with seasonal patterns that change over time and with outliers, and it has since become one of the common tools in applied time series work. Its ideas are the same as the classical method: a trend, a season and a remainder, estimated in turn.
Recap
- A time series is split into trend, seasonal and remainder, in the additive form , or the multiplicative form when swings grow with the level.
- The classical method estimates the trend by a centred moving average, removes it, averages the detrended values by season, centres the seasons, and takes what remains as the remainder.
- The trend and the remainder have no estimate at the ends of the series, which is why longer series give more usable points.
- Decomposition describes the past, so forecasting needs an explicit assumption for each component.
- Read next: Stationary Process for the statistical assumptions that decomposed series often need, and Autocorrelation Function for checking the remainder.