Title

xtpanic -- PANIC panel unit root test (Bai & Ng 2004): tests the
idiosyncratic component after extracting common factors by principal components

Syntax

xtpanic varname [if] [in] [, options]

The data must be xtset as a strongly balanced panel.

model(string) deterministic terms: constant (default) or
trend

kmax(#) maximum number of common factors (default 5)

icfactor(#) factor-number criterion: 1=PCp, 2=ICp (default), 3=AIC/BIC

pmax(#) maximum lags for the idiosyncratic ADF (default 3)

iclag(#) ADF lag criterion: 1=AIC, 2=SIC, 3=t-sig (default)

Description

xtpanic implements the PANIC procedure of Bai and Ng (2004) — Panel
Analysis of Nonstationarity in Idiosyncratic and Common components. Rather than
testing the observed series directly, PANIC first extracts the common
factors by principal components on the differenced data, and then tests the
idiosyncratic component for a unit root. This makes the panel test robust to
strong cross-sectional dependence of an unknown form.

The steps are: (i) difference the data (and, for the trend model, demean the
differences); (ii) estimate the number of common factors by the Bai-Ng (2002)
information criterion; (iii) extract the factors and loadings by principal
components; (iv) cumulate the idiosyncratic residuals; (v) run an augmented
Dickey-Fuller regression without deterministic terms on each unit's
idiosyncratic component; (vi) pool the p-values into the Fisher-type panel
statistics P and Pm.

xtpanic is part of the xtflexur library and shares its
common-factor engine with the other factor-based panel tests in that library.
See help xtpanic methods for the formulas.

Options

model(string) chooses the deterministic specification of the levels:
constant (the differenced data are used as is) or trend (the
differences are demeaned, removing the drift). Both use the Dickey-Fuller
no-constant distribution for the idiosyncratic ADF, as in Bai and Ng (2004).

kmax(#) is the maximum number of common factors considered by the
information criterion (default 5).

icfactor(#) selects the Bai-Ng (2002) criterion used to estimate the
number of factors: 1=PCp, 2=ICp (default), 3=AIC/BIC. The number
of factors reported is the one chosen by the second column of the criterion (ICp2).

pmax(#) and iclag(#) govern the per-unit ADF lag length:
maximum lags (default 3) and the selection rule (1=AIC, 2=SIC,
3=general-to-specific t-significance at 10%, the default).

Examples

Panel unit root test with a constant:

. xtset country year

. xtpanic lgdp

Trend model, up to 5 factors chosen by ICp, ADF lags by t-significance:

. xtpanic lgdp, model(trend) kmax(5) icfactor(2) pmax(3) iclag(3)

Stored results

xtpanic is rclass and stores:

Scalars

r(P), r(P_p) Fisher chi-square panel statistic and p-value

r(Pm), r(Pm_p) standardized (normal) panel statistic and p-value

r(nf) estimated number of common factors

r(N), r(T) panel and time dimensions

Matrices

r(units) per-unit id, ADF statistic, p-value, lags

Macros

r(cmd) xtpanic

r(model) deterministic model

Interpreting the output

The null hypothesis is that the idiosyncratic component contains a unit root
(the series is non-stationary once common factors are removed). The pooled tests
P (Fisher chi-square, 2N degrees of freedom) and Pm (standardized to
N(0,1)) reject for large values / small p-values. Rejection means the
idiosyncratic components are stationary.

Because PANIC separates common from idiosyncratic dynamics, a rejection here is
not contaminated by cross-sectional dependence: the common factors, which
carry most of the co-movement, are removed before testing. The per-unit table
shows which series drive the panel result.

Remarks

o Requires a strongly balanced panel (no gaps). Difference-based factor
extraction needs a common time span across units.

o The idiosyncratic ADF is run without deterministic terms in both models;
the deterministics of the levels are handled by the differencing/demeaning and by
the common factors (Bai and Ng 2004). p-values use the finite-sample
Dickey-Fuller (no constant) response surface.

o The command tests only the idiosyncratic component. Tests of the common
factors themselves (MQ statistics) can be added; see the methods page.

References

Bai, J., and S. Ng. 2002. Determining the number of factors in approximate
factor models. Econometrica 70: 191-221.

Bai, J., and S. Ng. 2004. A PANIC attack on unit roots and cointegration.
Econometrica 72: 1127-1177.

Nazlioglu, S., et al. 2023. Smooth structural changes and common factors in
nonstationary panel data: an analysis of healthcare expenditures. Econometric
Reviews 42(1): 78-97.

Author

Dr Merwan Roudane

merwanroudane920@gmail.com

github.com/merwanroudane

Faithful Stata port of the GAUSS routine BNG_PANIC (TSPDLIB) by
S. Nazlioglu; validated byte-for-byte against Table 3 of Nazlioglu et al. (2023).
Part of the xtflexur library.