- Validated against Python `statsmodels.tsa.stattools.adfuller` reference implementation.
The Augmented Dickey-Fuller test is the gold standard for detecting whether a financial time series is stationary or contains a unit root. Unlike the original Dickey-Fuller test, the augmented version includes lagged difference terms $\Delta y_{t-i}$ to absorb serial correlation, ensuring the test statistic follows the correct distribution. The p-value output uses MacKinnon (1994, 2010) polynomial interpolation with a standard normal CDF approximation, providing machine-precision results without lookup tables.
## Historical Context
David Dickey and Wayne Fuller introduced the original unit root test in 1979, establishing the foundation for modern time series econometrics. Said and Dickey (1984) proposed the augmented version that includes lagged differences to handle serial correlation in the residuals. James MacKinnon (1994, 2010) developed the response surface regression approach that maps the test statistic to an approximate p-value, replacing the need for Monte Carlo simulation tables. The ADF test remains the most widely used stationarity test in quantitative finance, underpinning pairs trading, cointegration analysis, and regime detection.
where $\alpha$ is the intercept (constant model), $\beta t$ is the linear trend (trend model), $\gamma$ is the coefficient of interest on the lagged level, and $\delta_i$ are coefficients on lagged differences that absorb serial correlation.
### 3. OLS Estimation via Cholesky
The normal equations $X'X \hat{\beta} = X'y$ are solved via Cholesky decomposition $X'X = LL'$ with forward-backward substitution. For $k \leq 8$ regressors, all matrices fit in `stackalloc` — zero heap allocation.
The polynomial Z-score is then passed through the standard normal CDF: $p = \Phi(Z)$.
#### Small-P Coefficients ($\tau \leq \tau^*$)
| Regression | $c_0$ | $c_1$ | $c_2$ |
|:-:|:-:|:-:|:-:|
| nc | 0.6344 | 1.2378 | 0.032496 |
| c | 2.1659 | 1.4412 | 0.038269 |
| ct | 3.2512 | 1.6047 | 0.049588 |
#### Large-P Coefficients ($\tau > \tau^*$)
| Regression | $c_0$ | $c_1$ | $c_2$ | $c_3$ |
|:-:|:-:|:-:|:-:|:-:|
| nc | 0.4797 | 0.93557 | −0.06999 | 0.033066 |
| c | 1.7339 | 0.93202 | −0.12745 | −0.010368 |
| ct | 2.5261 | 0.61654 | −0.37956 | −0.060285 |
### 7. Standard Normal CDF via Error Function
The standard normal CDF $\Phi(x)$ is computed via the Abramowitz & Stegun (1964) rational approximation of the Gaussian error function (equation 7.1.26):
| **Self-consistency** | ✅ | Batch/streaming/span match |
## Common Pitfalls
1.**Warmup period**: Requires at least 20 bars. Results before warmup return p=1.0 (assume unit root).
2.**Lag selection**: Auto-lag (maxLag=0) uses AIC which may overfit on short windows. For periods < 50, consider fixing maxLag=1.
3.**Regression model**: Using `ConstantAndTrend` when no trend exists reduces power (higher p-values). Default `Constant` is correct for most financial series.
4.**Non-standard distribution**: The test statistic does NOT follow a t-distribution — MacKinnon critical values are mandatory.
5.**Window size**: Period < 30 gives unreliable results. Period ≥ 50 recommended for financial data.
6.**Multiple testing**: Running ADF on many series without Bonferroni correction inflates false positives.
7.**Structural breaks**: ADF has low power against alternatives with structural breaks. Consider using Zivot-Andrews test instead.
## Related Indicators
- [**Hurst**](../hurst/Hurst.md): Measures long-range dependence. H < 0.5 and ADF p < 0.05 together strongly confirm mean-reversion.
- [**Cointegration**](../cointegration/Cointegration.md): Uses a simplified ADF internally on OLS residuals for the Engle-Granger two-step test.
- [**Variance**](../variance/Variance.md): High variance ratio rejection and low ADF p-value confirm stationarity.
## References
- Dickey, D.A. and 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.
- Said, S.E. and Dickey, D.A. (1984). "Testing for Unit Roots in Autoregressive-Moving Average Models of Unknown Order." *Biometrika*, 71(3), 599-607.
- Schwert, G.W. (1989). "Tests for Unit Roots: A Monte Carlo Investigation." *Journal of Business & Economic Statistics*, 7(2), 147-159.
- MacKinnon, J.G. (1994). "Approximate Asymptotic Distribution Functions for Unit-Root and Cointegration Tests." *Journal of Business & Economic Statistics*, 12(2), 167-176.
- MacKinnon, J.G. (2010). "Critical Values for Cointegration Tests." Working Paper 1227, Queen's University Department of Economics.
- Abramowitz, M. and Stegun, I.A. (1964). *Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables*. National Bureau of Standards Applied Mathematics Series 55, §7.1.26.