*! version 1.0.0 08jul2026

Title

xthkrcoint -- Hadri-Kurozumi-Rao panel cointegration test with the
null of cointegration, robust to cross-section dependence, for fixed N and
large T

Syntax

xthkrcoint
depvar indepvars
[if] [in]
[, options]

Model
trend include a linear time trend in the deterministic part
(default: constant only)

ols also report the OLS-residual autocovariance statistic as a
comparator

Tuning parameters
k(#) lag order K for the autocovariance; default
k(floor((a*T)^delta))

a(#) multiplier a in the default rule for K; default
a(2)

delta(#) exponent delta in the default rule for K;
default delta(0.5)

m(#) number of DOLS leads and lags M; default
m(floor(2*(T/100)^(1/5)))

j(#) Bartlett bandwidth J for the long-run variance; default
j(floor(12*(T/100)^(1/4)))

Reporting and graphs
noindividual suppress the per-unit results table

graph draw the publication diagnostics dashboard (unit forest
plot + K-sensitivity curve)

ksens(numlist) values of K for the sensitivity curve
(integers > 0)

name(string) stub for the stored graph name(s); default
name(xthkr)

scheme(string) graph scheme; default scheme(s2color)

title(string) replace the header title

The data must be declared as panel data with xtset (fixed N, large
T) or, for a single time series, with tsset (in which case the test
reduces to the univariate cointegration test of the same paper). The panel must
be strongly balanced with no gaps.

depvar is the dependent variable y; indepvars are the I(1)
regressors x. depvar and indepvars are assumed I(1); under
the null they are cointegrated.

Description

xthkrcoint implements the panel cointegration tests of
Hadri, Kurozumi and Rao (2015, Econometrics Journal).
The distinctive features of the test are:

1. The null hypothesis is cointegration for every unit;
the alternative is that at least one unit is not cointegrated. This is the
natural null when the researcher wishes to establish a long-run relationship,
and it complements the more common no-cointegration-null tests
(xtcointtest).

2. The asymptotics hold with N fixed and T large,
so the test suits typical macroeconomic and financial panels where N is
small relative to T. No estimation of the number of common factors is
required.

3. Arbitrary cross-section dependence (weak or strong,
including common factors and cross-unit cointegration) is mopped up
nonparametrically through the long-run variance of the pooled
autocovariances, in the spirit of Driscoll-Kraay. The pooled statistic is
therefore asymptotically standard normal and no bootstrap critical values
are needed.

4. Serial correlation is handled by dynamic OLS (DOLS) — the
cointegrating regression is augmented with leads and lags of Dx — and
a bias correction removes the finite-sample negative bias of the
autocovariance statistic (which otherwise makes the test conservative).

The command reports the pooled statistic SK (uncorrected) and
S~K (bias-corrected), each with a one-sided (upper-tail)
p-value, a decision at the 5% level, and a per-unit breakdown showing which
cross-sections drive a rejection. With graph it draws a two-panel
diagnostics dashboard.

Options

Model

trend adds a linear time trend to the deterministic component of the
cointegrating regression, so Xt = [1, t, xt]. Without
it the deterministic part is a constant only, Xt = [1,
xt]. The bias correction uses pc = 1 (constant) or
pc = 2 (constant and trend).

ols additionally computes the autocovariance statistic from static OLS
residuals, SKols, which is also asymptotically N(0,1) under the
null and is reported for comparison. The DOLS-based S~K is the
recommended statistic.

Tuning parameters

k(#) sets the lag order K of the autocovariance
aK,t = ðtðt-K. K must diverge
with T (Assumption 3, T1/4 <= K < T). The
default is K = floor((a*T)delta) with a(2) and
delta(0.5), i.e. K = floor((2T)1/2), the value recommended
in the paper. See Tuning parameters.

a(#) and delta(#) control the default rule K =
floor((a*T)delta). They are ignored if k() is given.

m(#) sets the number M of DOLS leads and lags of Dx. It
must satisfy Assumption 2 (M4/T ® 0). The default is
M = floor(2*(T/100)1/5). The effective sample after trimming is
T - 2M - 1.

j(#) sets the Bartlett-kernel bandwidth J used for every long-run
variance in the procedure. It must be o(T1/2). The default is
J = floor(12*(T/100)1/4).

Reporting and graphs

noindividual suppresses the per-unit table (shown by default when
N > 1).

graph draws the diagnostics dashboard: (a) a forest / caterpillar plot of
the unit-specific bias-corrected statistics with the 5% and 1% one-sided
critical values, units beyond the line shown in a contrasting colour; and (b)
the pooled S~K and SK as functions of K with the
critical values marked, so the robustness of the conclusion to the lag order can
be judged at a glance.

ksens(numlist) supplies the grid of K values for the sensitivity
curve. If omitted while graph is on, a default grid of about 16 values
spanning (0.5T)1/2 to (3T)1/2 is used. The grid is also
returned in r(ksens).

name(string), scheme(string) and title(string) control the
stored graph name stub, the graph scheme and the header title, respectively.

Method

For unit i the cointegrating regression is estimated by DOLS,

yi,t = bi'Xi,t +
j=-MM pi,j'Dxi,t-j +
ði,t*,

and the residuals are standardized, ð~i,t =
ð^i,t/ð^i. The pooled cross-product is
aK,t = i=1N
ð~i,tð~i,t-K and

SK = C~K / ð^a,
S~K = (C~K + b~) / ð^a,

where C~K = (T-K)-1/2 t=K+1T
aK,t, ð^a2 is the Bartlett long-run variance of
aK,t (this is what absorbs the cross-section dependence), and the
bias term is b~ = (T-K)-1/2 i
(pi,c+pi,x) ð^i2 /
ð^i2. Under H0 both statistics converge to N(0,1) and
diverge to +¥ under H1, so the test is one-sided (upper tail): large
positive values are evidence against panel cointegration.

Tuning parameters — practical guidance

The finite-sample behaviour depends mostly on K (paper, Section 5):

- Smaller K gives more power but larger K gives a
better-controlled size under strong serial correlation. The uncorrected
SK is conservative; the bias-corrected S~K is close to
nominal and is the one to report.

- The authors recommend K = floor((2T)1/2) or
floor((3T)1/2) — i.e. a(2) (the default) or a(3). Avoid very
small (K=T1/4) or very large (K=T3/4) exponents
when errors are strongly serially correlated.

- Always inspect the graph K-sensitivity curve and the
per-unit table before concluding.

Stored results

xthkrcoint is an r-class command. It stores:

Scalars

r(S) pooled uncorrected statistic SK

r(p) one-sided p-value for r(S)

r(Sbc) pooled bias-corrected statistic S~K

r(pbc) one-sided p-value for r(Sbc)

r(Sols) pooled OLS-residual statistic (with ols)

r(pols) one-sided p-value for r(Sols)

r(Cbar) pooled autocovariance C~K

r(omega_a) Bartlett long-run variance ð^a2

r(bias) bias term b~

r(N) number of panels

r(T) time periods per panel

r(Teff) effective obs after DOLS trimming (T-2M-1)

r(na) T-K used in C~K

r(K) lag order used

r(M) DOLS leads/lags used

r(J) Bartlett bandwidth used

Macros

r(cmd) xthkrcoint

r(depvar) name of depvar

r(regr) names of the I(1) regressors

r(det) deterministic specification

r(null) panel cointegration

Matrices

r(panel) 1×20 vector of all pooled quantities

r(indiv) N×9 per-unit results (unit, T_i, K, S_K, S_bc,
p_S, p_bc, S_ols, p_ols)

r(ksens) G×5 sensitivity grid (K, S_K, S_bc, p_S,
p_bc), when computed

Examples

Setup a balanced panel:

. webuse grunfeld, clear

. xtset company year

Baseline test (constant, default K, M, J):

. xthkrcoint invest mvalue kstock

Trend case, with the OLS comparator and the diagnostics dashboard:

. xthkrcoint invest mvalue kstock, trend ols graph

Robustness across lag orders, saving the sensitivity grid:

. xthkrcoint invest mvalue kstock, ksens(5 8 11 14 17 20)

. matrix list r(ksens)

A single time series (reduces to the univariate cointegration test):

. tsset year

. xthkrcoint y x1 x2

References

Hadri, K., E. Kurozumi, and Y. Rao. 2015. Novel panel cointegration tests
emending for cross-section dependence with N fixed. Econometrics Journal
18(3): 363-411. doi:10.1111/ectj.12054.

Harris, D., B. McCabe, and S. Leybourne. 2003. Some limit theory for
autocovariances whose order depends on sample size. Econometric Theory
19(5): 829-864.

Harris, D., S. Leybourne, and B. McCabe. 2005. Panel stationarity tests for
purchasing power parity with cross-sectional dependence. Journal of Business
and Economic Statistics 23(4): 395-409.

Saikkonen, P. 1991. Asymptotically efficient estimation of cointegration
regressions. Econometric Theory 7(1): 1-21.

Driscoll, J. C., and A. C. Kraay. 1998. Consistent covariance matrix estimation
with spatially dependent panel data. Review of Economics and Statistics
80(4): 549-560.

Author

Dr Merwan Roudane

merwanroudane920@gmail.com

github.com/merwanroudane