We present an algorithm to estimate the two-way fixed effect linear model. The algorithm relies on the Frisch-Waugh-Lovell theorem and applies to ordinary least squares (OLS), two-stage least squares (TSLS) and generalized method of moments (GMM) estimators. The coefficients of interest are computed using the residuals from the projection of all variables on the two sets of fixed effects. Our algorithm has three desirable features. First, it manages memory and computational resources efficiently which speeds up the computation of the estimates. Second, it allows the researcher to estimate multiple specifications using the same set of fixed effects at a very low computational cost. Third, the asymptotic variance of the parameters of interest can be consistently estimated using standard routines on the residualized data.
Abowd, J. M., F. Kramarz, and D. N. Margolis (1999): “High Wage Workers and High Wage Firms,” Econometrica 67 (2): 251–333.
Arellano, M. 1987. “Computing Robust Standard Errors for Within-Groups Estimators.” Oxford Bulletin of Economics and Statistics 49 (4): 431–434.
Baum, C. F., M. E. Schaffer, and S. Stillman. 2007. “Enhanced Routines for Instrumental Variables/GMM Estimation and Testing.” Stata Journal 7 (4): 465–506.
Carneiro, A., P. Guimares, and P. Portugal (2012): “Real Wages and the Business Cycle: Accounting for Worker, Firm, and Job Title Heterogeneity,” American Economic Journal: Macroeconomics 4(2): 133–152.
Cornelissen, T. 2008. “The Stata Command Felsdvreg to Fit a Linear Model with Two High-Dimensional Fixed Effects.” Stata Journal 8 (2): 170–189.
Correia, S. 2014. “REGHDFE: Stata Module to Perform Linear or Instrumental-Variable Regression Absorbing Any Number of High-Dimensional Fixed Effects,” Statistical Software Components S457874, Boston College Department of Economics.
Davis, P. 2002. “Estimating Multi-Way Error Components Models with Unbalanced Data Structures.” Journal of Econometrics 106 (1): 67–95.
Frisch, R., and F. V. Waugh. 1933. “Partial Time Regressions as Compared with Individual Trends.” Econometrica 1 (4): 387–401.
Gaure, S. 2013a. “Lfe: Fitting Linear Models with Multiple Factors with Many Levels.” The R Journal 5(2): 104–116.
Gaure, S. 2013b. “OLS with Multiple High Dimensional Category Variables.” Computational Statistics & Data Analysis 66: 8–18.
Giles, D. E. A. 1984. “Instrumental Variables Regressions Involving Seasonal Data.” Economics Letters 14 (4): 339–343.
Guimaraes, P. 2009. “REG2HDFE: Stata Module to Estimate a Linear Regression Model with two High Dimensional Fixed Effects,” Statistical Software Components S457101, Boston College Department of Economics.
Guimaraes, P., and P. Portugal. 2010. “A Simple Feasible Procedure to Fit Models with High-Dimensional Fixed Effects.” Stata Journal 10 (4): 628–649.
Hayashi, F. 2000. Econometrics. Princeton: Princeton University Press.
Lovell, M. C. 1963. “Seasonal Adjustment of Economic Time Series and Multiple Regression Analysis.” Journal of the American Statistical Association 58 (304): 993–1010.
Lovell, M. C. 2008. “A Simple Proof of the FWL Theorem.” The Journal of Economic Education 39 (1): 88–91.
Ouazad, A. 2008. “A2REG: Stata Module to Estimate Models with Two Fixed Effects,” Statistical Software Components S456942, Boston College, Department of Economics.
Stock, J. H., and M. W. Watson. 2008. “Heteroskedasticity-Robust Standard Errors for Fixed Effects Panel Data Regression.” Econometrica 76 (1): 155–174.
Wansbeek, T., and A. Kapteyn. 1989. “Estimation of the Error-Components Model with Incomplete Panels.” Journal of Econometrics 41 (3): 341–361.
Wooldridge, J. M. 2010. Econometric Analysis of Cross Section and Panel Data. 2nd ed. Cambridge, Mass: The MIT Press.
The Journal of Econometric Methods aims to bridge the widening gap between econometric research and empirical practice. It publishes papers from top scholars in all areas of econometrics that consider a topic of broad interest to practitioners and are written in a style that is targeted at practitioners.