*! version 1.0.0 22may2026

Title

urtable -- Joint ADF, DF-GLS, PP, and KPSS unit-root tests
with data-driven lag/bandwidth selection

Syntax

urtable varname [if] [in]
[,
lags(#)
trend
bgp(#)
rhocap(#)]

varname must be tsset.

Main
lags(#) max lag for ADF BG search and DF-GLS criterion
search; default is the Schwert rule, floor(12*(T/100)^(1/4)).

trend include a linear trend in the deterministic
component; default is constant only.

bgp(#) Breusch-Godfrey p-value threshold used in the ADF
general-to-specific lag search; default is 0.10.

rhocap(#) cap on |rho_hat| in Andrews (1991) AR(1) plug-in
to avoid bandwidth blow-up near unit root; default is 0.97.

Description

urtable reports four unit-root and stationarity tests on a single
time series in one comparison table: the augmented Dickey-Fuller (ADF), the
Elliott-Rothenberg-Stock GLS-detrended DF (DF-GLS) in three variants based
on different lag-selection criteria, the Phillips-Perron (PP), and the
Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test. All lag lengths and
bandwidths are chosen data-driven. The output table includes critical
values at 1%, 5%, and 10%, decision flags, and a one-sentence conclusion at
the 5% level that aggregates the evidence across the four tests.

The command targets pedagogical use in time-series courses: every lag,
bandwidth, and decision is shown explicitly, and the underlying
methodology is documented in the footer of the output.

Options

lags(#) sets the maximum lag for the ADF BG search and the DF-GLS
criterion search. If omitted, the Schwert (1989) rule is applied:
floor(12*(T/100)^(1/4)). Note that PP and KPSS bandwidths are set by their
own data-driven Andrews (1991) procedure and do not use lags().

trend includes a linear time trend in the deterministic component
of each test. Without it, only a constant is included.

bgp(#) controls the Breusch-Godfrey p-value threshold for the ADF
lag selection. The smallest k in [0, lags] with BG p-value above this
threshold is selected. Stricter thresholds (e.g., 0.05) tend to choose
shorter lags; looser thresholds (e.g., 0.15) tend to choose longer lags.

rhocap(#) caps the absolute value of the AR(1) coefficient
estimated on test residuals when computing the Andrews (1991) Bartlett
bandwidth. Necessary because alpha(1) = 4*rho^2/(1-rho^2)^2 diverges as
|rho| approaches 1, which is common in KPSS residuals under H1.

Methodology

ADF. The dependent variable is Delta y_t. The regression is

Delta y_t = alpha (+ beta*t) + gamma*y_ + sum_^k phi_j*Delta y_ + e_t

Lag k is chosen by a general-to-specific procedure (Hall 1994): for
k = 0, 1, ..., lags, the regression residuals are tested with the
Breusch-Godfrey LM test of order max(4, k+1). The smallest k with BG
p-value above bgp() is selected.

DF-GLS. GLS detrending follows Elliott, Rothenberg, and Stock
(1996). With cbar = -7 (constant) or -13.5 (trend), the series and
regressors are quasi-differenced at alpha* = 1 + cbar/T. The resulting
GLS-detrended series y* is then used in an ADF-type regression without
constant or trend.

Three lag-selection criteria are reported as separate rows:

ERS sequential-t: starting from k = lags, the highest k whose lag
coefficient satisfies |t| > 1.645 (Ng-Perron 1995).

Min SC: argmin over k = 0..lags of ln(sigma^2) + (k+1)*ln(N)/N
(Schwarz / BIC).

Min MAIC: argmin of ln(sigma^2) + 2*(tau(k)+k)/N where
tau(k) = gamma^2 * sum(y*_)^2 / sigma^2 (Ng-Perron 2001).

All three regressions use a common sample (the maxlag sample) so that
the criteria are directly comparable.

DF-GLS critical values are from ERS (1996) Table 1, bracketed by sample
size (T<75, T<150, T<300, T>=300) for the trend case and the asymptotic
values for the constant-only case.

PP and KPSS. Bandwidth is selected by the Andrews (1991) AR(1)
plug-in rule for the Bartlett kernel:

alpha(1) = 4*rho^2 / (1-rho^2)^2

BW = ceil(1.1447 * (alpha(1) * T)^(1/3))

For PP, rho is estimated from AR(1) applied to residuals of the PP-type
level regression (Delta y on y_ with constant/trend). For KPSS, rho
is from AR(1) on residuals of the level regression y on constant
(+trend). |rho| is capped at rhocap() and BW is capped at the
Schwert max.

The official ADF and PP statistics are taken from Stata's dfuller
and pperron at the selected lag/bandwidth. The KPSS statistic is
computed manually with a Bartlett kernel using the selected bandwidth.
The DF-GLS regressions and statistics are also computed manually, so
urtable does not depend on Stata's dfgls command.

Examples

Setup:

. webuse air2

. tsset time

Default model (constant only):

. urtable air

With a linear trend:

. urtable air, trend

Limit the ADF/DF-GLS lag search to 6:

. urtable air, lags(6) trend

Stricter BG threshold (prefer shorter ADF lags):

. urtable air, bgp(0.05)

Lower rho cap (more conservative Andrews bandwidth):

. urtable air, rhocap(0.90)

Test the first difference (should be stationary):

. urtable D.air

Stored results

urtable stores the following in r():

Scalars

r(adf_stat) ADF tau statistic

r(adf_p) ADF MacKinnon p-value

r(adf_lag) selected ADF lag

r(adf_bg_p) BG p-value at selected lag

r(pp_stat) PP tau statistic

r(pp_p) PP p-value

r(pp_lag) PP bandwidth

r(pp_rho) capped AR(1) coefficient (PP residuals)

r(kpss_stat) KPSS LM statistic

r(kpss_lag) KPSS bandwidth

r(kpss_rho) capped AR(1) coefficient (KPSS residuals)

r(dfgls_ers_lag) DF-GLS lag selected by ERS seq-t

r(dfgls_sc_lag) DF-GLS lag selected by Min SC

r(dfgls_maic_lag) DF-GLS lag selected by Min MAIC

r(dfgls_ers_stat) DF-GLS stat at ERS lag

r(dfgls_sc_stat) DF-GLS stat at SC lag

r(dfgls_maic_stat) DF-GLS stat at MAIC lag

r(T) sample size

r(Ncommon) common sample size for DF-GLS

r(lags) max lag used in search

r(n_tau_reject_5) # of ADF/DF-GLS/PP rejecting H0 at 5%

r(kpss_reject_5) 1 if KPSS rejects H0 at 5%, else 0

Macros

r(model) "Constant" or "Constant + Trend"

r(verdict) two-sentence conclusion text

References

Andrews, D. W. K. 1991. Heteroskedasticity and autocorrelation consistent
covariance matrix estimation. Econometrica 59: 817-858.

Elliott, G., T. J. Rothenberg, and J. H. Stock. 1996. Efficient tests for
an autoregressive unit root. Econometrica 64: 813-836.

Hall, A. 1994. Testing for a unit root in time series with pretest
data-based model selection. Journal of Business and Economic
Statistics 12: 461-470.

Kwiatkowski, D., P. C. B. Phillips, P. Schmidt, and Y. Shin. 1992.
Testing the null hypothesis of stationarity against the alternative of a
unit root. Journal of Econometrics 54: 159-178.

Levendis, J. D. 2018. Time Series Econometrics: Learning Through
Replication. 2nd ed. Springer.

Ng, S., and P. Perron. 1995. Unit root tests in ARMA models with
data-dependent methods for the selection of the truncation lag.
Journal of the American Statistical Association 90: 268-281.

Ng, S., and P. Perron. 2001. Lag length selection and the construction
of unit root tests with good size and power. Econometrica 69:
1519-1554.

Schwert, G. W. 1989. Tests for unit roots: A Monte Carlo investigation.
Journal of Business and Economic Statistics 7: 147-159.

Author

Y. Baris Altayligil

Istanbul University, Department of Economics

ybaris@istanbul.edu.tr

Please report bugs and suggestions by email. Source and updates are also
available at the author's repository (see SSC package description).

Also see

Online: dfuller, dfgls, pperron, kpss (if
installed via ssc install kpss)