The command regife estimates models with interactive fixed effects following Bai (2009).
For an observation i, denote (jλ(i), jf(i)) the associated pair (id x time). The command estimates models of the form
The model is estimated by least square, i.e. by finding the coefficients β, of factors (f1, .., fr) and of loadings (λ1, ..., λr) that minimize
regife requires a formula and the option factors, that specifies the id variable, the time variable, and the dimension:
insheet "data/cigar.csv", clear
regife sales price, f(state year, 3)
You can impose id and/or time fixed effect by estimating models of the form
Just use the option absorb along with the option factors:
regife sales price, f(state year, 2) a(state year)
The command handles unbalanced panels (ie missing observation for a given id, time) as described in the appendix of Bai 2009.
Weights are supported but should be constant within id
Save loadings and/or factors by specifying new variable names at the left hand side of =
regife sales price, a(fe_state=state) f(ife_state=state ife_year=year, 2)
To save residuals, use the option residuals
regife sales price, f(state year, 2) residuals(newres)
Time fixed effects allow to control for aggregate shocks that impact individuals in the same way. Interactive fixed effects allow to control for aggregate shocks that impact individuals in different ways, as long as this heterogeneity is constant accross time.
You can find such models in the following articles:
- Eberhardt, Helmers, Strauss (2013) Do spillovers matter when estimating private returns to R&D?
- Hagedorn, Karahan, Movskii (2015) Unemployment Benefits and Unemployment in the Great Recession: The Role of Macro Effects
- Hagedorn, Karahan, Movskii (2015) The impact of unemployment benefit extensions on employment: the 2014 employment miracle?
- Totty (2015) The Effect of Minimum Wages on Employment: A Factor Model Approach
The vce option is passed to a regression of y on x and covariates of the form i.id#c.year and i.year#c.id. You can use any vce option availbe in reghdfe. This way of computing standard errors is hinted in section 6 of of Bai (2009).
regife sales price, f(state year, 2) a(state year) vce(cluster state)
That being said, personal Monte carlo evidence suggest to bootstrap the standard errors for small T.
regife sales price, f(state year, 2) vce(bootstrap, reps(100))
regife sales price, f(state year, 2) vce(bootstrap, cluster(state))
As proven in Moon Weidner (2015), overestimating the number of factors still returns consistent estimates: irrelevant factors behave similarly to irrelevant covariates in a traditional OLS. A rule of thumb is to check that your estimate stays constant when you add more factors.
In presence of cross or time correlation beyond the factor structure, the estimate for beta is biased (but still consistent): see Theorem 3 in Bai 2009, which derives the correction term in special cases. However, regife does not implement any correction. You may want to add enough factors until residuals are approximately i.i.d.
- Start the convergence at a given
betausingbstart. - Decrease the
tolerance(default to 1e-9) ormaxiteration(default to 10000). - The algorithm used in
regiferequires a lot of iterations when interactive fixed effects are correlated with the RHS variable. This meansregifeis slow exactly in those cases where the interactive fixed effect estimates substantially differ from the OLS estimates. For the same reason, adding id or time fixed effects generally makes the convergence much faster. - I've written a similar command in Julia, which is more than 100x faster
For models with fixed effect, an equivalent way to obtain β is to first demean regressors within groups and then regress y on these residuals instead of the original regressors.
In contrast, this method does not work with models with interactive fixed effects. While fixed effects are linear projections (so that the Frisch-Waugh-Lovell theorem holds), factor models are non linear projections.
regife is now available on ssc. It requires reghdfe
ssc install reghdfe
ssc install regife
To install the latest version on Github
-
with Stata13+
net install regife, from(https://github.com/matthieugomez/stata-regife/raw/master/) -
with Stata 12 or older, download the zipfiles of the repositories and run in Stata the following commands:
net install regife, from("SomeFolderRegife")


