Trend, Seasonality & Residual Decomposition
Trend, Seasonality & Residual Decomposition
Time series data in business contexts (e.g., e-commerce order volumes, server API loads, electricity demand) is driven by multiple overlapping dynamics. Classical Time Series Decomposition untangles raw metrics into three distinct, interpretable components: Trend, Seasonality, and Residual Noise.
1. The Core Components of Time Series
- 1Trend ($T_t$): The overarching long-term directional movement of the metric (e.g., year-over-year revenue expansion or contraction).
- 2Seasonality ($S_t$): Recurring, predictable periodic patterns tied to the calendar (e.g., weekly weekend spikes, holiday surges every November/December).
- 3Residual Noise ($R_t$ or $I_t$): The irregular, random variations remaining after removing trend and seasonality. Residuals reflect unexpected events, promotions, or pure stochastic noise.
2. Additive vs Multiplicative Decomposition
Choosing the proper decomposition mathematical model is crucial:
Additive Model
$$Y_t = T_t + S_t + R_t$$
- When to use: When the magnitude of seasonal fluctuations remains constant regardless of whether the overall trend is increasing or decreasing.
Multiplicative Model
$$Y_t = T_t \times S_t \times R_t$$
- When to use: When the seasonal oscillations grow proportionally as the overall trend increases (very common in growing startups, revenue, and web traffic).
3. Implementing Decomposition with statsmodels
In Python, the statsmodels library provides seasonal_decompose and STL (Seasonal and Trend decomposition using Loess):
4. Modern STL Decomposition (Loess Smoothing)
Classical decomposition suffers when seasonality drifts over time or when outliers distort moving averages. STL provides robust, non-parametric smoothing:
Multiple Choice Questions
period parameter in seasonal_decompose?Lag Features, Autocorrelation & Stationarity Checks
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
| Previous Lesson | Next Lesson |
|---|---|
| Window Functions & Moving Averages in Pandas | Lag Features, Autocorrelation & Stationarity Checks |
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.