Foundations✓ Mathematical
◆ The PatternThe assumption that makes forecasting possible
A time series is stationary if its statistical properties — mean, variance, and autocovariance — do not change over time. Most classical models (ARIMA, ETS) require stationarity. If your series has a trend or changing variance, you must transform it first.
E[yt] = μ & Var(yt) = σ² & Cov(yt, yt−k) = f(k)
Stationarity means the joint distribution of any collection of time steps depends only on the gaps between them, not on the absolute position in time.
// Interactive — stationary vs non-stationary series
Trend Strength0
| Test | Null Hypothesis | Action |
|---|---|---|
| ADF (Augmented Dickey-Fuller) | Unit root (non-stationary) | p < 0.05 → stationary |
| KPSS | Stationary | p < 0.05 → non-stationary |
| Phillips-Perron | Unit root | Robust to serial correlation |
# Python — test for stationarity from statsmodels.tsa.stattools import adfuller, kpss result = adfuller(series, autolag='AIC') print(f"ADF stat: {result[0]:.4f}, p-value: {result[1]:.4f}") result_kpss = kpss(series, regression='c', nlags='auto') print(f"KPSS stat: {result_kpss[0]:.4f}, p-value: {result_kpss[1]:.4f}")
Use both tests together: ADF and KPSS have opposite null hypotheses. If ADF rejects and KPSS does not, the series is likely stationary. If both fail to reject, you may have a trend-stationary process that needs detrending rather than differencing.
Pattern bridge: Stationarity is the time-series version of the distribution shape assumption in statistics. In markets, regime detection is exactly the question: has the underlying process become non-stationary?