*! version 1.1.0 06may2026

Title

xtpanelcoint -- Panel cointegration and multiple long-run
relations estimation

Syntax

Bivariate long-run coefficient estimators

xtpanelcoint estimator depvar [if] [in]
[, options]

where estimator is one of: spmg, breitung, pdols,
or mgmw

Mean Group Distributed Lag (IRF estimation)

xtpanelcoint mgdl depvar shockvar [if] [in],
product(varname) location(varname)
[mgdl_options]

Pooled Minimum Eigenvalue (multiple long-run relations)

xtpanelcoint pme varlist [if] [in] [, pme_options]

Post-estimation visualization

xtpanelcoint plot [, plot_options]

Options

SPMG options
lags(#) lag order for ARDL specification;
default is lags(2)

maxiter(#) maximum iterations;
default is maxiter(500)

precision(#) convergence tolerance;
default is precision(1e-4)

bootstrap(#) number of wild bootstrap
replications; default is bootstrap(0) (off)

seed(#) random seed for bootstrap;
default is seed(1234)

Breitung options
lags(#) lag order; default is lags(2)

PDOLS options
leadslags(#) number of leads and lags of
D.x; default is leadslags(4)

MGMW options
subperiods(#) number of sub-periods for temporal
aggregation; default is subperiods(5)

MGDL options
product(varname) variable identifying product
groups; required

location(varname) variable identifying location
groups; required

horizon(#) IRF horizon;
default is horizon(4)

augmented use augmented variance estimator for robust
inference

bonferroni apply Bonferroni correction for family-wise
error rate

PME options
subsamples(#) number of sub-sample periods
(q {&ge} 2); default is subsamples(2)

delta(#) thresholding exponent for rank
estimation; default is delta(0.25)

rank(#) fix the number of long-run relations
r0 (bypasses automatic estimation)

Plot options
type(string) plot type: coeff, compare,
irf, eigenvalue, cumulative

saving(filename) save graph to file
(supports .png, .pdf, .eps)

title(string) custom graph title

subtitle(string) custom graph subtitle

compare compare stored estimates (requires prior
estimates store)

Description

xtpanelcoint implements a suite of panel cointegration estimators for
long-run relations in heterogeneous panels where both N and T are large. The
package provides six estimators and publication-quality visualization tools.

The panel must be declared via xtset and must be strongly balanced.
All estimators post results to e() and support estimates store.

This is the Stata implementation of the Python multicoint library (v1.1.0),
which translates the original MATLAB replication code from the authors'
academic papers.

Estimators

SPMG â€” System Pooled Mean Group

The SPMG estimator of Chudik, Pesaran & Smith (2023) maximizes the system
log-likelihood for the bivariate VECM:

{&Delta}wit = -{&phi}i {&beta}' wi,t-1
+ {&Upsilon}i qit + uit

where wit = (yit, xit)',
{&beta} = (1, -{&theta})', and
{&phi}i = ({&phi}yi, {&phi}xi)'.

Key properties:

- Handles two-way long-run causality between y and x

- Robust to non-cointegrating units ({&phi}i {&rarr} 0 contributes negligibly)

- Invariant to normalization: {&theta}y.x {&middot} {&theta}x.y = 1

- Optional wild bootstrap confidence intervals

Breitung â€” Two-Step Parametric

The Breitung (2005) two-step estimator:

Step 1: Unit-by-unit Engle-Granger to get {&beta}i, {&alpha}i, {&Sigma}i

Step 2: Pooled regression on transformed variables z+it

Uses heteroskedasticity-robust standard errors. Non-iterative.

PDOLS â€” Panel Dynamic OLS

The Panel DOLS estimator of Mark & Sul (2003) augments the cointegrating
regression with leads and lags of {&Delta}xit to correct for
endogeneity. Heteroskedasticity-robust standard errors.

MGMW â€” MÃ¼ller-Watson Mean Group

The MGMW estimator uses temporal aggregation (sub-period averaging) to
estimate long-run coefficients. Robust to unknown forms of serial
correlation.

MGDL â€” Mean Group Distributed Lag

The MGDL estimator of Choi & Chudik (2024) estimates impulse response
functions of common observed shocks in large panels with a
productlocationtime structure:

xijt = aij + {&Sigma}{&ell}=0h
bij{&ell} vt-{&ell} + controls + eijt

Returns product-level IRFs, location effects cj, and cumulative
multipliers with optional Bonferroni-corrected confidence intervals.

PME â€” Pooled Minimum Eigenvalue

The PME estimator of Chudik, Pesaran & Smith (2025) estimates r0
long-run relations in panel data with m > 2 variables, using sub-sample
time averages and eigenvalue decomposition:

QwÌ„wÌ„ = (nTq)-1 {&Sigma} {&Sigma}
(wÌ„i{&ell} - wÌ„i.)(wÌ„i{&ell} - wÌ„i.)'

The number of long-run relations is estimated by counting eigenvalues below
the threshold T-{&delta}. Identified coefficients and
asymptotic inference are provided.

Visualization

After estimation, call xtpanelcoint plot for publication-quality
graphs:

Coefficient plot (SPMG, Breitung, PDOLS, MGMW):

xtpanelcoint plot

xtpanelcoint plot, saving(fig_coeff.png)

Multi-estimator comparison (requires estimates store):

xtpanelcoint spmg y x, lags(2)

estimates store spmg

xtpanelcoint breitung y x, lags(2)

estimates store breitung

xtpanelcoint plot, type(compare)

IRF plot (after MGDL estimation):

xtpanelcoint plot, type(irf)

Eigenvalue scree plot (after PME estimation):

xtpanelcoint plot, type(eigenvalue)

Cumulative multiplier bar chart (after MGDL estimation):

xtpanelcoint plot, type(cumulative)

Stored results

All bivariate estimators (SPMG, Breitung, PDOLS, MGMW) store:

Scalars

e(theta) estimated long-run coefficient {&theta}

e(se) asymptotic standard error

e(t_ratio) t-ratio for H0: {&theta} = 1

e(p_value) two-sided p-value

e(ci95_lo) lower bound of 95% asymptotic CI

e(ci95_hi) upper bound of 95% asymptotic CI

e(boot_ci_lo) lower bound of 95% bootstrap CI (if computed)

e(boot_ci_hi) upper bound of 95% bootstrap CI (if computed)

e(N_g) number of panels (cross-sections)

e(T) number of time periods

e(lags) lag order used

e(n_iter) number of iterations (iterative estimators)

e(converged) 1 if converged, 0 otherwise

Macros

e(cmd) xtpanelcoint

e(estimator) estimator name

e(estimator_type) estimator code (spmg, breitung, etc.)

e(depvar) dependent variable name

e(indepvar) independent variable name

MGDL additionally stores:

e(M_products) number of product groups

e(N_locations) number of location groups

e(horizon) IRF horizon

e(cum_mult) M1 matrix of cumulative multipliers

e(cum_ci_lo) lower CI bounds

e(cum_ci_hi) upper CI bounds

e(product_irfs) M(h+1) matrix of product-level IRFs

e(location_irfs) N(h+1) matrix of location effects c_j

e(significant) M1 significance indicator

PME additionally stores:

e(r_hat) estimated number of long-run relations

e(m_vars) number of variables

e(eigenvalues) m1 vector of eigenvalues (ascending)

e(Theta) (m-r)r matrix of identified coefficients

e(Theta_se) standard errors of Theta

e(Theta_t) t-ratios

e(Theta_p) p-values

e(Q_ww) mm pooled covariance matrix

Examples

Example 1: Consumption-GDP great ratio (JST data)

Replicates Chudik, Pesaran & Smith (2023) Table 4, Application 1.
Uses 13 countries with complete data from 1870-2016 (T=147).

. import excel "JSTdatasetR4.xlsx", sheet("Data") firstrow clear

. keep year iso rgdppc rconpc

. encode iso, gen(country_id)

. gen ln_con = ln(rconpc)

. gen ln_gdp = ln(rgdppc)

. xtset country_id year

. keep if ln_con != . & ln_gdp != .

. bysort country_id: gen _T = _N

. keep if _T == 147

. drop _T

. xtset country_id year

SPMG with wild bootstrap (recommended):

. xtpanelcoint spmg ln_con ln_gdp, lags(2) bootstrap(500) seed(1234)

theta = 0.902, SE = 0.007, Bootstrap 95% CI: [0.864, 0.940]

H0: theta=1 rejected â€” consumption-GDP ratio is NOT a great ratio

Multi-estimator comparison:

. xtpanelcoint spmg ln_con ln_gdp, lags(2)

. estimates store spmg

. xtpanelcoint breitung ln_con ln_gdp, lags(2)

. estimates store breitung

. xtpanelcoint pdols ln_con ln_gdp, leadslags(4)

. estimates store pdols

. xtpanelcoint mgmw ln_con ln_gdp, subperiods(5)

. estimates store mgmw

. xtpanelcoint plot, type(compare)

Example 2: Term structure â€” short rate / long rate

Tests whether the term spread is stationary (4 countries, T=147).

. xtpanelcoint spmg short_r long_r, lags(2) bootstrap(500) seed(42)

theta = 0.921, SE = 0.044, Bootstrap 95% CI: [0.748, 1.094]

H0: theta=1 NOT rejected â€” term spread IS stationary

Example 3: PME with three variables (consumption, GDP, investment)

. gen ln_inv = ln(iy * gdp)

. xtpanelcoint pme ln_con ln_gdp ln_inv, subsamples(3) delta(0.25)

r_hat = 2 â€” two cointegrating relations among three variables

Implies one common stochastic trend driving all three series

. xtpanelcoint plot, type(eigenvalue)

Example 4: MGDL impulse responses (product x location panel)

. * Requires product x location x time panel structure

. xtset panel_id time

. xtpanelcoint mgdl dlnprice oilshock, product(product_id) location(city_id) horizon(6) augmented bonferroni

. xtpanelcoint plot, type(irf) saving(fig_irf.png)

. xtpanelcoint plot, type(cumulative) saving(fig_cum.png)

Example 5: Simulated DGP (theta = 1)

. clear

. set seed 12345

. local N = 20

. local T = 100

. set obs `=`N'*`T''

. gen id = ceil(_n/`T')

. bysort id: gen time = _n

. xtset id time

. gen double x = 0

. gen double y = 0

. gen double u = 0

. bysort id (time): replace x = x[_n-1] + rnormal() if _n > 1

. bysort id (time): replace u = 0.5*u[_n-1] + rnormal()*0.5 if _n > 1

. replace y = x + u

. xtpanelcoint spmg y x, lags(2) bootstrap(200) seed(42)

theta = 1.008, SE = 0.005, Bootstrap CI: [0.994, 1.022]

H0: theta=1 not rejected â€” correctly recovers true theta=1

References

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

Choi, C.-Y. & Chudik, A. (2024). Mean group distributed lag estimation of
impulse response functions in large panels. Federal Reserve Bank of Dallas,
Globalization Institute Working Paper 0423r1.

Chudik, A., Pesaran, M.H. & Smith, R.P. (2023). Revisiting the great ratios
hypothesis. Federal Reserve Bank of Dallas, Globalization Institute Working
Paper 415.

Chudik, A., Pesaran, M.H. & Smith, R.P. (2025). Estimation of multiple
long-run relations in panels. arXiv:2506.02135v3.

Mark, N.C. & Sul, D. (2003). Cointegration vector estimation by panel DOLS
and long-run money demand. Oxford Bulletin of Economics and Statistics
65(5), 655-680.

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

Author

Dr. Merwan Roudane

Email: merwanroudane920@gmail.com

GitHub: https://github.com/merwanroudane/multicointt

Python version: multicoint (PyPI)

Please cite as:

Roudane, M. (2026). xtpanelcoint: Panel Cointegration and Multiple Long-Run
Relations Estimation for Stata. Statistical Software Components.

Also see

Online: xtpmg, xtset, estimates