*! version 1.0 05jan2026

*! Manh Hoang-Ba, hbmanh9492@gmail.com

Title

xtgmmfa -- performs GMM estimation for fixed-T factor-augmented panel data model

Syntax

xtgmmfa depvar [indepvars] [if] [in] [, options]

Description

xtgmmfa performs GMM estimation for fixed-T panel data model with multifactor structural errors and the presence of endogenous variables.
The underlying methodology involves approximating the unobserved common factors using observed factor proxies. The resulting moment conditions are linear in the parameters. See Juodis and Sarafidis (2022) for more details.

options

Model
* gmmvars(varlist [, mlag(#)]) specifies variables with lags used to construct the GMM-style collumns in instrument matrix. mlag(#) specifies the maximum lag order used for all variables.

ivvars(varlist) specifies variables used to construct the IV-style collumns in instrument matrix.

unofactors(unof_spec) specifies the specification of the factor proxies selection or estimation step.

obsfactors(varlist) specifies observed factors with unit-specific factor loadings. Specifying too many observed factors may lead to identification problems.

wmatrix(1|2) specifies initial weighting matrix: 1 = indentity matrix, 2 = Z'Z matrix (default).

onestep use the one-step estimator.

noconstant suppress constant term.

SE/Robust
robust use robust standard errors; for two-step GMM, apply the Windmeijer (2005) correction.

cluster(varname) computes cluster-robust standard errors. This option does not affect one-step coefficients, but affects one-step standard errors and both coefficients and standard errors in two-step GMM.

small make degrees-of-freedom adjustment and report small-sample statistics.

Reporting
level(#) set confidence level; default is level(95).

* These options is required.

unof_spec is

Vlist [, wvar(varname) regu bss type(1|2|3) lmax(#) seed(#) power(#) er noregressor]

unof_spec

Vlist includes time-varying variables, assumed to be drived by factors inside (as well as outside) the model. These variables are used to construct the vector v_i in equation (11) and V_i in equation (17) in Juodis and Sarafidis (2022). In addition, xtgmmfa automatically adds time-varying regressors (y, X) after Vlist. Therefore, Vlist can be empty.

wvar(varname) specifies a variable to be used in constructing the weight vector wi in formulas (12) and (16) in Juodis and Sarafidis (2022). When wvar is empty, xtgmmfa automatically uses the dependent variable.

regu uses the Regularization method to estimate the number of factor proxies. This is default.

bss uses the Best-Subset Selection method (BSS) instead of the Regularization. bss selects the factor proxies vector and the number of factor proxies from a set of available factors, by estimating feasible models and finding the model with the smallest BIC. This procedure is time-consuming when using type(3) options.

type(#) specifies how to combines V_i and W_i in constructing the set of available factors. type(1) uses the first variable in Vlist and multiple weights w_i, type(2) uses all variables in Vlist and single weight, type(3) combines both.

lmax(#) specifies the maximum number of factor proxies to be searched in the BSS method; default is lmax(2).

seed(#) seed specifies the seed used to generate the Rademacher random variable when regu is specified; default is seed(120).

power(#) specifies the power to calculate the single weights from the variable in wvar; default is seed(120).

er uses the Eigenvalue Ratio statistic instead of the Growth Ratio (default) in estimating the number of factor proxies when the regu is specified.

noregressor prevents xtgmmfa from automatically adding regression variables to Vlist.

You must xtset your data before using xtgmmfa; see [XT] xtset.

All varlists may contain factor variables; see fvvarlist.

depvar and all varlists may contain time-series operators; see tsvarlist.

xtgmmfa is a community-contributed program. The current version requires Stata version 11 or higher.

Example

Water data (Juodis and Sarafidis, 2022)

. use js22data, clear

Regularization: column M_F of table 1 in Juodis and Sarafidis (2022)

. xtgmmfa l(0/1).lcons price rain temp, gmm(l.lcons l.price rain temp) unof(smi, type(1)) nocons wmat(1)

Best-Subset Selection: column M1_c of table 1 in Juodis and Sarafidis (2022)

. xtgmmfa l(0/1).lcons price rain temp, gmm(l.lcons l.price rain temp) unof(smi, bss type(1) lmax(4)) nocons wmat(1)

Arellano-Bond data

. webuse abdata, clear

One-step GMM with robust standard errors

. xtgmmfa l(0/1).n k w ys, gmm(l.n l.k l.w l.ys) one r

Two-step GMM with Windmeijer-corrected robust standard errors

. xtgmmfa l(0/1).n k w ys, gmm(l.n l.k l.w l.ys) r

Saved results

xtgmmfa saves the following in e():

Scalars

e(N) number of observations

e(N_g) number of groups

e(Tmin) smallest group size

e(Tavg) average group size

e(Tmax) largest group size

e(k) number of interested parameters

e(r_ga) number of estimated parameters

e(j) number of instruments

e(j_s) Sargan/Hansen's J statistic

e(j_p) Sargan/Hansen's J p-value

e(j_df) Sargan/Hansen's J degrees-of-freedom

e(df_m) Model degrees of freedom

e(df_r) residual degrees of freedom (if small not specified)

e(chi2) Wald chi-squared statistic (if small not specified)

e(chi2p) chi-squared p-value (if small not specified)

e(F) F statistic (if small specified)

e(F_p) F p-value (if small specified)

e(Le) Le is estimated/selected

e(bic) Bayesian information criterion

e(type) Type of method to constructing factor proxies

e(N_clust) number of clusters

Macros

e(cmd) xtgmmfa

e(cmdline) command as typed

e(ivar) variable denoting groups

e(tvar) variable denoting time

e(method) method to determine the number of factor proxies

e(stat_note) statistic to determine the number of factor proxies

e(gmmstep) one-step or two-steps GMMteffects

e(vcetype) title used to label Std. Err.

e(clustvar) name of cluster variable

e(small) "small" for small

e(properties) b V

e(depvar) name of dependent variable

Matrices

e(b) interested coefficient vector

e(V) variance-covariance matrix of the interested estimators

e(theta) coefficient vector

e(Vtheta) variance-covariance matrix of the estimators

e(S) lag selection matrix to contruct instrument matrix

e(Fe_hat) factor proxies matrix

Functions

e(sample) marks estimation sample

Version updates

To update the xtgmmfa package to the latest version, run either of the following commands

. `"ssc install xtgmmfa, replace"'

. //raw.githubusercontent.com/ManhHB94/xtgmmfa/main/") replace"'

Author

Manh Hoang-Ba, https://manhb94econometrics.wordpress.com/

hbmanh9492@gmail.com

Acknowledgement

I would like to express my sincere gratitude to Arturas Joudis and Vasilis Sarafidis, who developed the linear GMM approach for this class of models. The implementation of xtgmmfa benefited substantially from the MATLAB code provided with their research.

References

Juodis, A., & Sarafidis, V. (2022). A linear estimator for factor-augmented fixed-T panels with endogenous regressors. Journal of Business & Economic Statistics, 40(1), 1-15.

Windmeijer, F. 2005.
A finite sample correction for the variance of linear efficient two-step GMM estimators.
Journal of Econometrics 126: 25-51.