Stationarity & Differencing
Why classical time series models fail completely on non-stationary data, and how differencing transforms raw data into stationary signals.
What is Stationarity?
Classical statistical time-series algorithms (ARIMA) assume statistical properties of historical data will remain constant in the future.
Non-Stationary Series (Upward Trend + Growing Variance)
100 ┤ /\ /\
50 ┤ /\ /\ /\ / \/ \
0 ┴───────────────────────────────/──\/──\/──\/────────► Time
(Mean μ_t increases; Variance σ²_t grows! Spurious predictions)
Stationary Series (Constant Mean, Constant Variance around Zero)
10 ┤ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\
0 ┼───/──\/──\/──\/──\/──\/──\/──\/──\/──\/──\/──\/────► Time
-10 ┤
(Mean E[Y_t] = 0, Variance Var(Y_t) = σ² constant across time)
1. Strict Stationarity
Joint distribution of $(Y_{t_1}, \dots, Y_{t_n})$ is identical to shifted joint distribution $(Y_{t_1+k}, \dots, Y_{t_n+k})$ for all shifts $k$.
2. Weak (Covariance) Stationarity (Industry Standard)
- Constant Mean: $\mathbb{E}[Y_t] = \mu$ for all $t$.
- Constant Variance: $\text{Var}(Y_t) = \sigma^2 < \infty$ for all $t$.
- Lag-dependent Autocovariance: $\text{Cov}(Y_t, Y_{t+k}) = \gamma(k)$ (Depends only on lag $k$, not timestamp $t$).
Transforming Non-Stationary Series
- First Differencing ($\Delta Y_t$): Removes linear trend:
$$\Delta Y_t = Y_t - Y_{t-1}$$
- Seasonal Differencing ($\Delta_s Y_t$): Removes seasonal cycles of period $s$ (e.g. 12 months):
$$\Delta_s Y_t = Y_t - Y_{t-s}$$
- Log Transformation ($\ln Y_t$): Stabilizes exponential growth / heteroscedastic growing variance before differencing.
Testing Stationarity: ADF Test
Augmented Dickey-Fuller (ADF) Test:
- Null Hypothesis ($H_0$): Unit root exists ($\gamma = 0$ in $\Delta Y_t = \alpha + \beta t + \gamma Y_{t-1} + \dots$). Series is non-stationary.
- Alternative ($H_1$): Series is stationary.
If ADF statistic $p\text{-value} < 0.05$, reject $H_0 \implies$ Confirm series is stationary.
Say this out loud
"Stationarity requires constant mean, constant variance, and autocovariance depending only on lag distance k. Non-stationary data containing trends or growing variance causes classical forecasting algorithms like ARIMA to fail. We achieve stationarity by applying log transforms to stabilize variance, first differencing (Y_t - Y_t-1) to remove linear trends, and validating with the Augmented Dickey-Fuller (ADF) test (p < 0.05)."
Follow-ups to expect
- What is Spurious Regression? Regressing one non-stationary series on another unrelated non-stationary series (e.g. US GDP vs Global Temperature) produces falsely high R² and low p-values due to shared trends, despite zero causal relationship.
- What is Cointegration? Two non-stationary time series $X_t$ and $Y_t$ are cointegrated if a linear combination $Z_t = Y_t - \beta X_t$ is stationary. Used in algorithmic pairs trading (long/short stock pairs).
Check yourself
What 3 statistical properties must hold for a time series Y_t to be Weakly (Covariance) Stationary?