*! version 2.0.0 14mar2026

Title

dptest -- Multiple unit root and cointegration tests for I(2) processes

Syntax

Unit root testing:

dptest
varname
[if] [in]
[, options]

Cointegration testing:

dptest
depvar indepvars
[if] [in]
, test(coint) i2vars(varlist) [options]

Main
test(string) test to run: dp, hf, hz, coint, or all (default)

maxdiff(#) maximum differencing order for DP test; default is 3

maxlag(#) maximum AR lag augmentation; default uses Schwert rule

det(string) deterministic terms: none, const (default), trend, qtrend

level(#) significance level: 1, 5 (default), or 10

bandwidth(#) Newey-West bandwidth for Z(F*); default uses Schwert rule

i2vars(varlist) I(2) regressors for cointegration test

graph produce diagnostic graphs (line plots + ACF)

notable suppress output tables

crit(string) lag selection criterion: bic (default) or aic

The data must be tsset before using dptest.

Description

dptest implements four complementary tests for determining the order of
integration in time series and for testing cointegration when both I(1) and I(2)
variables are present:

1. Dickey-Pantula (1987) sequential t* procedure for multiple unit roots

2. Hasza-Fuller (1979) joint F test (Phi statistics) for double unit roots

3. Haldrup (1994 JBES) semiparametric Z(F*) test for double unit roots

4. Haldrup (1994 JoE) residual-based cointegration ADF test with I(1) and I(2) variables

Methods 1-3 are unit root tests that determine whether a series is I(0), I(1),
or I(2). Method 4 is a cointegration test that determines whether variables of
mixed integration orders share a long-run equilibrium.

Why is this package needed? Standard unit root tests (dfuller, pperron,
dfgls) only distinguish between I(0) and I(1). If a series is actually I(2),
applying dfuller to its first difference may incorrectly conclude it is
stationary, leading to spurious regression problems. dptest tests specifically
for multiple unit roots by testing from the highest order downward, or by
jointly testing for two unit roots. This is essential in macroeconomic and financial
applications where price levels, money supply, or nominal GDP may be I(2).

Options

Main

test(string) specifies which test to run.

dp -- Dickey-Pantula sequential t* test. Tests multiple unit roots by
working from the highest order downward. Best when you suspect up to 2 or 3 unit
roots and want a definitive integration order.

hf -- Hasza-Fuller joint F test. Tests the null of exactly two unit
roots against at most one. A parametric approach that assumes iid errors.

hz -- Haldrup semiparametric Z(F*) test. Same null as hf, but
robust to serial correlation and heteroskedasticity via Newey-West correction.
Preferred when errors may be autocorrelated.

coint -- Haldrup cointegration ADF test. Tests whether variables of
mixed integration orders (some I(1), some I(2)) cointegrate. Requires
i2vars().

all -- (default) Runs the three unit root tests (dp, hf, hz)
together, providing a comprehensive assessment. Does not run the cointegration
test.

maxdiff(#) sets the maximum differencing order for the Dickey-Pantula test.
Default is 3, which tests for up to I(3). In most applications, maxdiff(2)
is sufficient. Setting maxdiff(3) is appropriate when you suspect the series
may need triple differencing (rare, but possible in nominal price series).

maxlag(#) sets the maximum number of augmenting lags. If not specified,
the default is computed using the Schwert (1989) rule: int(12*(N/100)^0.25).
Lags are selected via BIC minimization over {0, 1, ..., maxlag}. Higher
values provide more insurance against serial correlation but reduce degrees
of freedom.

det(string) specifies deterministic terms included in test regressions.

none -- No constant or trend. Appropriate only when the series has
no drift and no trend under the alternative.

const -- (default) Intercept only. Appropriate for most economic time
series that may have a nonzero mean under the alternative.

trend -- Intercept plus linear trend. Use when the series exhibits a
clear linear trend under the alternative hypothesis.

qtrend -- Intercept plus quadratic trend. Use when the series appears
to have a nonlinear (quadratic) trend. Critical values from Haldrup (1994 JBES)
Tables 3-4 are used. This is rare in practice but applicable to some demographic
or cumulative series.

level(#) specifies the significance level for hypothesis testing. Allowed
values are 1, 5 (default), or 10. Critical values are adjusted
accordingly. Use 1% for conservative testing (lower risk of false rejection)
or 10% for more liberal testing (higher power).

bandwidth(#) sets the bandwidth for the Newey-West long-run variance
estimator used in the Haldrup Z(F*) test. Default uses the Schwert (1989) rule:
int(4*(N/100)^0.25). The Bartlett kernel is always used. Higher bandwidth allows
more autocorrelation lags in the variance estimate.

i2vars(varlist) specifies which independent variables are I(2). Required
for test(coint). Variables in indepvars not listed in i2vars()
are treated as I(1). The count of I(1) variables (m1) and I(2) variables (m2)
determines which critical value table is used. Tables cover m1 = {0,...,4} and
m2 = {1,2}.

graph produces two sets of diagnostic graphs: (1) line plots of the
series in levels, first differences, and second differences; (2) autocorrelation
function (ACF) plots for each transformation. Visual inspection of these plots
helps confirm the test results. The level series of an I(2) process will show
a smooth, trending path; its first difference will look like a random walk;
and only its second difference will appear stationary.

notable suppresses all output tables. Results are still stored in r().
Useful for Monte Carlo simulations or batch processing.

crit(string) specifies the information criterion for lag selection:
bic (default) or aic. BIC tends to select more parsimonious models;
AIC may include more lags.

Methods and Formulas

Method 1: Dickey-Pantula (1987) Sequential t*

When to use: When you want to determine the exact integration order of a
series (I(0), I(1), I(2), or I(3)). This is the most general of the three unit
root tests.

Why it works: Dickey and Pantula (1987) show that testing for unit roots
must proceed from the highest order downward. Starting with the standard ADF
test for one unit root when the series is I(2) leads to size distortions and
incorrect conclusions. Their sequential procedure avoids this by first testing
the most restrictive null hypothesis.

Model specification: Suppose maxdiff = p. The LHS of the test regression
is the p-th difference: Delta^p Y_t. At step d (testing H0: d unit roots), the
key regressor is Delta^ Y_, with control variables
Delta^d Y_, ..., Delta^

Y_. The t-ratio on the key regressor
is compared to Fuller (1976) tau critical values.

Decision rule: If t* < CV, reject H0 (the series has fewer than d unit
roots) and move to the next step. If t* >= CV, do not reject, and the series
is declared I(d). The procedure stops at the first non-rejection.

Augmentation: Lags of the LHS variable are added and selected by BIC to
account for serial correlation in the errors.

Method 2: Hasza-Fuller (1979) Joint F Test

When to use: When you specifically want to test I(2) vs. I(1) or I(0).
This test has greater power than the sequential t* when the true DGP is I(2),
because it tests both unit root restrictions jointly.

Model specification: The series is reparameterized as:

Delta^2 Y_t = (alpha - 1)Y_ + (beta - 1)Delta Y_ + sum_j delta_j Delta^2 Y_ + e_t

The null hypothesis H0: alpha = beta = 1 (two unit roots) is tested using an
F statistic. Five Phi statistics are available:

Phi_1(2) -- No deterministics. Tests alpha = beta = 1 only.

Phi_2(2) -- With intercept. Tests alpha = beta = 1 only.

Phi_3(2) -- With intercept + trend. Tests alpha = beta = 1 only.

Phi_QT -- With intercept + quadratic trend (Haldrup JBES extension).

Decision rule: If F > CV, reject H0 (evidence against two unit roots).
Note: This is a right-tail test.

Method 3: Haldrup (1994 JBES) Semiparametric Z(F*)

When to use: When you want to test I(2) vs. I(1) but are concerned about
serial correlation or heteroskedasticity in the errors. This test is robust
where the Hasza-Fuller test may have size distortions.

Model specification: The test first detrends the series (demean, detrend,
or quadratic detrend depending on det()). Then it runs the HF regression
on the detrended series without a constant (since deterministics have already
been removed). The F statistic is then adjusted using a Newey-West long-run
variance estimate:

Z(F*) = (s^2 / sigma^2) * F_raw

where s^2 is the short-run variance (RSS/N) and sigma^2 is the Newey-West
long-run variance using a Bartlett kernel with the specified bandwidth.

Critical values: By Haldrup (1994 JBES) Theorem 2, Z(F*) has the same
asymptotic distribution as the HF F statistic, so the same critical value
tables apply. For det(qtrend), extended critical values from Haldrup JBES
Tables 3-4 are used.

Decision rule: Same as HF: reject H0 (two unit roots) if Z(F*) > CV.

Method 4: Haldrup (1994 JoE) Cointegration ADF

When to use: When your system contains variables of different integration
orders (some I(1), some I(2)) and you want to test whether they cointegrate.
Standard Engle-Granger cointegration tests assume all variables are I(1);
Haldrup extends this to mixed I(1)/I(2) systems.

Model specification: This is a two-step Engle-Granger procedure:

Step 1: Run cointegration regression: Y_t = b1*X1_t + b2*X2_t + ... + u_t
where X1 variables are I(1) and X2 variables are I(2).

Step 2: Test the residuals u_hat for a unit root using ADF with no constant
(residuals have zero mean by construction).

If the ADF t statistic on the residuals is more negative than the critical
value, reject the null of no cointegration.

Critical values: These depend on (m1, m2) = (number of I(1) regressors,
number of I(2) regressors). Tables from Haldrup (1994 JoE, Table 1) cover
m1 = {0,...,4} and m2 = {1,2} at sample sizes n = {25, 50, 100, 250, 500}.

Key distinction: Unlike standard cointegration tests, the null here is
that the residuals are I(1), not I(0). This is a left-tail test:
reject if ADF statistic < CV.

How to Interpret the Output

Reading the Header

The header shows the variable name, sample size, deterministic specification,
maximum lag order, significance level, and (for Z(F*)) the bandwidth. Verify
these match your intentions before reading the test results.

Panel A — Sequential t*

The table shows one row per step. For each step d, the H0 column shows the
null hypothesis (d unit roots), the t* column shows the test statistic, and
the Decision column shows whether H0 is rejected.

If all nulls are rejected: The series is I(0) — it is stationary.

If the first non-rejection is at d=1: The series is I(1).

If the first non-rejection is at d=2: The series is I(2).

If no null is rejected: The series is I(maxdiff), the maximum order tested.

Common pitfall: If t* values are close to the critical value boundary,
results may be sensitive to the significance level. Run with different levels
(level(1), level(5), level(10)) to check robustness.

Panel B — Joint F Test

A single F statistic is reported along with critical values at 1%, 5%, and 10%.

F > CV: Reject H0. The series does not have two unit roots. It is
at most I(1). A subsequent standard ADF test can determine if it is I(1) or I(0).

F <= CV: Cannot reject H0. Evidence is consistent with I(2).

Note: This is a right-tail test, unlike the standard ADF which is left-tail.

Panel C — Z(F*)

Same interpretation as Panel B, but the test statistic is corrected for serial
correlation. Compare Z(F*) with the same critical values as the HF F test.

The output also shows the short-run variance s^2 and the long-run variance
sigma^2. If sigma^2 >> s^2, this indicates substantial serial correlation in
the errors. In such cases, the uncorrected HF test may over-reject the null,
and Z(F*) provides a more reliable result.

When HF and Z(F*) disagree: If HF rejects but Z(F*) does not, the
rejection by HF is likely a size distortion caused by serial correlation. Trust
Z(F*) in this case.

Panel D — Cointegration ADF

Reports the ADF statistic on cointegration residuals along with critical values
that account for the number and integration order of regressors.

ADF < CV: Reject H0. Evidence of cointegration — a long-run
equilibrium relationship exists among the variables.

ADF >= CV: Cannot reject H0. No evidence of cointegration.

The critical values here are more negative than standard ADF critical values
because the residuals are generated regressors (Haldrup 1994 JoE accounts for
this).

Summary Table

When running test(all), the summary table at the bottom shows the
estimated integration order from each method side by side. Ideally, all
three methods should agree. Disagreement suggests either:

(a) the series is borderline (near-I(2) with a large but finite AR root), or

(b) the deterministic specification may be inappropriate — try different
det() options, or

(c) the sample size is too small for reliable inference.

Critical Values

Critical value tables are hardcoded from five sources:

1. Fuller (1976) Table 8.5.2: tau statistics for the DP sequential t*
test at n = {25, 50, 100, 250, 500+}. Three sets: no constant, constant,
constant + trend.

2. Hasza & Fuller (1979) Table 4.1: Phi_1(2), Phi_2(2), Phi_3(2)
at n = {25, 50, 100, 250, 500, infinity} and percentiles
{50, 80, 90, 95, 97.5, 99}.

3. Haldrup (1994 JBES) Table 3: Phi with quadratic trend at
n = {25, 50, 100, 250, 500}.

4. Haldrup (1994 JBES) Table 4: DF t-test with quadratic trend.

5. Haldrup (1994 JoE) Table 1: Cointegration ADF critical values
for m2 = {1,2} and m1 = {0,...,4} at n = {25, 50, 100, 250, 500} and
significance levels {1%, 2.5%, 5%, 10%}.

Sample size matching uses the nearest lower bracket. For example, n = 73 uses
the n = 50 critical values. This is conservative (critical values are wider for
smaller n).

Stored Results

dptest stores the following in r():

Common:

r(N) effective sample size

r(depvar) dependent variable name

r(det) deterministic specification

r(level) significance level

r(maxlag) maximum lag order

r(bandwidth) Newey-West bandwidth

Dickey-Pantula (test dp):

r(dp_d) estimated integration order

r(dp_tstar_1) t* for step 1

r(dp_tstar_2) t* for step 2

r(dp_tstar_3) t* for step 3 (if maxdiff >= 3)

Hasza-Fuller (test hf):

r(hf_F) F statistic

r(hf_d) estimated order (2 = I(2), 1 = at most I(1))

r(hf_cv1) critical value at 1%

r(hf_cv5) critical value at 5%

r(hf_cv10) critical value at 10%

r(hf_lags) selected augmentation lags

Haldrup Z(F*) (test hz):

r(hz_ZF) Z(F*) statistic

r(hz_d) estimated order (2 = I(2), 1 = at most I(1))

r(hz_sigma2) Newey-West long-run variance

r(hz_s2) short-run variance

r(hz_lambda) half-variance correction

Cointegration (test coint):

r(coint_adf) ADF statistic on residuals

r(coint_cv) critical value at specified level

r(coint_cv1) critical value at 1%

r(coint_cv5) critical value at 5%

r(coint_cv10) critical value at 10%

r(coint_reject) 1 if H0 rejected, 0 otherwise

r(coint_m1) number of I(1) regressors

r(coint_m2) number of I(2) regressors

r(coint_lags) selected augmentation lags

Examples

Example 1: Basic unit root testing

Setup:

. webuse air2

. tsset t

Run all three unit root tests with default settings (constant, 5%):

. dptest air

Interpretation: If the DP test concludes I(1), HF fails to reject, and
Z(F*) fails to reject, then the series likely has two unit roots (I(2)).
If all three methods agree on I(1), the series needs only first differencing.

Example 2: Choosing deterministic terms

If the series shows a clear upward trend, include a trend:

. dptest air, test(dp) det(trend)

If you suspect the trend is nonlinear (e.g., accelerating growth):

. dptest air, test(hz) det(qtrend)

For series centered around zero with no drift:

. dptest air, test(hf) det(none)

Example 3: Simulated I(2) process

Generate and test an I(2) process:

. clear

. set obs 200

. set seed 12345

. gen t = _n

. tsset t

. gen eps = rnormal()

. gen dy = sum(eps)

. gen y = sum(dy)

. dptest y

Expected: DP should find I(2), HF and Z(F*) should not reject H0 (both
indicating two unit roots). The graph option helps confirm visually:

. dptest y, graph

Example 4: Simulated I(1) process

. gen y_rw = sum(rnormal())

. dptest y_rw

Expected: DP should find I(1). HF and Z(F*) should reject H0 of two unit
roots, concluding at most I(1).

Example 5: Simulated I(0) process

. gen y_stat = rnormal()

. dptest y_stat

Expected: DP should find I(0). HF and Z(F*) should reject H0 (the series
does not have two unit roots).

Example 6: Significance level sensitivity

Check how conclusions change across significance levels:

. dptest air, level(1)

. dptest air, level(5)

. dptest air, level(10)

If results change between 5% and 10%, the evidence is borderline. Use
the graph option and the ACF to make a judgment call.

Example 7: Cointegration with I(1) and I(2) variables

Generate a cointegrated system: y = x2 + 0.5*x1 + v, where x1 ~ I(1),
x2 ~ I(2), and v ~ I(1):

. gen e1 = rnormal()

. gen e2 = rnormal()

. gen x1 = sum(e1)

. gen dx2 = sum(e2)

. gen x2 = sum(dx2)

. gen v = sum(rnormal())

. gen y_c = x2 + 0.5*x1 + v

. dptest y_c x1 x2, test(coint) i2vars(x2)

Here m1 = 1 (x1 is I(1)) and m2 = 1 (x2 is I(2)). If the ADF statistic
is sufficiently negative, we reject H0 of no cointegration and conclude that
y, x1, and x2 share a long-run equilibrium.

Example 8: Multiple I(2) regressors

. gen dx3 = sum(rnormal())

. gen x3 = sum(dx3)

. gen y_c2 = x2 + x3 + 0.3*x1 + v

. dptest y_c2 x1 x2 x3, test(coint) i2vars(x2 x3)

Here m1 = 1, m2 = 2. Critical values are more negative (harder to reject)
because more regressors increase the chance of spurious cointegration.

Example 9: Using stored results in programs

Suppress output and access results programmatically:

. dptest air, notable

. display "DP order: " r(dp_d)

. display "HF F stat: " r(hf_F)

. display "Z(F*): " r(hz_ZF)

Example 10: Monte Carlo size simulation

Evaluate the size of the HF test under H0:

. local reps 1000

. local rejects 0

. forval i = 1/`reps' {

. qui drop _all

. qui set obs 100

. qui gen t = _n

. qui tsset t

. qui gen y = sum(sum(rnormal()))

. qui dptest y, test(hf) notable

. if r(hf_d) == 1 local rejects = `rejects' + 1

. }

. display "Rejection rate: " `rejects'/`reps'

Under H0 (true I(2)), the rejection rate should be close to 5% at the
5% significance level.

Diagnostics and Troubleshooting

Sample size too small: dptest requires at least 25 observations.
With very small samples (n < 50), critical values may be imprecise. Results
should be interpreted with caution.

Missing values: The command uses marksample and drops missing
observations before testing. Be aware that differencing and lagging reduce
the effective sample size by maxdiff + selected_lags observations.

Structural breaks: None of these tests account for structural breaks.
If breaks are present, the unit root tests may incorrectly fail to reject
(the series appears more persistent). Consider using break-robust alternatives
or testing subsamples.

Seasonal data: For seasonal data, consider seasonal differencing first
or including seasonal dummies (not yet supported). The standard tests assume
non-seasonal integration.

References

Dickey, D.A. and S.G. Pantula. 1987.
Determining the order of differencing in autoregressive processes.
Journal of Business & Economic Statistics 5(4): 455-461.

Fuller, W.A. 1976.
Introduction to Statistical Time Series. New York: Wiley.

Haldrup, N. 1994.
Semiparametric tests for double unit roots.
Journal of Business & Economic Statistics 12(1): 109-122.

Haldrup, N. 1994.
The asymptotics of single-equation cointegration regressions with
I(1) and I(2) variables.
Journal of Econometrics 63(1): 153-181.

Hasza, D.P. and W.A. Fuller. 1979.
Estimation for autoregressive processes with unit roots.
The Annals of Statistics 7(5): 1106-1120.

Newey, W.K. and K.D. West. 1987.
A simple, positive semi-definite, heteroskedasticity and autocorrelation
consistent covariance matrix.
Econometrica 55(3): 703-708.

Phillips, P.C.B. 1987.
Time series regression with a unit root.
Econometrica 55(2): 277-301.

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

Author

Dr. Merwan Roudane

Email: merwanroudane920@gmail.com

Please cite as:

Roudane, M. 2026. dptest: Multiple unit root and cointegration tests
for I(2) processes. Stata package version 2.0.0.