sergiocorreia / reghdfe

Linear, IV and GMM Regressions With Any Number of Fixed Effects
http://scorreia.com/software/reghdfe/
MIT License
216 stars 57 forks source link
fixed-effects linear-models ols regression stata

REGHDFE: Linear Regressions With Multiple Fixed Effects

GitHub release (latest by date) GitHub Release Date GitHub commits since latest release (by date) StataMin DOI


Recent Updates

Things to be aware of:

Future/possible updates

Citation

reghdfe implements the estimator described in Correia (2017). If you use it, please cite either the paper and/or the command's RePEc citation:

@TechReport {Correia2017:HDFE,
  Author = {Correia, Sergio},
  Title = {Linear Models with High-Dimensional Fixed Effects: An Efficient and Feasible Estimator},
  Note = {Working Paper},
  Year = {2017},
}

Correia, Sergio. 2017. "Linear Models with High-Dimensional Fixed Effects: An Efficient and Feasible Estimator" Working Paper. http://scorreia.com/research/hdfe.pdf

Noah Constantine, Sergio Correia, 2021. reghdfe: Stata module for linear and instrumental-variable/GMM regression absorbing multiple levels of fixed effects. https://ideas.repec.org/c/boc/bocode/s457874.html

Install:

To find out which version you have installed, type reghdfe, version.

reghdfe 6.x is not yet in SSC. To quickly install it and all its dependencies, copy/paste these lines and run them:

* Install ftools (remove program if it existed previously)
cap ado uninstall ftools
net install ftools, from("https://raw.githubusercontent.com/sergiocorreia/ftools/master/src/")

* Install reghdfe 6.x
cap ado uninstall reghdfe
net install reghdfe, from("https://raw.githubusercontent.com/sergiocorreia/reghdfe/master/src/")

To run IV/GMM regressions with ivreghdfe, also run these lines:

cap ado uninstall ivreg2hdfe
cap ado uninstall ivreghdfe
cap ssc install ivreg2 // Install ivreg2, the core package
net install ivreghdfe, from(https://raw.githubusercontent.com/sergiocorreia/ivreghdfe/master/src/)

Alternatively, you can install the stable/older version from SSC (5.x):

cap ado uninstall reghdfe
ssc install reghdfe

Manual Install:

To install reghdfe to a firewalled server, you need to download these zip files by hand and extract them:

Then, run the following, adjusting the folder names:

cap ado uninstall ftools
cap ado uninstall reghdfe
cap ado uninstall ivreghdfe
net install ftools, from(c:\git\ftools)
net install reghdfe, from(c:\git\reghdfe)
net install ivreghdfe, from(c:\git\ivreghdfe)

Note that you can now also use Github releases in order to install specific versions.


Description

reghdfe is a Stata package that estimates linear regressions with multiple levels of fixed effects. It works as a generalization of the built-in areg, xtreg,fe and xtivreg,fe regression commands. It's objectives are similar to the R package lfe by Simen Gaure and to the Julia package FixedEffectModels by Matthieu Gomez (beta). It's features include:

Authors

Sergio Correia
Board of Governors of the Federal Reserve
Email: sergio.correia@gmail.com

Noah Constantine
Board of Governors of the Federal Reserve
Email: noahbconstantine@gmail.com

Acknowledgments

This package wouldn't have existed without the invaluable feedback and contributions of Paulo Guimaraes, Amine Ouazad, Mark E. Schaffer, Kit Baum and Matthieu Gomez. Also invaluable are the great bug-spotting abilities of many users.

Contributing

Contributors and pull requests are more than welcome. There are a number of extension possibilities, such as estimating standard errors for the fixed effects using bootstrapping, exact computation of degrees-of-freedom for more than two HDFEs, and further improvements in the underlying algorithm.

Note that all the code is written in the current-code folder, which then gets compiled by build.py into the src folder (which combines multiple files in single .ado and .mata files, so they can be installed and copied faster.