*! version 1.0.0 16 Mar 2026
help ifete

Title

ifete -- estimation and inference of treatment effects in panel data with interactive fixed effects

Syntax

ifete depvar [indepvars],
treatvar(treatvarname)
[options]

Model
r(#) number of factors

iterate(#) maximum number of iterations

tolerance(tol) tolerance criterion for convergence

trend({0|1)} indicator of nonstationary trend

bootstrap(#) number of bootstrap samples

seed(int) seed used by the random number generator

Optimization
rmethod(criterion) method for estimating the number of factors

rmin(#) minimum number of factors

rmax(#) maximum number of factors

Reporting
citype({eq|sy)} type of reported confidence interval

frame(framename) create a Stata frame storing generated variables.

nofigure do not display figures

savegraph(prefix, [asis replace]) save all produced graphs to the current path.

xtset panelvar timevar must be used to declare a strongly panel dataset in the usual long form; see [XT] xtset.

depvar and indepvars must be numeric variables, and abbreviations are not allowed.

Description

ifete is designed for estimation and inference of treatment effects in panel data models with interactive fixed effects.
As a major extension of two-way fixed effects, interactive fixed effects provide a flexible way to construct counterfactual predictions for causal inference.
The ifete command implements the tall-wide algorithm for efficient estimation of treatment effects (Bai and Ng, 2021, Journal of the American Statistical Association),
while using residual-based wild bootstrap for valid inference (Li, Shen and Zhou, 2024, Journal of Econometrics).
This command presents point estimates of treatment effects as well as confidence intervals and p-values for inference, while covariates and nonstationary trends are allowed.
See Yan et al. (2026) for details.

Required Settings

The outcome variable depvar and treatment variable treatvarname must be specified. Covariates indepvars can be included to improve the efficiency of estimation.
If treatvarname indicates staggered treatments (i.e., differential initial treatment timing for different units),
ifete automatically identifies the number of pretreatment periods when all units are untreated as T0 (the height of the wide block) and the number of control units as N0 (the width of the tall block).

treatvar(treatvarname) specifies a binary treatment variable indicating whether units are exposed to the treatment of interest in given periods.
The treatment variable takes the value of 1 if the unit is treated in that period and 0 otherwise.
The specification of the treatment variable allows ifete to distinguish between treated and control units, as well as pretreatment and posttreatment periods.
This distinction is necessary for constructing the "wide block" and "tall block" matrices, which are fundamental components of the tall-wide algorithm for estimating treatment effects.
The "wide block" matrix contains pretreatment observations for all units, while the "tall block" matrix contains observations for control units across all periods.

Options

Model

r(#) specifies the number of factors. # must be a positive integer that lies within the interval [1, min(T0 - 1, N0 - 1)],
where T0 denotes the number of pretreatment periods when all units are untreated, and N0 denotes the number of control units.
If the option r(#) is not specified, ifete uses data-driven methods to estimate the number of factors through the options rmethod(criterion), rmin(#) and rmax(#).

iterate(#) specifies the maximum number of iterations allowed in estimating the interactive fixed effects by the LSPC estimator (Bai, 2009) iterating between least squares (LS) and principal components (PC).
The default is 1000.

tolerance(tol) specifies the convergence tolerance threshold tol for estimating the interactive fixed effects by the LSPC estimator.
Specifically, ifete calculates the L2 norm (Euclidean norm) of the difference between the coefficient estimates obtained in two successive iterations.
The procedure stops if the L2 norm difference falls below the specified tolerance threshold tol.
tol should be set to a small positive real number, which defaults to 0.0001.

trend({0|1}) specifies an indicator of nonstationary trends.
trend(0) indicates stationary data, while trend(1) indicates nonstationary factors and/or covariates following the unit root process.
The default is trend(0).

bootstrap(#) specifies the number of bootstrap samples used for constructing confidence intervals of treatment effects and the related p-values.
# should be set to a positive large integer, which defaults to 500.

seed(int) specifies the seed used by the random number generator for reproducible results, which defaults to 1.

Optimization

If the number of factors is not specified using the option r(#), ifete provides the following methods to estimate the number of factors:
leave-one-out cross validation (loo) (Xu, 2017),
twice K-fold cross validation (cv or cv(K J)) (Wei and Chen, 2020),
Bai and Ng's information criteria (pc1, pc2, pc3, ic1, ic2, ic3) (Bai and Ng, 2002),
and Ahn and Horenstein's eigenvalue ratio (er) and growth ratio (gr) criteria (Ahn and Horenstein, 2013).

rmethod(criterion) specifies the method used to determine the number of factors.
criterion should be one of loo, cv, cv(K J), pc1, pc2, pc3, ic1, ic2, ic3, er, or gr.
The default is rmethod(loo).

loo (default) specifies leave-one-out cross validation (Xu, 2017), which selects the number of factors by minimizing the mean squared prediction error.

cv or cv(K J) specifies the twice K-fold cross validation (Wei and Chen, 2020) for selecting the number of factors.
The tall block is split into K folds in the time dimension and J folds in the cross-sectional dimension.
For each candidate number of factors, the method computes the summed squared prediction error over all held-out blocks and selects the value that minimizes this criterion.
If cv is specified without arguments, the default is K = T and J = N0.
cv(K J) may also be specified, where 1 <= K <= T and 1 <= J <= N0.

pc1, pc2, pc3, ic1, ic2 or ic3 specifies Bai and Ng's information criteria (Bai and Ng, 2002),
which minimize the sum of squared residuals in addition to a penalty term that increases with the number of factors.

er or gr specifies Ahn and Horenstein's eigenvalue-based criteria (Ahn and Horenstein, 2013),
which determine the number of factors by examining the ratio of adjacent eigenvalues, with er relying on the eigenvalue ratio and gr on the growth ratio.

rmin(#) specifies the minimum number of factors considered by rmethod(criterion), which defaults to 1.
# must be a positive integer less than or equal to the maximum number of factors specified by rmax(#).

rmax(#) specifies the maximum number of factors considered by rmethod(criterion), which defaults to 10.
# must be a positive integer that lies within the interval [1, min(T0 - 1, N0 - 1)], where T0 denotes the number of pretreatment periods when all units are untreated, and N0 denotes the number of control units.
It is recommended to further increase rmax(#) if it turns out to be the same as the optimal number of factors chosen.

Reporting

citype({eq|sy}) specifies the type of reported confidence intervals of predicted outcomes and treatment effects.
citype(eq) corresponds to the equal tailed confidence interval, and citype(sy) corresponds to the symmetric confidence interval. The default is citype(eq).

frame(framename) creates a Stata frame storing generated variables including counterfactual predictions, treatment effects, 90%, 95%, 99% confidence intervals of predicted outcomes and treatment effects,
and p-values of treatment effects. The frame named framename is replaced if it already exists, or created if not.

nofigure do not display figures. The default is to display all figures for estimation results.

savegraph(prefix, [asis replace]) automatically and iteratively calls the graph save to save all produced graphs to the current path,
where prefix specifies the prefix added to _graphname to form a file name,
that is, the graph named graphname is stored as prefix_graphname.gph.
asis and replace are options passed to graph save; for details, see [G-2] graph save.
Note that this option only applies when nofigure is not specified.

Example 1: estimating the impact of economic integration between Hong Kong and mainland China in 2004q1 (Hsiao et al., 2012)

. use growth2, clear

. xtset region time

* Visualize the configuration of the treatment variable "ei" for economic integration in panel data (panelview has been installed from SSC)

. panelview gdp ei, i(region) t(time) type(treat)

* Implement factor-based estimation and create a Stata frame "growth_ei" storing generated variables including treatment effects and confidence intervals

. ifete gdp, treatvar(ei) frame(growth_ei)

* Change to the generated Stata frame "growth_ei" containing the results

. frame change growth_ei

. describe, simple

* Change back to the default Stata frame

. frame change default

Example 2: estimating the effect of California's tobacco control program (Abadie, Diamond, and Hainmueller 2010)

. use smoking2, clear

. xtset state year

* Visualize the treatment structure for California's tobacco control program

. panelview cigsale ctcp, i(state) t(year) type(treat)

* Implement factor-based estimation for a model with covariates and a nonstationary trend using eigenvalue ratio criterion (er)

. ifete cigsale lnincome eduattain poverty, treatvar(ctcp) trend(1) rmethod(er)

* List the names and values of the macros, scalars and matrix stored in e()

. ereturn list

Stored results

rcm stores the following in e():

Scalars

e(N) number of observations used in coefficient estimation

e(df_r) degrees of freedom for t-statistics of coefficient estimates

e(r) number of factors

e(T) total number of periods

e(T0) number of pretreatment periods without treatment across all units

e(T1) number of posttreatment periods with at least one treated unit

e(G) total number of units

e(G0) number of control units

e(G1) number of treated units

e(mse) mean squared error of the fitted model

e(rmse) root mean squared error of the fitted model

e(r2) R-squared of the fitted model

Macros

e(panelvar) name of panel variable

e(timevar) name of time variable

e(varlist) names of dependent variable and independent variables

e(depvar) names of dependent variable

e(indepvars) names of independent variables

e(trend) indicator for the presence of nonstationary trends

e(cmd) ifete

e(cmdline) command as typed

e(seed) seed used by the random number generator for reproducible results

e(frame) name of Stata frame storing generated variables

e(graph) names of all produced graphs

e(properties) b V

Matrices

e(b) coefficient vector of the model fitted

e(V) variance-covariance matrix of the coefficient estimates

e(Ftall) common factors matrix estimated from the tall block

e(Ltall) factor loadings matrix estimated from the tall block

e(Fwide) common factors matrix estimated from the wide block

e(Lwide) factor loadings matrix estimated from the wide block

Reference

Bai, Jushan and Serena Ng. 2002. Determining the number of factors in approximate factor models. Econometrica 70(1): 191-221.

Bai, Jushan. 2009. Panel data models with interactive fixed effects. Econometrica 77(4): 1229-1279.

Ahn, Seung C. and Alex R. Horenstein. 2013. Eigenvalue ratio test for the number of factors.
Econometrica 81(3): 1203-1227.

Xu, Yiqing. 2017. Generalized synthetic control method: Causal inference with interactive fixed effects models. Political Analysis 25(1): 57–76.

Wei, Jie, and Hui Chen. 2020. Determining the Number of Factors in Approximate Factor Models by Twice K-fold Cross Validation. Economics Letters 191: 109149.

Bai, Jushan, and Serena Ng. 2021. Matrix completion, counterfactuals, and factor analysis of missing data. Journal of the American Statistical Association 116(536): 1746-1763.

Li, Xingyu, Yan Shen, and Qiankun Zhou. 2024. Confidence Intervals of Treatment Effects in Panel Data Models with Interactive Fixed Effects. Journal of Econometrics 240(1): 105684.

Yan, Guanpeng, Qiang Chen, Xingyu Li, Yan Shen and Qiankun Zhou. 2026.
ifete: Estimation and inference of treatment effects via interactive fixed effects. Working Paper.

Author

Guanpeng Yan, Shandong University of Finance and Economics

guanpengyan@yeah.net

Qiang Chen (corresponding author), Shandong University

qiang2chen2@126.com

Xingyu Li, Zhejiang University

lixyecon@zju.edu.cn

Yan Shen, Peking University

yshen@phbs.pku.edu.cn

Qiankun Zhou, Louisiana State University

qzhou@lsu.edu