*! xtmunitroot version 1.0.0 27jun2026

Title

xtmunitroot -- Fixed-T panel unit root tests with missing values

Syntax

xtmunitroot
varname
[if] [in]
[,
options]

Model
model(spec) deterministic specification: intercept (default),
trend, break or breaktrend

break(#) break point for break/breaktrend: a calendar
date, a fraction in (0,1), or unknown

Missing values
method(m) zeroout (default), previous, linear or
all

Unknown-break bootstrap
breps(#) bootstrap replications for break(unknown); default 399

trim(#) end trimming fraction for the break-date search; default 0.15

seed(#) RNG seed for the bootstrap

Reporting
level(#) significance level for the decision; default level(95)

graph draw the missing-value map and method-comparison dashboard

name(str) stub for the graph names; default xtmunitroot

The data must be xtset.

Description

xtmunitroot implements the fixed-T panel unit root tests of
Harris and Tzavalis (1999) and
Karavias and Tzavalis (2014), extended to
unbalanced panels with missing values exactly as in
Karavias, Tzavalis and Zhang (2022). These tests are
designed for panels with a large number of cross-section units N and a
small, fixed number of time periods T.

The model is an AR(1) panel, u(i,t) = rho*u(i,t-1) + e(i,t), and the test is

H0: rho = 1 (every panel has a unit root) vs H1: rho < 1 (stationary).

The pooled fixed-effects estimator of rho is inconsistent for fixed T (the
Hurwicz-Nickell bias), so it is bias-corrected and the resulting statistic is
asymptotically standard normal as N -> infinity:

z = (rho_hat - bias - 1) / sqrt(V/N) -> N(0,1) under H0.

Because rho_hat is biased downward, the bias is negative; under stationarity
z is large and negative, so the unit-root null is rejected in the lower tail.

Missing values make the panel unbalanced and contaminate the bias correction,
which depends on the location of the gaps. xtmunitroot builds, for
every unit, the reshuffling matrix D(i) of
Karavias, Tzavalis and Zhang (2022) and applies the
unbalanced bias and variance corrections (their Propositions 1-2). The four
deterministic specifications correspond to models (1)-(4) of that paper:

intercept individual (incidental) intercepts

trend individual intercepts and individual linear trends

break individual intercepts with a common structural break at break()

breaktrend intercepts and trends with a common structural break at break()

Options

model(spec) sets the deterministic component. Abbreviations
i, t, b, bt are accepted.

break(#) is required for break and breaktrend. A value
in (0,1) is read as a break fraction of the time grid; any other value is
read as a calendar date on the time variable. break(unknown) searches
all admissible break dates: the test statistic is the minimum (inf) of the t over
the candidate dates, and the p-value and critical values come from a cross-section
residual bootstrap that imposes the unit-root null (Karavias & Tzavalis 2019).
Only one method() may be used with break(unknown).

breps(#), trim(#), seed(#) control the unknown-break
bootstrap: number of replications, the fraction trimmed from each end of the
break-date search, and the RNG seed for reproducibility.

method(m) chooses how missing values are handled:

zeroout (default, recommended) -- "closing the gaps". Every
equation that involves a missing value is dropped, and the exact unbalanced
bias/variance correction is applied. This is the method
Karavias, Tzavalis and Zhang (2022) prove delivers
the greatest power, for all deterministic specifications.

previous -- the missing value is replaced by the last observed value
(carry-forward), then the test is computed on the completed series.

linear -- the missing value is replaced by linear interpolation of
the two adjacent observed values, then the test is computed on the completed
series.

all -- reports all three in one comparison table (and dashboard).

level(#) significance level used only for the printed decision.

graph produces a two-panel dashboard: (a) a missing-value map of the
panel and (b) a bar chart of the z-statistic by method with the 5% critical line.
If the user-contributed heatplot is installed it is used for the map;
otherwise a scatter fallback is drawn.

A note on the three methods

The zeroout method is the full, exact implementation of
Karavias, Tzavalis and Zhang (2022): the diagonal
D(i) drops the two equations contaminated by each gap and the bias correction is
computed from D(i). The previous and linear methods are implemented as
impute-then-test: the series is completed first and the standard fixed-T
correction is then applied. They are provided so the user can reproduce, on real
data, the power ranking reported in the paper -- namely that zeroing-out
dominates and substituting the previous value is generally worst. Report
zeroout as the primary result.

Related command

xtmunitroot assumes i.i.d. errors and is built for missing values
(unbalanced panels). When the errors are instead serially correlated or
heteroscedastic and the panel is balanced, use its companion
xtgunitroot (the generalized DME test of Karavias & Tzavalis 2019), which
shares the same break(unknown) inf-t bootstrap interface.

Stored results

xtmunitroot stores the following in r():

Scalars

r(rho) bias-corrected rho (single-method runs)

r(bias) estimated bias correction (single-method runs)

r(z) test statistic (single-method runs)

r(p) one-sided p-value (single-method runs)

r(N) number of panels

r(T) number of equations on the time grid

r(N_used) panels contributing to the statistic

r(N_drop) panels dropped (too few usable equations)

r(n_miss) missing cells on the rectangular grid

r(kbreak) break equation index (break models)

Macros

r(cmd) xtmunitroot

r(depvar) series tested

r(ivar) / r(tvar) panel and time variables

r(model) / r(method) chosen specification / method

Matrices

r(results) 3 x 8 matrix, one row per method (zeroout, previous,
linear): rho, bias, z, p, N_used, N_drop, n_miss, T_eq

Examples

Setup a panel and introduce some gaps:

. webuse grunfeld, clear

. xtset company year

. replace invest = . if mod(_n,17)==0

Default test (zeroing-out, individual intercepts):

. xtmunitroot invest

Individual trends:

. xtmunitroot invest, model(trend)

Structural break at the middle of the sample, with the dashboard:

. xtmunitroot invest, model(break) break(0.5) graph

Compare all three missing-value methods:

. xtmunitroot invest, method(all) graph

Structural break at an unknown date (inf-t with bootstrap p-value):

. xtmunitroot invest, model(break) break(unknown) breps(499) seed(42) graph

References

Karavias, Y., E. Tzavalis, and H. Zhang. 2022. Missing values in panel
data unit root tests. Econometrics 10(1): 12.
doi:10.3390/econometrics10010012.

Harris, R. D. F., and E. Tzavalis. 1999. Inference for unit roots in
dynamic panels where the time dimension is fixed. Journal of Econometrics
91: 201-226.
doi:10.1016/S0304-4076(98)00076-1.

Karavias, Y., and E. Tzavalis. 2014. Testing for unit roots in short
panels allowing for a structural break. Computational Statistics & Data
Analysis 76: 391-407.
doi:10.1016/j.csda.2012.10.014.

Karavias, Y., and E. Tzavalis. 2019. Generalized fixed-T panel unit root
tests. Scandinavian Journal of Statistics 46(4): 1227-1251.
doi:10.1111/sjos.12392.

Author

Merwan Roudane

merwanroudane920@gmail.com

github.com/merwanroudane