DPredict · Guide test 196
Dickey–Fuller test
Tests a unit root against a stationary alternative with the chosen deterministic terms.
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 = Dickey–Fuller (no lags).
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 · Dickey–Fuller test
Each error carries φ × the previous one; 1 is a random walk.
Your data
Simulated with a known ρIf H₀ were true
- The reference: how τ varies across samples when H₀ is true (Null Atlas: quantiles simulated with 200,000 replicates).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .104).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- zero under a unit root, negative if the series reverts to its mean
- the t ratio of the lagged level
- the estimated autoregressive coefficient
The verdict
τ = −2.59, p = .104
p > α = .050: compatible with H₀
τ looks like a t statistic but doesn't follow a t distribution: under a unit root it sits much further left. Using the t table here would find mean reversion too often. Failing to reject doesn't prove a unit root, because this test has low power against φ near 1.
- Statistic
- −2.592
- p-value
- 0.1038
Dickey–Fuller test on 40 (x, y) pairs: τ = −2.59, p = .104. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: autoregressive root ρ=1; H1: stationarity around 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. The basic DF regression assumes serially uncorrelated innovations.
Formula
Parameters and notation
dt contains chosen intercept/trend terms; H0 γ=0 versus γ<0.
Structure of the method
Regress first differences on lagged levels and the selected deterministic terms, without augmented difference lags. The lagged-level coefficient's t-shaped ratio is compared with a Dickey–Fuller distribution. Under a unit root the regressor is stochastic and persistent, so ordinary Student-t calibration is invalid.
Estimated and nuisance parameters
The autoregressive deviation from one, deterministic coefficients, and innovation variance are estimated. The null fixes the autoregressive root at one; drift/trend specification determines the reference family rather than serving as an innocuous nuisance option.
Settings and design choices
Prespecify no constant, intercept, or trend as scientifically appropriate, sample endpoints, treatment of missing intervals, and whether basic DF's uncorrelated-innovation assumption is credible. If errors retain serial structure, moving to ADF or another justified test changes the procedure.
Fitting and adaptation
Estimate the stated regression on a regularly ordered series and use matching unit-root critical values. A bootstrap must generate under the unit-root null with the correct deterministic and innovation structure, not simply shuffle observed levels. Refit after a documented transformation; selecting deterministic terms or breaks from the same test evidence needs a transparent strategy.
Sensitivity and robustness
Near-unit-root stationary alternatives are difficult to distinguish in short samples. Structural breaks, measurement changes, seasonal roots, and serially correlated innovations can distort interpretation. Failure to reject does not establish a random walk, and rejection does not establish independent innovations. Report the deterministic model and sample horizon with the statistic.
How to use and calibrate
Use Dickey–Fuller critical values matching deterministic terms; reject in the negative tail.
Example application
Assess whether a series behaves as a random walk rather than a stationary process.
Interpretation and pitfalls
Watch out
The statistic looks like a t ratio but does not follow the ordinary Student t distribution under 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=0,regression="c",autolag=None))
Output
(-1.8987121908829907, 0.33266717910587007, 0, 159, {'1%': np.float64(-3.472161410886292), '5%': np.float64(-2.8798954259680936), '10%': np.float64(-2.5765565828092245)})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=0)))
Output
###############################################
# Augmented Dickey-Fuller Test Unit Root Test #
###############################################
Test regression drift
Call:
lm(formula = z.diff ~ z.lag.1 + 1)
Residuals:
Min 1Q Median 3Q Max
-2.58708 -0.70095 -0.03076 0.70701 2.58412
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.27797 0.15844 -1.754 0.0813 .
z.lag.1 -0.04306 0.02198 -1.959 0.0519 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.9974 on 157 degrees of freedom
Multiple R-squared: 0.02386, Adjusted R-squared: 0.01765
F-statistic: 3.838 on 1 and 157 DF, p-value: 0.05187
Value of test-statistic is: -1.9591 1.9256
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 196, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT196.