*! version 1.0.0 03jul2026

Title

xtfmg fccemg -- Fourier Common Correlated Effects Mean Group
(F-CCEMG) estimator

Syntax

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

kfreq(#) Fourier frequency k; default kfreq(1)

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

heteroplot forest plot of the unit-specific slopes

focus(varname) regressor shown in the heterogeneity plot;
default is the first independent variable

fourierplot plot the estimated unit-specific Fourier
components (the smooth breaks)

notable suppress the coefficient table

saving(filename) export the table in journal format
(.tex, .rtf/.doc, .csv or .txt)

title(string) caption for the exported table

replace overwrite the export file if it exists

The data must be xtset. An unbalanced panel is allowed;
periods missing for some units simply enter the cross-sectional averages
with fewer units.

Description

xtfmg fccemg estimates, for each unit i, the augmented regression

y_it = a_i + b_i' x_it + d_i' zbar_t + g_i sin(2 pi k t/T) + l_i cos(2 pi k t/T) + e_it,

where zbar_t = (ybar_t, xbar_t')' are the period-by-period cross-sectional
averages of the dependent variable and the regressors, and the sine and
cosine terms are a single-frequency Fourier basis with unit-specific
coefficients. The F-CCEMG estimate of the mean slope is the mean-group
average of the unit slope estimates, with the nonparametric Pesaran-Smith
(1995) variance

V = [N(N-1)]^-1 sum_i (b_i - b_MG)(b_i - b_MG)'.

The two augmentations act on orthogonal sources of variation: the
cross-sectional averages span and remove the common-factor component
(Pesaran 2006), while the unit-specific Fourier terms absorb idiosyncratic,
heterogeneously-timed structural breaks that the averages cannot reach
(Guliyev 2026). The estimator nests CCEMG (Fourier coefficients zero) and a
Fourier Mean Group regression (averages excluded) as special cases.

The reported sin and cos rows are the mean-group averages of the
unit-specific Fourier coefficients. Because breaks may differ in direction
across units, these averages can be insignificant even when the unit-level
Fourier terms matter; use fourierplot to inspect the unit paths.

Options

kfreq(#) sets the Fourier frequency k. The default, kfreq(1),
follows Becker, Enders and Lee (2006) and Enders and Lee (2012): a single
low frequency approximates one or two breaks of unknown timing and form
while adding only two regressors per unit. Higher frequencies can track more
elaborate break patterns but risk over-fitting the deterministic component,
a danger that is acute in small-T panels; a note is displayed for
kfreq() greater than 3.

level(#) sets the confidence level for the reported intervals and for
the plot whiskers; see [R] level.

heteroplot draws a forest plot of the unit-specific slope estimates on
the focus() variable, with unit-level confidence intervals and a
dashed line at the mean-group average. The graph is named
xtfmg_hetero.

focus(varname) selects the regressor displayed by heteroplot;
the default is the first independent variable.

fourierplot plots each unit's estimated deterministic Fourier
component g_i sin(2 pi k t/T) + l_i cos(2 pi k t/T) against time, making the
heterogeneously-timed smooth breaks directly visible. The graph is named
xtfmg_fourier.

notable suppresses the output table (useful in simulations); all
results remain available in r().

saving(filename) exports the coefficient table in publication format.
The format follows the file extension: .tex writes a LaTeX table with
booktabs rules (add \usepackage{booktabs} to the preamble) and
superscript significance stars; .rtf or .doc writes a Word table
in Times New Roman with journal-style horizontal rules; .csv and
.txt write delimited and aligned text. Coefficients carry stars,
standard errors appear in parentheses beneath, and notes report N, T, the
CD statistic and the star legend.

title(string) sets the caption of the exported table; a sensible
default is used if omitted.

replace permits saving() to overwrite an existing file.

Remarks

When to use F-CCEMG. The Monte Carlo evidence in Guliyev (2026) places
F-CCEMG first on root mean squared error in almost every configuration and
near-nominal 95% coverage once N is not minimal (N >= 10). It is the
estimator of choice in the intermediate regime -- moderate
cross-sectional dependence combined with individual, heterogeneously-timed
breaks -- which is typical of small country groups such as the G7,
the BRICS and the N-11. Run xtfmg map to locate your panel
on the regime map.

Small N caveat. The cross-sectional-average approximation underlying
all CCE-based estimators is asymptotic in N. With N below 10 the averages
are noisy proxies for the latent factors and the intervals are mildly
anti-conservative; report xtfmg fsurmg alongside as the
small-N comparator, as in the G7 application of the paper.

Consistency. The limiting distribution of F-CCEMG is not formally
established; consistency is inherited heuristically from CCE (the Fourier
terms are bounded deterministic functions of time and do not disturb the
factor-spanning argument) and is supported by the Monte Carlo evidence.

Units skipped. Units whose time series is too short for the augmented
regression (T_i <= k_x + k_x + 1 + 2 + 2, with k_x regressors) or whose
augmented design is collinear are skipped and reported in the header.

Stored results

xtfmg fccemg stores the following in r():

Scalars

r(N) number of panel units

r(N_used) units entering the mean-group average

r(N_skip) units skipped

r(Tbar) average time-series length

r(n) number of observations

r(k) number of regressors

r(kfreq) Fourier frequency

r(cd) Pesaran CD statistic (unit residuals)

r(cd_p) CD p-value

r(alpha) Bailey-Kapetanios-Pesaran CSD exponent (simple
estimator, standardized residuals)

Macros

r(estimator) fccemg

r(depvar) dependent variable

r(indepvars) independent variables

r(ivar) panel variable

r(tvar) time variable

Matrices

r(b) 1 x (k+2) mean-group estimates (slopes, sin, cos)

r(V) Pesaran-Smith variance matrix

r(bunit) N x (k+2) unit-specific estimates

r(seunit) N x (k+2) unit-specific standard errors

Examples

. webuse grunfeld, clear

. xtset company year

. xtfmg fccemg invest mvalue kstock

. xtfmg fccemg invest mvalue kstock, heteroplot focus(mvalue) fourierplot

. matrix list r(bunit)

References

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.

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.

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.

Pesaran, M. H., and R. Smith. 1995. Estimating long-run relationships
from dynamic heterogeneous panels. Journal of Econometrics 68: 79-113.

Author

Merwan Roudane

merwanroudane920@gmail.com

https://github.com/merwanroudane