*! version 1.0.0 01mar2026

Title

xtpcmg -- Panel Cointegrating Polynomial Regressions: Group-Mean & Pooled FM-OLS (v1.0.0)

Syntax

xtpcmg depvar regressors [if] [in] , model(string)
[options]

Model
model(string) estimation method: mg (Group-Mean FM-OLS) or pmg (Pooled FM-OLS); required

q(#) polynomial degree: 2 (quadratic) or 3 (cubic); default is 2

poly(varname) variable receiving the polynomial expansion; default is the first regressor

Deterministic Components
trend(#) (mg only) 1 = individual intercepts; 2 = individual intercepts + linear trends; default is 1

effects(string) (pmg only) oneway = individual FE; twoway = individual + time FE; default is oneway

HAC Estimation
kernel(string) kernel: ba (Bartlett, default), tr (Truncated), pa (Parzen), bo (Bohman), da (Daniell), qs (Quadratic Spectral)

bw(string) bandwidth: And91 (Andrews 1991, default), or a positive integer

Advanced
corrrob (mg only) cross-sectional dependence robust VCV matrix

graph produce comprehensive diagnostic plots (7 graphs for mg, 4 for pmg)

level(#) confidence level; default is level(95)

You must xtset your data before using xtpcmg; see xtset. The panel must be strongly balanced.

Description

xtpcmg estimates Fully Modified OLS (FM-OLS) for Panel Cointegrating Polynomial Regressions (CPRs).
Polynomial cointegration models arise when a dependent variable is linked not just to an integrated
process but also to its higher-order powers. The leading application is the Environmental Kuznets
Curve (EKC), where CO2 emissions follow a quadratic or cubic function of GDP.
Standard panel cointegration estimators are inconsistent for these models because the polynomial
powers are perfectly correlated with the level of the integrated process.
xtpcmg applies the specialised FM-OLS corrections developed in the recent econometrics
literature.

Multiple regressors. The user selects which variable receives the polynomial expansion via
poly(varname). All other regressors enter linearly as controls. If poly() is omitted,
the first regressor is expanded.

xtpcmg implements two estimators:

1. Group-Mean FM-OLS (model(mg))

Based on Wagner and Reichold (2023, Econometric Reviews).
Each cross-section unit is individually corrected using HAC long-run variance estimation.
The group-mean estimator averages the individual FM-OLS coefficients, yielding a
consistent and asymptotically normal estimator under cross-sectional independence.
When cross-sectional dependence is suspected, the corrrob option provides a
robust VCV using the full 2N x 2N long-run covariance matrix.

2. Pooled FM-OLS (model(pmg))

Based on de Jong and Wagner (2022, Econometrics and Statistics).
The pooled estimator stacks the panel and uses averaged long-run variances,
scaling by the exact deterministic asymptotic limits (M and Q matrices).
Individual or two-way fixed effects are removed before estimation.

Automatic advanced analysis. After estimation, xtpcmg automatically displays:

(i) Individual FM-OLS coefficient table (mg only), showing each panel's estimates.

(ii) Coefficient heterogeneity analysis with descriptive statistics (mean, median, SD, IQR,
skewness, kurtosis) and percentile distribution (min, P5, P25, P75, P95, max).

(iii) Swamy (1970) test for slope homogeneity across panels.

(iv) Between-within variance decomposition to distinguish systematic heterogeneity from
estimation noise.

(v) Turning point analysis with delta-method confidence intervals (quadratic) or two
critical points (cubic).

Options

Model

model(string) selects the estimation method. model(mg) for Group-Mean FM-OLS
(Wagner and Reichold 2023) or model(pmg) for Pooled FM-OLS (de Jong and Wagner 2022).
This option is required.

q(#) sets the polynomial degree of the cointegrating relationship.
2 estimates y = b1*x + b2*x^2 (+ controls).
3 adds b3*x^3.
Default is 2.

poly(varname) specifies which independent variable receives the polynomial
expansion. The variable must appear in regressors. All other regressors are
included linearly as controls. If omitted, the first regressor is expanded.

Deterministic Components

trend(#) (mg only) controls the deterministic specification for
detrending individual series.
1 = individual intercepts only (demeaning).
2 = individual intercepts + individual linear time trends.
Default is 1.

effects(string) (pmg only) controls the fixed-effects removal.
oneway = individual fixed effects.
twoway = individual + time fixed effects.
Default is oneway.

HAC Estimation

kernel(string) selects the kernel function for HAC long-run variance estimation.
Available kernels: ba (Bartlett, default), tr (Truncated),
pa (Parzen), bo (Bohman), da (Daniell), qs (Quadratic Spectral).

bw(string) selects the bandwidth. And91 uses the data-driven bandwidth
selector of Andrews (1991) (default). Alternatively, specify a positive integer.

Advanced

corrrob (mg only) computes the cross-sectional correlation robust VCV
matrix. This uses the full 2N x 2N long-run variance matrix to account for
contemporaneous correlation across panels. Recommended for macro panels where
cross-sectional dependence is expected.

graph produces a comprehensive suite of publication-quality diagnostic plots.
For the mg model, up to 7 graphs are produced: polynomial fit, panel-by-panel scatter,
kernel density of coefficients, caterpillar (sorted bar) plots, box plots,
residual diagnostics, and turning point visualization. For pmg, 4 graphs are
produced (fit, panel scatter, residuals, and turning point). All graphs are
combined into a single diagnostic suite.

level(#) sets the confidence level for the estimation table and turning
point analysis. Default is 95.

Advanced Output

xtpcmg produces the following advanced analysis tables after the main estimation results:

Individual Coefficient Table (mg only)

Displays each panel's individual FM-OLS coefficient estimates for the polynomial terms.
This allows direct inspection of cross-sectional heterogeneity in the estimated relationship.

Coefficient Heterogeneity Analysis (mg only)

Descriptive Statistics: Reports the mean, median, standard deviation, interquartile range (IQR),
skewness, and kurtosis of the distribution of individual panel coefficients for each regressor.

Percentile Distribution: Reports the minimum, 5th, 25th, 75th, 95th percentiles, and maximum
of individual panel coefficients.

Swamy (1970) Slope Homogeneity Test (mg only)

Tests the null hypothesis that all individual FM-OLS slope coefficients are equal against the
alternative that at least one panel has a different slope. The S-statistic follows a chi-squared
distribution with (N-1)*K degrees of freedom under the null. A rejection (p < 0.05) suggests
significant heterogeneity, supporting the use of Group-Mean over Pooled FM-OLS.

Between-Within Variance Decomposition (mg only)

Decomposes the total variance of individual panel coefficients into between-panel variance
(systematic heterogeneity) and within-panel estimation noise. The ratio of between-panel to total
variance indicates the strength of the heterogeneity signal. A ratio > 0.8 indicates high
systematic heterogeneity; < 0.5 indicates mostly estimation noise.

Turning Point Analysis

For quadratic models (q=2), computes the turning point x* = -b1/(2*b2) with delta-method standard
errors and 95% confidence interval. Identifies whether the relationship is concave (inverted U) or
convex (U-shaped). For cubic models (q=3), reports both critical points when they exist.

Diagnostic Graphs

When graph is specified, xtpcmg generates a comprehensive diagnostic suite:

1. Polynomial Fit: Scatter plot of observed data with the estimated FM-OLS polynomial curve overlaid.

2. Panel-by-Panel Scatter: Small multiples showing each panel's data and the estimated curve.

3. Coefficient Density (mg only): Kernel density plots of individual FM-OLS coefficient distributions.

4. Caterpillar Plot (mg only): Sorted bar charts of individual panel coefficients with the group-mean reference line.

5. Box Plot (mg only): Box-and-whisker plots summarising the coefficient distribution across panels.

6. Residual Distribution: Histogram of FM-OLS residuals with kernel density overlay.

7. Turning Point (when applicable): Fitted curve with the estimated turning point and confidence interval marked.

Stored Results

xtpcmg stores the following in e():

Scalars

e(N_g) number of panels

e(T) number of time periods

e(q) polynomial degree

e(n_controls) number of linear control variables (if any)

e(tp) turning point estimate (q=2)

e(tp_se) turning point standard error (q=2)

e(tp_lo) turning point lower 95% CI bound (q=2)

e(tp_hi) turning point upper 95% CI bound (q=2)

e(tp_z) turning point z-statistic (q=2)

e(tp_p) turning point p-value (q=2)

e(tp1) first critical point (q=3)

e(tp2) second critical point (q=3)

e(swamy_s) Swamy S-statistic (mg only)

e(swamy_df) Swamy degrees of freedom (mg only)

e(swamy_p) Swamy p-value (mg only)

Macros

e(cmd) xtpcmg

e(cmdline) command as typed

e(title) model description

e(depvar) dependent variable name

e(model) mg or pmg

e(polyvar) polynomial variable name

e(controls) list of control variables (if any)

Matrices

e(b) coefficient vector

e(V) variance-covariance matrix

e(indiv_b) N x K matrix of individual FM-OLS coefficients (mg only)

Functions

e(sample) estimation sample

Examples

Setup

. webuse pennxrate, clear

. xtset id year

Example 1: Group-Mean quadratic EKC with robust VCV and graphs

. xtpcmg lCO2 lGDP, model(mg) q(2) trend(1) bw(And91) corrrob graph

Example 2: Pooled cubic with two-way fixed effects and Bartlett kernel

. xtpcmg lCO2 lGDP, model(pmg) q(3) effects(twoway) kernel(ba) graph

Example 3: Multiple regressors — polynomial on lGDP, linear controls lTrade and lPop

. xtpcmg lCO2 lGDP lTrade lPop, model(mg) poly(lGDP) q(2) corrrob graph

Example 4: Pooled cubic with one linear control

. xtpcmg lCO2 lGDP lTrade, model(pmg) poly(lGDP) q(3) effects(oneway) graph

Example 5: Access stored results after estimation

. xtpcmg y x, model(mg) q(2) bw(And91)

. di "Turning point = " e(tp)

. di "Swamy p-value = " e(swamy_p)

. matrix list e(indiv_b)

. ereturn list

References

Andrews, D. W. K. (1991). Heteroskedasticity and autocorrelation consistent covariance matrix
estimation. Econometrica, 59(3), 817-858.

de Jong, R. M., & Wagner, M. (2022). Panel cointegrating polynomial regression analysis and
an illustration with the environmental Kuznets curve.
Econometrics and Statistics.

Swamy, P. A. V. B. (1970). Efficient inference in a random coefficient regression model.
Econometrica, 38(2), 311-323.

Wagner, M., & Reichold, K. (2023). Panel cointegrating polynomial regressions: group-mean
fully modified OLS estimation and inference.
Econometric Reviews, 42(4), 358-392.

Author

Dr. Merwan Roudane

Email: merwanroudane920@gmail.com