*! version 1.0.0 03jul2026

Title

xtfmg -- Second-generation heterogeneous panel estimators with
individual and common shocks: MG, CCEMG, SURMG, F-SURMG and the Fourier
Common Correlated Effects Mean Group (F-CCEMG) estimator

Syntax

xtfmg subcommand depvar indepvars [if] [in] [, options]

subcommand

fccemg Fourier CCE Mean Group estimator (Guliyev 2026) -- see xtfmg_fccemg

fsurmg Fourier SUR Mean Group estimator (Guliyev 2023, 2025) -- see xtfmg_fsurmg

ccemg CCE Mean Group estimator (Pesaran 2006) -- see xtfmg_estimators

surmg SUR Mean Group estimator -- see xtfmg_estimators

mg Mean Group estimator (Pesaran and Smith 1995) -- see xtfmg_estimators

fe pooled fixed-effects benchmark -- see xtfmg_estimators

all all six estimators, journal-style comparison table -- see xtfmg_all

breaks per-unit sup-Wald structural-break test (Andrews 1993) -- see xtfmg_breaks

map CSD diagnostics and regime-map estimator recommendation -- see xtfmg_map

The data must be xtset with both a panel and a time variable.
indepvars must be numeric; time-series and factor-variable operators are
not allowed (create the lags/dummies first).

Description

xtfmg estimates the mean slope of the heterogeneous panel data model
with individual and common shocks

y_it = a_i + b_i' x_it + u_it, u_it = g_i' f_t + e_it,

where the slopes b_i are heterogeneous across units with mean b = E(b_i),
f_t is a vector of unobserved common factors generating cross-sectional
dependence (CSD), and each unit may in addition experience structural breaks
at unit-specific dates. The object of interest is the mean slope b.

The package implements the full estimator set studied in Guliyev (2026):

o FE -- the pooled fixed-effects benchmark, inconsistent for
b under slope heterogeneity (Pesaran and Smith 1995);

o MG -- unit-by-unit OLS averaged across units, consistent
under heterogeneity but biased under CSD;

o CCEMG -- unit regressions augmented with the
cross-sectional averages of (y, x), which asymptotically span the factor
space (Pesaran 2006);

o SURMG -- the N unit equations estimated jointly by
feasible-GLS SUR, exploiting cross-equation error correlation when N is
small relative to T;

o F-SURMG -- SURMG with unit-specific single-frequency
Fourier terms approximating breaks of unknown number, timing and form
(Becker, Enders and Lee 2006; Enders and Lee 2012);

o F-CCEMG -- the proposed estimator: the CCE regression
augmented with unit-specific Fourier terms, so the cross-sectional averages
filter the common factor while the Fourier terms absorb idiosyncratic,
heterogeneously-timed breaks.

All mean-group estimators report the nonparametric Pesaran-Smith (1995)
variance. Every estimation subcommand also reports the Pesaran CD statistic
computed from its unit residuals.

The regime map

The Monte Carlo evidence in Guliyev (2026) shows that the appropriate
estimator depends jointly on the cross-section size N, the strength of the
cross-sectional dependence (measured by the Bailey-Kapetanios-Pesaran 2016
exponent alpha), and whether the structural breaks are individual rather
than common:

Dependence very small N (<10) moderate / large N

weak F-SURMG F-CCEMG

moderate F-CCEMG F-CCEMG

strong F-CCEMG (caution) CCEMG / F-CCEMG

xtfmg map estimates the panel's position on this map from the Mean
Group residuals and prints a recommendation. xtfmg breaks documents
whether the breaks are heterogeneously timed, as in the G7 application of
the paper where the estimated dates span 1974-2004.

Subcommands and options

Estimation subcommands (fccemg, fsurmg, ccemg,
surmg, mg) share the options kfreq(#) (Fourier frequency,
default 1; Fourier estimators only), level(#), heteroplot
(forest plot of the unit-specific slopes), fourierplot (plot of the
estimated unit-specific Fourier components; Fourier estimators only),
focus(varname) (variable shown in the heterogeneity plot) and
notable. See the linked pages for details.

xtfmg all adds coefplot (comparison of all six estimates with
confidence intervals, one panel per regressor). xtfmg breaks has
trim(#) (default 0.15) and plot. SUR-based estimators require a
balanced panel with T > N.

All table-producing subcommands accept saving(filename),
title(string) and replace, which export the table in
publication format chosen by the file extension: .tex (LaTeX with
booktabs rules and superscript stars), .rtf/.doc (Word, Times New
Roman, journal rules), .csv, or .txt (aligned text). Coefficients
carry significance stars with standard errors in parentheses beneath, and
the table notes report N, T, the CD statistic and the star legend.

Examples

Setup

. webuse grunfeld, clear

. xtset company year

Where is this panel on the regime map?

. xtfmg map invest mvalue kstock

Are the breaks heterogeneously timed?

. xtfmg breaks invest mvalue kstock, plot

The proposed estimator, with plots

. xtfmg fccemg invest mvalue kstock, heteroplot fourierplot

Small-N comparator that does not rely on cross-sectional averages

. xtfmg fsurmg invest mvalue kstock

Full journal-style comparison table and coefficient plot

. xtfmg all invest mvalue kstock, coefplot

Export the comparison table for the paper (LaTeX and Word)

. xtfmg all invest mvalue kstock, saving(table8.tex) replace

. xtfmg all invest mvalue kstock, saving(table8.rtf) replace

Stored results

Each subcommand is rclass; see the subcommand pages for the full
list. All estimation subcommands store r(b), r(V),
r(bunit), r(seunit), r(N), r(Tbar), r(cd),
r(cd_p) and r(alpha). xtfmg all stores the stacked
comparison matrices r(B) and r(SE) plus per-estimator
r(b_est) and r(V_est). xtfmg breaks
stores r(breaks). xtfmg map stores r(regime) and
r(recommend).

References

Andrews, D. W. K. 1993. Tests for parameter instability and structural
change with unknown change point. Econometrica 61: 821-856.
https://doi.org/10.2307/2951764

Bailey, N., G. Kapetanios, and M. H. Pesaran. 2016. Exponent of
cross-sectional dependence: Estimation and inference.
Journal of Applied Econometrics 31: 929-960.
https://doi.org/10.1002/jae.2476

Becker, R., W. Enders, and J. Lee. 2006. A stationarity test in the
presence of an unknown number of smooth breaks.
Journal of Time Series Analysis 27: 381-409.
https://doi.org/10.1111/j.1467-9892.2006.00478.x

Enders, W., and J. Lee. 2012. A unit root test using a Fourier series
to approximate smooth breaks.
Oxford Bulletin of Economics and Statistics 74: 574-599.
https://doi.org/10.1111/j.1468-0084.2011.00662.x

Guliyev, H. 2025. Heterogeneous panel data model with sharp and smooth
changes: Testing the green growth hypothesis in G7 countries.
Innovation and Green Development 4(3): 100245.
https://doi.org/10.1016/j.igd.2025.100245

Guliyev, H. 2026. Second-generation heterogeneous panel data model
with individual and common shocks. arXiv:2606.29063.

Pesaran, M. H. 2006. Estimation and inference in large heterogeneous
panels with a multifactor error structure. Econometrica 74: 967-1012.
https://doi.org/10.1111/j.1468-0262.2006.00692.x

Pesaran, M. H., and R. Smith. 1995. Estimating long-run relationships
from dynamic heterogeneous panels. Journal of Econometrics 68: 79-113.
https://doi.org/10.1016/0304-4076(94)01644-F

Author

Merwan Roudane

merwanroudane920@gmail.com

https://github.com/merwanroudane