Skip to content

DPredict · Guide test 199

DF GLS or Elliott–Rothenberg–Stock test

Uses generalized least squares detrending to improve unit root testing power.

Runs in CodeSplashPython (calls R) example not runR example validated

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 = DF-GLS (Elliott–Rothenberg–Stock).

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 · DF GLS (Elliott–Rothenberg–Stock) test

60
0.000
0.80

Each error carries φ × the previous one; 1 is a random walk.

0.0
2

Extra lags of Δy that soak up short-run dynamics.

0.050

Your data

Simulated with a known ρ

If H₀ were true

τ_GLS = −2.56
  1. The reference: how τ_GLS varies across samples when H₀ is true, Dickey–Fuller τ without deterministic terms (MacKinnon (1994) response surface (asymptotic)).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .010).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

ytd=yt−μ^GLS,αˉ=1−7/n,Δytd=γ yt−1d+∑j=1kδj Δyt−jd+εty^d_t = y_t - \hat\mu_{GLS},\quad \bar\alpha = 1 - 7/n,\qquad \Delta y^d_t = \gamma\,y^d_{t-1} + \sum_{j=1}^{k}\delta_j\,\Delta y^d_{t-j} + \varepsilon_t

With your numbers

τGLS=(−2.56),k=2, n=60\tau_{GLS} = (-2.56),\qquad k = 2,\ n = 60
μ^GLS\hat\mu_{GLS}
the mean estimated on quasi-differences with ᾱ = 1 + c/n, c = −7
ytdy^d_t
the GLS-demeaned series

The verdict

τ_GLS = −2.56, p = .010

p ≤ α = .050: reject H₀

Noticeably more powerful than ADF when the series is close to a unit root; the reference is Dickey–Fuller's no-constant distribution.

Statistic
−2.565
p-value
0.0100
DF GLS (Elliott–Rothenberg–Stock) test on 60 (x, y) pairs: τ_GLS = −2.56, p = .010. The p-value is below α = .050, so the data are hard to reconcile with H0.

DF GLS (Elliott–Rothenberg–Stock) test on 60 (x, y) pairs: τ_GLS = −2.56, p = .010. The p-value is below α = .050, so the data are hard to reconcile with H₀.

Question and hypotheses

H0: a unit root; H1: local stationarity around an intercept/trend.

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

αˉ=1+c/Tyt∗=yt−αˉyt−1zt∗=zt−αˉzt−1ytd=yt−ztTδ^GLS\begin{gathered}\bar\alpha=1+c/T\\[5pt] y_t^*=y_t-\bar\alpha y_{t-1}\\[5pt] z_t^*=z_t-\bar\alpha z_{t-1}\\[5pt] y_t^d=y_t-z_t^T\widehat\delta_{GLS}\end{gathered}

Parameters and notation

Initialize first transformed observation according to the ERS convention; regress y* on z* to estimate δGLS. Common local constants c=−7 for a constant and −13.5 for a trend.

Structure of the method

Quasi-difference the series and deterministic regressors using a specified local-to-unity constant, estimate GLS detrending coefficients, subtract the fitted deterministic component, and run a no-added-deterministic-term augmented unit-root regression on the detrended series. This two-stage construction differs from simply requesting a trend in ordinary ADF.

Estimated and nuisance parameters

GLS deterministic coefficients and subsequent lagged-level/difference-lag coefficients are estimated. The local-to-unity constant is supplied by the test design rather than estimated as the series' true autoregressive coefficient. Initial transformed observations follow the chosen ERS convention.

Settings and design choices

Prespecify constant versus trend, local constant, lag cap/selection method, and DF-GLS versus the related point-optimal ERS statistic. Software options and critical-value tables must correspond to the exact variant; 'ERS test' alone is ambiguous.

Fitting and adaptation

Repeat GLS detrending and auxiliary regression whenever the sample changes. In simulation-based calibration, preserve null generation, initial-value handling, and lag selection. Do not add back an intercept automatically in the detrended regression without checking the intended procedure. This is nuisance-trend estimation and test calibration, not predictive neural fine-tuning.

Sensitivity and robustness

Power gains rely on matching the deterministic structure and handling short-run dependence adequately. Breaks, short series, excessive lags, and near-collinearity of trend regressors can weaken results. DF-GLS critical values should not be replaced indiscriminately by ordinary ADF values. Report the exact detrending specification and selected lag count alongside conclusions.

How to use and calibrate

Run an ADF regression without added deterministic terms on detrended yd and use DF–GLS-specific critical values. ERS point-optimal statistics are related but distinct.

Example application

Improve power against persistent stationary alternatives.

Interpretation and pitfalls

Watch out

Ordinary ADF critical values cannot automatically replace DF–GLS values. Specify detrending and lag rule.

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.

Python · invokes R

Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: urca

# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
    raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
x<-cumsum(rnorm(160))
library(urca)
print(summary(ur.ers(x,type="DF-GLS",model="constant",lag.max=4)))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
                        text=True, capture_output=True)
print(result.stdout)
if result.stderr:
    print(result.stderr)
result.check_returncode()
R

Validated — Executed successfully in the validation environment · needs urca

set.seed(2026)
x<-cumsum(rnorm(160))
library(urca)
print(summary(ur.ers(x,type="DF-GLS",model="constant",lag.max=4)))
Output
############################################### 
# Elliot, Rothenberg and Stock Unit Root Test # 
############################################### 

Test of type DF-GLS 
detrending of series with intercept 


Call:
lm(formula = dfgls.form, data = data.dfgls)

Residuals:
    Min      1Q  Median      3Q     Max 
-2.5294 -0.7560 -0.1368  0.6111  2.4617 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)  
yd.lag       -0.01597    0.01281  -1.246   0.2147  
yd.diff.lag1 -0.08328    0.08117  -1.026   0.3065  
yd.diff.lag2  0.16372    0.08116   2.017   0.0455 *
yd.diff.lag3  0.09381    0.08149   1.151   0.2515  
yd.diff.lag4  0.07784    0.08132   0.957   0.3400  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.9994 on 150 degrees of freedom
Multiple R-squared:  0.05398,	Adjusted R-squared:  0.02244 
F-statistic: 1.712 on 5 and 150 DF,  p-value: 0.1352


Value of test-statistic is: -1.2459 

Critical values of DF-GLS are:
                 1pct  5pct 10pct
critical values -2.58 -1.94 -1.62

Sources

Statistics guide v4 (historical):
Python: Executed end to end through Rscript · R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 199, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT199.