Trend, Seasonality & Decomposition
P7.ts-foundations.02 · Audience: guest, it-ml, language-pro · Prerequisites: What Makes Data a Time Series?
The previous module named the four ingredients of a series — level, trend, seasonality, noise. This module makes the separation mechanical: a moving average to lift out the trend, a per-position average to lift out the season, and whatever remains is the residual. The whole procedure is arithmetic you can check by hand, and by the end you will read a three-panel decomposition plot the way a doctor reads an X-ray.
Here is a tiny series, nine days of a quantity that both grows and cycles. It was built from a trend that climbs by 1 each day and a three-day seasonal pattern that repeats +2, −2, 0 — with no noise at all, so every step of the separation can be verified exactly.
| Day t | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
| Trend (hidden) | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| Season (hidden) | +2 | −2 | 0 | +2 | −2 | 0 | +2 | −2 | 0 |
| Observed y | 12 | 9 | 12 | 15 | 12 | 15 | 18 | 15 | 18 |
In real data only the bottom row is observed. The question of this module: given just 12, 9, 12, 15, 12, 15, 18, 15, 18 — can we recover the two hidden rows? The answer is yes, with two averaging tricks.
Ask the mentor about this module
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
Try it yourself
A scratch console for this page's ideas — ungraded, nothing you run here is recorded.
Scratch console
A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.
Output appears here.
Where next?
Later in Time-Series Foundations