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 is identical to shifted joint distribution for all shifts .
2. Weak (Covariance) Stationarity (Industry Standard)
- Constant Mean: for all .
- Constant Variance: for all .
- Lag-dependent Autocovariance: (Depends only on lag , not timestamp ).
Transforming Non-Stationary Series
- First Differencing (): Removes linear trend:
- Seasonal Differencing (): Removes seasonal cycles of period (e.g. 12 months):
- Log Transformation (): Stabilizes exponential growth / heteroscedastic growing variance before differencing.
Testing Stationarity: ADF Test
Augmented Dickey-Fuller (ADF) Test:
- Null Hypothesis (): Unit root exists ( in ). Series is non-stationary.
- Alternative (): Series is stationary.
If ADF statistic , reject 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 and are cointegrated if a linear combination 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?