Stationarity
A time series is stationary when its statistical properties do not change over time: its mean, its variance and the correlation between values a given number of periods apart are the same whatever stretch of the series is taken. A stationary series fluctuates around a fixed level and returns to it after a shock. A non-stationary one, such as a price that follows a random walk or a series with a trend, wanders without a fixed level, so its average over one period says little about the next.
Stationarity matters because most statistical methods assume it. A regression of one trending series on another finds a strong relation even when there is none, the spurious regression, and a mean, a volatility or a correlation estimated on a non-stationary series does not carry over to the future. Prices are usually not stationary while returns, their changes, usually are, which is why risk and performance measures work with returns.
The unit root tests take a non-stationary series as their null hypothesis. Dickey and Fuller (1979) derived the distribution of the test statistic under a unit root, Phillips and Perron (1988) made the test robust to autocorrelated errors, and Kwiatkowski, Phillips, Schmidt and Shin (1992) reversed the hypotheses, with stationarity as the null. Using a test of each kind gives a firmer answer: a series is stationary when the unit root is rejected and stationarity is not.
The Finance Toolkit tests stationarity with the unit root tests, among them the Augmented Dickey-Fuller and the Phillips-Perron test and the Zivot-Andrews test, which allows for a structural break, and with the KPSS test. Two non-stationary series can still share a stationary combination, which the cointegration tests look for.
Example · ^GSPC, ^VIX · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then:
from financetoolkit import Toolkit
toolkit = Toolkit(
["^GSPC", "^VIX"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
benchmark_ticker=None,
)
toolkit.econometrics.get_unit_root_test()
Which returns:
| Item | ^GSPC | ^VIX |
|---|---|---|
| ADF Statistic | 0.1693 | -5.6898 |
| P-Value | 0.9705 | 8.119e-07 |
| Lags Used | 4 | 1 |
| Observations | 1250 | 1276 |
| Critical Value 1% | -3.4356 | -3.4355 |
| Critical Value 5% | -2.8639 | -2.8638 |
| Critical Value 10% | -2.568 | -2.568 |
| Reject Unit Root (5%) | 0 | 1 |
References
- Paper Dickey, D.A. & Fuller, W.A. (1979). “Distribution of the Estimators for Autoregressive Time Series with a Unit Root.” Journal of the American Statistical Association, 74(366), 427-431.
- Paper Phillips, P.C.B. & Perron, P. (1988). “Testing for a Unit Root in Time Series Regression.” Biometrika, 75(2), 335-346.
- Paper Kwiatkowski, D., Phillips, P.C.B., Schmidt, P. & Shin, Y. (1992). “Testing the Null Hypothesis of Stationarity Against the Alternative of a Unit Root.” Journal of Econometrics, 54(1-3), 159-178.