*! version 1.0.1 05apr2026

Title

xtpvarcoint -- Panel VAR Modeling with Cointegration,
Structural Breaks, and Cross-Sectional Dependence

Syntax

General syntax:

xtpvarcoint subcommand [varlist] [, options]

Subcommands:

subcommand

pcoint panel cointegration rank tests (Johansen, Breitung, SL, CAIN)

coint individual (time-series) cointegration rank tests

pvar panel VAR estimation via Mean Group

pvec panel VECM estimation via Pooled/Mean Group

vecm individual VECM estimation (single unit)

pid panel SVAR identification

speci specification tools (factor number, lag order)

irf impulse response functions (after pvar/pvec/vecm)

fevd forecast error variance decomposition (after pvar/pvec/vecm)

sboot bootstrap inference for IRF with confidence intervals

plot publication-quality graphs (IRF, FEVD, eigenvalues)

Subcommand Syntax

1. Panel Cointegration Tests (pcoint)

xtpvarcoint pcoint varlist ,
method(JO|BR|SL|CAIN)
lags(numlist)
[type(string)
nfactors(#)
niter(#)
tbreak(numlist)
tshift(numlist)
nseason(#)]

2. Individual Cointegration Test (coint)

xtpvarcoint coint varlist ,
lags(#)
[type(string)
method(JO|SL)
tbreak(numlist)
tshift(numlist)
nseason(#)]

3. Panel VAR (pvar)

xtpvarcoint pvar varlist ,
lags(numlist)
[type(const|trend|both|none)
nfactors(#)
niter(#)
tshift(numlist)
exog(varlist)]

4. Panel VECM (pvec)

xtpvarcoint pvec varlist ,
lags(numlist)
rank(#)
[type(Case1|Case2|Case3|Case4|Case5)
pool(numlist)
nfactors(#)
niter(#)
tbreak(numlist)
tshift(numlist)]

5. Individual VECM (vecm)

xtpvarcoint vecm varlist ,
lags(#)
[rank(#)
type(Case1|Case2|Case3|Case4|Case5)
exog(varlist)
exlags(#)]

6. SVAR Identification (pid)

xtpvarcoint pid ,
[method(chol|grt|iv|dc|cvm)
combine(pool|group|indiv)
s2(string)
covu(string)
nfactors(#)
niter(#)
itermax(#)
steptol(#)
iter2(#)
pit]

7. Specification — Lag Order (speci var)

xtpvarcoint speci var varlist ,
lagset(numlist)
[breaks(#)
trim(real)
breaktype(string)
adddummy]

8. Specification — Factor Number (speci factors)

xtpvarcoint speci factors varlist ,
[kmax(#)
niter(#)
differenced
centered
scaled
nfactors(#)]

9. Impulse Response Functions (irf)

xtpvarcoint irf ,
[horizon(#)
ci(real)
boot(#)
blocksize(#)
cumulative
orthogonal]

10. Forecast Error Variance Decomposition (fevd)

xtpvarcoint fevd ,
[horizon(#)]

11. Bootstrap Inference (sboot)

xtpvarcoint sboot ,
[method(pmb|mb|mg|normality)
nboot(#)
blocksize(#)
ci(real)
horizon(#)
seed(#)]

12. Publication-Quality Plots (plot)

xtpvarcoint plot ,
[plottype(irf|fevd|eigenvalues)
variable(numlist)
shock(numlist)
saving(string)
title(string)]

Description

xtpvarcoint implements a comprehensive econometric toolkit for
vector autoregressive (VAR) modeling in heterogeneous panels. It
is a Stata port of the R package pvars and provides:

Panel cointegration rank tests based on the Johansen procedure
(Larsson et al. 2001), the Breitung (2005) two-step estimator, the
Saikkonen-Luetkepohl procedure (Arsova and Oersal 2018), and the
correlation-augmented inverse normal test robust to cross-sectional
dependence (Arsova and Oersal 2021).

Panel VAR/VECM estimation using the mean-group (MG) and pooled
mean-group (PMG) estimators with optional Kilian (1998) bias correction
and factor-augmented specifications for cross-sectional dependence.

Panel SVAR identification via Cholesky decomposition,
Blanchard-Quah long-run restrictions, proxy/IV variables, distance
covariance (DC), and Cramer-von Mises (CVM) independence criteria.

Specification tools for determining the number of common factors
(Onatski 2010, Ahn and Horenstein 2013, Bai and Ng 2002) and the
optimal lag order based on AIC, HQC, SIC, and FPE criteria.

Impulse response functions, forecast error variance
decomposition, and bootstrap confidence intervals via the
panel moving-block bootstrap.

Publication-quality plots for IRFs with confidence bands,
FEVD stacked area charts, and companion matrix eigenvalue stability
diagrams.

The data must be xtset before calling xtpvarcoint.
Individual-specific lag orders are supported by specifying a
numlist in lags().

Options

Panel Cointegration (pcoint, coint)

method(JO|BR|SL|CAIN) specifies the panel cointegration test
procedure: JO for Johansen (Larsson et al. 2001), BR for
Breitung (2005), SL for Saikkonen-Luetkepohl (Arsova and
Oersal 2018), or CAIN for the correlation-augmented inverse
normal test (Arsova and Oersal 2021). Default is JO.

type(Case1|Case2|Case3|Case4|Case5|SL_mean|SL_trend) specifies
the deterministic term in the cointegration model.
Case1: no intercept, no trend.
Case2: restricted intercept (intercept enters only through the
error-correction term).
Case3: unrestricted intercept (default).
Case4: restricted trend, unrestricted intercept.
Case5: unrestricted intercept and trend.
SL_mean: SL procedure with mean shift.
SL_trend: SL procedure with trend (default for method SL).

lags(numlist) specifies either a common lag order (single integer)
or individual-specific lag orders for each panel unit (one integer per
unit). Required for pcoint, coint, pvar, pvec, and
vecm.

nfactors(#) specifies the number of common factors for
factor-augmented (PANIC) analysis. Default is 0 (no factors).

niter(#) specifies the number of iterations for factor estimation.
Default is 0.

tbreak(numlist) specifies structural break dates (observation
indices) for trend-break dummies.

tshift(numlist) specifies shift-break dates for level-shift dummies.

nseason(#) specifies the number of seasons for seasonal dummy
variables. Default is 0 (no seasonal dummies).

Panel VAR/VECM (pvar, pvec, vecm)

type(const|trend|both|none) specifies the deterministic terms for
VAR estimation. const: constant only (default).
trend: linear trend only. both: constant and trend.
none: no deterministic terms.

rank(#) specifies the cointegration rank for VECM estimation.
Required for pvec. Default is 0 for vecm (unrestricted).

pool(numlist) specifies which variable indices to pool using
the Breitung (2005) two-step estimator for homogeneous cointegrating
vectors. Omit for individual-specific vectors (MG estimator).

exog(varlist) specifies exogenous variables to include in the
VAR/VECM.

exlags(#) specifies the number of lags for exogenous variables.
Default is 0.

SVAR Identification (pid)

method(chol|grt|iv|dc|cvm) specifies the SVAR identification
method: chol for Cholesky (default), grt for Blanchard-Quah
long-run restrictions, iv for proxy/instrumental variables,
dc for distance covariance ICA, or cvm for Cramer-von Mises
ICA.

combine(pool|group|indiv) specifies how individual structural
matrices are combined: pool for pooled residuals (default),
group for group-specific ICA, or indiv for unit-specific
identification.

itermax(#) specifies the maximum number of iterations for
ICA-based identification. Default is 500.

steptol(#) specifies the step tolerance parameter for ICA
optimization. Default is 100.

iter2(#) specifies the number of second-stage iterations. Default
is 75.

Specification (speci)

lagset(numlist) specifies the candidate lag orders to evaluate.
Required for speci var.

kmax(#) specifies the maximum number of factors to consider.
Default is 20.

differenced requests first-differencing of the data before
factor analysis.

centered requests demeaning (centering) of the data before
factor analysis.

scaled requests standardization (scaling to unit variance) before
factor analysis.

breaks(#) specifies the maximum number of structural breaks for
lag/break selection. Default is 0.

trim(real) specifies the trimming parameter for break detection.
Default is 0.15.

IRF, FEVD, and Bootstrap (irf, fevd, sboot)

horizon(#) specifies the forecast horizon. Default is 20.

cumulative requests cumulative impulse responses.

orthogonal requests orthogonalized (Cholesky) impulse responses
instead of structural.

method(pmb|mb|mg|normality) specifies the bootstrap method:
pmb for panel moving-block (default), mb for individual
moving-block, mg for mean-group, or normality for
residual bootstrap normality test.

nboot(#) specifies the number of bootstrap replications. Default
is 500.

blocksize(#) specifies the block size for moving-block bootstrap.
Default is ceil(T^(1/3)).

ci(real) specifies the confidence level for bootstrap intervals.
Default is 0.95.

seed(#) sets the random number seed for reproducibility.

Plots (plot)

plottype(irf|fevd|eigenvalues) specifies the type of plot:
irf for impulse response functions (default), fevd for
forecast error variance decomposition, or eigenvalues for
companion matrix eigenvalue stability plot.

variable(numlist) specifies which response variables to plot
(by index). Default is all.

shock(numlist) specifies which shocks to plot (by index). Default
is all.

saving(string) specifies a filename to export the graph.

title(string) specifies a custom graph title.

Examples

Setup

. webuse grunfeld2, clear

. xtset company year

1. Lag Order Selection

. xtpvarcoint speci var invest mvalue kstock, lagset(1 2 3 4)

2. Factor Number Determination

. xtpvarcoint speci factors invest mvalue kstock, kmax(5) differenced centered

. xtpvarcoint speci factors invest mvalue kstock, kmax(8) centered scaled nfactors(3)

3. Panel Cointegration (Johansen)

. xtpvarcoint pcoint invest mvalue kstock, method(JO) lags(2) type(Case3)

4. Panel Cointegration (CAIN — CSD-robust)

. xtpvarcoint pcoint invest mvalue kstock, method(CAIN) lags(2) type(Case3)

5. Panel Cointegration with per-unit lags

. xtpvarcoint pcoint invest mvalue kstock, method(JO) lags(1 2 3 2 1 2 3 2 1 2) type(Case3)

6. Individual Cointegration Test (single unit)

. preserve

. keep if company == 1

. tsset year

. xtpvarcoint coint invest mvalue kstock, lags(2) type(Case3) method(JO)

. restore

7. Panel VAR Estimation (Mean Group)

. xtpvarcoint pvar invest mvalue kstock, lags(2) type(const)

8. Panel VECM Estimation (rank = 1)

. xtpvarcoint pvec invest mvalue kstock, lags(2) rank(1) type(Case3)

9. Individual VECM

. preserve

. keep if company == 1

. tsset year

. xtpvarcoint vecm invest mvalue kstock, lags(2) rank(1) type(Case3)

. restore

10. Impulse Response Functions

. xtpvarcoint pvar invest mvalue kstock, lags(2) type(const)

. xtpvarcoint irf, horizon(20)

. xtpvarcoint irf, horizon(15) cumulative

11. Orthogonal IRFs (after VECM)

. preserve

. keep if company == 1

. tsset year

. xtpvarcoint vecm invest mvalue kstock, lags(2) rank(1) type(Case3)

. xtpvarcoint irf, horizon(10) orthogonal

. restore

12. Forecast Error Variance Decomposition

. xtpvarcoint pvar invest mvalue kstock, lags(2) type(const)

. xtpvarcoint fevd, horizon(20)

13. SVAR Identification

. preserve

. keep if company == 1

. tsset year

. xtpvarcoint vecm invest mvalue kstock, lags(2) rank(1) type(Case3)

. xtpvarcoint pid, method(chol)

. xtpvarcoint pid, method(grt)

. xtpvarcoint pid, method(dc) combine(pool)

. xtpvarcoint pid, method(cvm) itermax(200) steptol(50)

. restore

14. Bootstrap Inference

. preserve

. keep if company == 1

. tsset year

. xtpvarcoint vecm invest mvalue kstock, lags(2) rank(1) type(Case3)

. xtpvarcoint sboot, method(pmb) nboot(500) horizon(20) ci(0.95) seed(12345)

. xtpvarcoint sboot, method(mb) nboot(500) blocksize(3) horizon(10) ci(0.90)

. restore

15. Publication-Quality Plots

. xtpvarcoint pvar invest mvalue kstock, lags(2) type(const)

. xtpvarcoint irf, horizon(20)

. xtpvarcoint plot, plottype(irf) title("IRF Plot")

. xtpvarcoint plot, plottype(irf) saving(irf_plot.png)

. xtpvarcoint fevd, horizon(20)

. xtpvarcoint plot, plottype(fevd) title("FEVD Plot")

. xtpvarcoint plot, plottype(eigenvalues) title("Stability")

16. Panel VECM with per-unit lags

. xtpvarcoint pvec invest mvalue kstock, lags(2 2 1 2 2 1 2 2 1 2) rank(1) type(Case3)

Stored results

Results are stored as global Stata matrices and scalars with the prefix
_xpvc_. These persist across successive xtpvarcoint calls.

pcoint — Panel Cointegration

Scalars

_xpvc_N number of panel individuals

_xpvc_K number of endogenous variables

_xpvc_rho_eps estimated cross-sectional correlation (CAIN only)

Matrices

_xpvc_LRbar standardized LR_bar panel test statistics (JO/BR/SL)

_xpvc_LRbar_pval p-values for LR_bar

_xpvc_Choi_P Fisher (Choi P) combination statistics

_xpvc_Choi_Pm modified Fisher (Choi Pm) statistics

_xpvc_Choi_Z inverse normal (Choi Z) statistics

_xpvc_CAIN CAIN test statistics (CAIN only)

_xpvc_CAIN_pval CAIN p-values

_xpvc_indiv_TR K x N matrix of individual trace statistics

_xpvc_indiv_pval K x N matrix of individual p-values

Macros

r(method) test method (JO, BR, SL, or CAIN)

r(type) deterministic specification

coint — Individual Cointegration

Scalars

_xpvc_K number of variables

_xpvc_T effective sample size

_xpvc_p lag order

Matrices

_xpvc_eigenvalues eigenvalues

_xpvc_trace_stat trace test statistics

_xpvc_trace_pval trace p-values

_xpvc_maxeig_stat max-eigenvalue test statistics

_xpvc_maxeig_pval max-eigenvalue p-values

_xpvc_beta cointegrating vectors

pvar — Panel VAR

Scalars

_xpvc_N number of panel individuals

_xpvc_K number of endogenous variables

_xpvc_max_p maximum lag order

_xpvc_max_eigenmod maximum companion eigenvalue modulus

Matrices

_xpvc_A mean-group VAR coefficient matrix [A_1, ..., A_p]

_xpvc_A_var variance of individual coefficient matrices

pvec — Panel VECM

Scalars

_xpvc_N number of panel individuals

_xpvc_K number of endogenous variables

_xpvc_r cointegration rank

_xpvc_max_p maximum lag order

Matrices

_xpvc_A mean-group VAR coefficient matrix (levels)

_xpvc_alpha mean-group loading matrix (K x r)

_xpvc_beta mean-group cointegrating vectors

_xpvc_PI mean-group long-run impact PI = alpha*beta'

_xpvc_GAMMA mean-group short-run coefficients

vecm — Individual VECM

Scalars

_xpvc_K number of variables

_xpvc_T effective sample size

_xpvc_p lag order

_xpvc_r cointegration rank

Matrices

_xpvc_A VAR coefficients in levels

_xpvc_alpha loading matrix

_xpvc_beta cointegrating vectors

_xpvc_PI long-run impact matrix

_xpvc_GAMMA short-run coefficients

_xpvc_OMEGA MLE residual covariance

_xpvc_SIGMA OLS residual covariance

_xpvc_eigenvalues Johansen eigenvalues

pid — SVAR Identification

Matrices

_xpvc_B structural impact matrix B

Macros

r(pid_method) identification method used

r(pid_combine) combination approach

irf — Impulse Response Functions

Scalars

_xpvc_horizon forecast horizon

Matrices

_xpvc_IRF (H+1) x K^2 IRF matrix

_xpvc_IRF_cum (H+1) x K^2 cumulative IRF (if requested)

fevd — Variance Decomposition

Matrices

_xpvc_FEVD (H+1) x K^2 FEVD matrix

sboot — Bootstrap

Scalars

_xpvc_nboot number of bootstrap replications

_xpvc_ci_level confidence level

_xpvc_blocksize block size used

Matrices

_xpvc_IRF (H+1) x K^2 point estimate IRF

_xpvc_IRF_lo (H+1) x K^2 lower CI bounds

_xpvc_IRF_hi (H+1) x K^2 upper CI bounds

speci — Specification Tools

Scalars (speci var)

_xpvc_p_aic optimal lag by AIC

_xpvc_p_hqc optimal lag by HQC

_xpvc_p_sic optimal lag by SIC

_xpvc_p_fpe optimal lag by FPE

Matrices (speci var)

_xpvc_IC_table information criteria table

Scalars (speci factors)

_xpvc_r_ONC Onatski edge-distribution estimate

_xpvc_r_ER Ahn-Horenstein eigenvalue ratio estimate

_xpvc_r_GR Ahn-Horenstein growth ratio estimate

_xpvc_r_IC1 Bai-Ng IC(p1) estimate

_xpvc_r_IC2 Bai-Ng IC(p2) estimate

_xpvc_r_IC3 Bai-Ng IC(p3) estimate

Matrices (speci factors)

_xpvc_eigenvalues eigenvalues from SVD

_xpvc_IC information criterion values

_xpvc_Ft estimated factors (if nfactors > 0)

_xpvc_LAMBDA factor loadings (if nfactors > 0)

References

Ahn, S. and Horenstein, A. (2013). Eigenvalue ratio test for the
number of factors. Econometrica, 81, pp. 1203-1227.

Arsova, A. and Oersal, D. (2018). Likelihood-based panel cointegration
test in the presence of a linear time trend and cross-sectional
dependence. Econometric Theory, 34, pp. 1033-1073.

Arsova, A. and Oersal, D. (2021). A panel cointegration test under
cross-sectional dependence. Econometrics and Statistics, 17,
pp. 38-51.

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

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

Blanchard, O. and Quah, D. (1989). The dynamic effects of aggregate
demand and supply disturbances. American Economic Review, 79,
pp. 655-673.

Breitung, J. (2005). A parametric approach to the estimation of
cointegration vectors in panel data. Econometric Reviews, 24,
pp. 151-173.

Doornik, J. (1998). Approximations to the asymptotic distribution
of cointegration tests. Journal of Economic Surveys, 12,
pp. 573-593.

Johansen, S. (1995). Likelihood-based Inference in Cointegrated
Vector Autoregressive Models. Oxford University Press.

Kilian, L. (1998). Small-sample confidence intervals for impulse
response functions. Review of Economics and Statistics, 80,
pp. 218-230.

Larsson, R., Lyhagen, J., and Lothgren, M. (2001). Likelihood-based
cointegration tests in heterogeneous panels.
The Econometrics Journal, 4, pp. 109-142.

Luetkepohl, H. (2005). New Introduction to Multiple Time Series
Analysis. Springer, 2nd ed.

Onatski, A. (2010). Determining the number of factors from empirical
distribution of eigenvalues. Review of Economics and Statistics,
92, pp. 1004-1016.

Pesaran, M.H., Shin, Y., and Smith, R.J. (1999). Pooled mean group
estimation of dynamic heterogeneous panels.
Journal of the American Statistical Association, 94, pp. 621-634.

Saikkonen, P. and Luetkepohl, H. (2000). Testing for the cointegrating
rank of a VAR process with structural shifts.
Journal of Business and Economic Statistics, 18, pp. 451-464.

Version history

1.0.1 (05apr2026)

Fixed conformability error (r3200) in pvec when using heterogeneous
per-unit lag orders. GAMMA matrices of varying dimensions are now
zero-padded to a common size before mean-group averaging.

All 37 tests pass (0 failures).

1.0.0 (03apr2026)

Initial release. Port of the R package pvars.

Authors

Dr Merwan Roudane

Email: merwanroudane920@gmail.com

Please cite as:

Roudane, M. (2026). xtpvarcoint: Panel VAR modeling with cointegration,
structural breaks, and cross-sectional dependence.
Statistical Software Components, Boston College Department of Economics.