TS Stationarity
ML-TS: stationarity is defined three times (Cheatsheet "Basics", Cheatsheet #1, §3), forecasting methods are listed twice (Cheatsheet #5, §6), and windowing appears twice (Ebook 04, Géron 04).
A time series is (weakly) stationary when its statistical properties don't change over time:
-
Constant mean (no trend)
-
Constant variance
-
Autocovariance that depends only on the lag k, not on the time t
Seasonality breaks the constant-mean condition, so a seasonal series isn't stationary either.
Why it matters¶
We only ever observe one realization (a sample path) of the underlying stochastic process: a sequence of random variables indexed by time. Stationarity lets us treat different time points as draws from the same process, so statistics computed along that single path estimate the process's properties. ARMA models require stationarity; ARIMA differences the series until it holds.
Example: random walk (nonstationary)¶
\(Y_t = Y_{t-1} + \varepsilon_t\). The errors accumulate, so the variance grows with time, and an apparent "trend" can be pure chance. The first difference, \(Y_t - Y_{t-1} = \varepsilon_t\), is white noise, which is stationary.
Checking¶
-
Plot the series: look for trend, changing spread, and seasonality.
-
ACF: decays very slowly for a nonstationary series.
-
ADF test: null hypothesis = unit root (nonstationary). High p-value → can't reject → difference the series. Low p-value → stationary.
Making a series stationary¶
| Problem | Transform |
|---|---|
| Trend (random walk, or linear trend) | First difference: \(\nabla Y_t = Y_t - Y_{t-1} = (1 - B)Y_t\) |
| Trend remains after one difference | Second difference (more is rarely needed) |
| Variance grows with the level (common in financial data) | Log transform, then difference if needed |
| Seasonality with period m | Seasonal difference: \(Y_t - Y_{t-m}\) (e.g., m = 12 for monthly data) |
| Deterministic trend, \(Y_t = f(t) + \text{noise}\) | Fit and subtract \(f(t)\) (detrend), or difference |
Re-check (plot / ADF) after each transform. Avoid over-differencing: it introduces artificial negative autocorrelation.