DPredict · Guide test 197
Augmented Dickey–Fuller test
Adds lagged differences to the unit root regression to accommodate serially correlated errors.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Unit-root and stationarity tests — Does the series wander like a random walk (a unit root), or return to a mean or trend — and how many differences make it stationary?
In Unit-root and stationarity tests, choose Test = Augmented Dickey–Fuller.
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Augmented Dickey–Fuller test
Each error carries φ × the previous one; 1 is a random walk.
Extra lags of Δy that soak up short-run dynamics.
Your data
Simulated with a known ρIf H₀ were true
- The reference: how τ varies across samples when H₀ is true, Dickey–Fuller τ with a constant (MacKinnon (1994) response surface (asymptotic)).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .069).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- zero under a unit root
- lagged differences that absorb serial correlation
- compared with MacKinnon's Dickey–Fuller distribution, not the t table
The verdict
τ = −2.73, p = .069
p > α = .050: compatible with H₀
Low power against φ near 1, and a level shift can look like a unit root (try the shift control). Too few lags distort size, too many waste power.
- Statistic
- −2.728
- p-value
- 0.0693
Augmented Dickey–Fuller test on 60 (x, y) pairs: τ = −2.73, p = .069. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: a unit root; H1: stationarity about the specified deterministic component.
Assumptions
A regularly ordered time series with a specified deterministic component (none, intercept, or trend); innovations satisfy the selected unit-root test’s weak-dependence/moment conditions. Lag/bandwidth choices and breaks affect calibration.
Formula
Parameters and notation
p augmenting lags should leave approximately uncorrelated residuals; test statistic is the t ratio for γ=0.
Structure of the method
Add lagged first differences to the Dickey–Fuller regression so short-run dependence can be absorbed while testing the lagged-level coefficient. The augmentation aims to produce approximately uncorrelated innovations. The test remains nonstandard under the unit-root null despite looking like an ordinary regression t test.
Estimated and nuisance parameters
Deterministic coefficients, the lagged-level coefficient, short-run difference-lag coefficients, and residual variance are fitted. The selected lag count controls the nuisance-dynamics approximation and effective sample size; it is not a learned structural unit-root parameter.
Settings and design choices
Specify deterministic terms, maximum lag, fixed/AIC/BIC/sequential selection rule, and the sample used during lag comparison. Keep candidate models on comparable rows when selecting lags. The supplied examples intentionally fix four augmentation lags rather than automatically optimizing them.
Fitting and adaptation
Fit the complete auxiliary regression and inspect residual serial dependence. If lag selection is part of a bootstrap test, repeat it in simulated null datasets rather than treating a selected order as externally fixed. Forecast-model tuning and unit-root hypothesis testing are related decisions but use different objectives and uncertainty calculations.
Sensitivity and robustness
Under-augmentation leaves dependence and size distortions; over-augmentation lowers power and may create collinearity. Breaks, heteroskedasticity, seasonal patterns, short samples, and near-unit-root alternatives require care. A large p-value is not a posterior probability of a unit root. Compare the time plot and stationarity-null diagnostics without forcing conflicting tests into a binary automatic differencing rule.
How to use and calibrate
Use ADF/MacKinnon critical values, not ordinary t tails. State deterministic terms, maximum lag and lag selection rule.
Example application
Check whether differencing is needed for a persistent time series.
Interpretation and pitfalls
Watch out
Too few lags distort size; too many reduce power. Nonrejection does not establish a unit root.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Read the unit-root/stationarity statistic and its nonstandard critical values, not the auxiliary regression coefficient’s ordinary t p-value. Deterministic terms, bandwidth and lag selection must match before comparing implementations.
Validated — Executed successfully in the validation environment · needs numpy, scipy, statsmodels
import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
x=np.cumsum(rng.normal(size=160))
from statsmodels.tsa.stattools import adfuller
print(adfuller(x,maxlag=4,regression="c",autolag=None))
Output
(-1.896305793265067, 0.33380097296321043, 4, 155, {'1%': np.float64(-3.4732590518613002), '5%': np.float64(-2.880374082105334), '10%': np.float64(-2.5768120811654525)})Validated — Executed successfully in the validation environment · needs urca
set.seed(2026)
x<-cumsum(rnorm(160))
library(urca)
print(summary(ur.df(x,type="drift",lags=4,selectlags="Fixed")))
Output
###############################################
# Augmented Dickey-Fuller Test Unit Root Test #
###############################################
Test regression drift
Call:
lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
Residuals:
Min 1Q Median 3Q Max
-2.4532 -0.6422 -0.0711 0.6825 2.4573
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.34644 0.17121 -2.024 0.0448 *
z.lag.1 -0.05453 0.02370 -2.300 0.0228 *
z.diff.lag1 -0.06944 0.08076 -0.860 0.3913
z.diff.lag2 0.17748 0.08076 2.198 0.0295 *
z.diff.lag3 0.11709 0.08167 1.434 0.1537
z.diff.lag4 0.10044 0.08144 1.233 0.2194
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.9905 on 149 degrees of freedom
Multiple R-squared: 0.07697, Adjusted R-squared: 0.046
F-statistic: 2.485 on 5 and 149 DF, p-value: 0.03406
Value of test-statistic is: -2.3005 2.6465
Critical values for test statistics:
1pct 5pct 10pct
tau2 -3.46 -2.88 -2.57
phi1 6.52 4.63 3.81Sources
- urca — urca · ur.dfAuthor documentation/source reviewed: urca 1.3-4.search.r-project.org
- ur.dfsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Executed successfully in the validation environment · R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Unavailable local dependencies: statsmodels. Python: Not run in the reference's review: Unavailable local dependencies: statsmodels. No installation attempted. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 197, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT197.