REGHDFE | Quick Start Guide

Basic Syntax

  1. The basic syntax of reghdfe is the same as areg. Thus,

    . areg depvar indepvars, absorb(absvar)

    Becomes:

    . reghdfe depvar indepvars, absorb(absvar1 absvar2 …)

  2. With IV/GMM regressions, use the ivregress and ivreg2 syntax:

    . reghdfe depvar indepvars (endogvars=iv_vars), absorb(absvars)

  3. Similarly, for robust standard errors:

    . reghdfe depvar indepvars , absorb(absvars) vce(robust)

    . reghdfe depvar indepvars , absorb(absvars) vce(cluster clustervars)

Examples

Estimate an OLS Regression with two levels of fixed effects

. sysuse auto
(1978 Automobile Data)

. reghdfe price weight length, absorb(turn trunk)
(dropped 9 singleton observations)
(converged in 12 iterations)

HDFE Linear regression                            Number of obs   =         65
Absorbing 2 HDFE groups                           F(   2,     38) =      12.85
                                                  Prob > F        =     0.0001
                                                  R-squared       =     0.6403
                                                  Adj R-squared   =     0.3942
                                                  Within R-sq.    =     0.4035
                                                  Root MSE        =  2254.6288

------------------------------------------------------------------------------
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      weight |   5.688144   1.302818     4.37   0.000     3.050727    8.325561
      length |  -44.21191   57.60797    -0.77   0.448    -160.8332    72.40933
-------------+----------------------------------------------------------------
    Absorbed |         F(24, 38) =      1.548   0.110             (Joint test)
------------------------------------------------------------------------------

Absorbed degrees of freedom:
---------------------------------------------------------------+
 Absorbed FE |  Num. Coefs.  =   Categories  -   Redundant     | 
-------------+-------------------------------------------------|
        turn |           13              13              0     | 
       trunk |           12              13              1     | 
---------------------------------------------------------------+

Estimate an OLS Regression with two-way clustering

. reghdfe price weight length, absorb(turn trunk) vce(cluster turn trunk)
(dropped 9 singleton observations)
(converged in 12 iterations)

HDFE Linear regression                            Number of obs   =         65
Absorbing 2 HDFE groups                           F(   2,     12) =      16.59
Statistics robust to heteroskedasticity           Prob > F        =     0.0004
                                                  R-squared       =     0.6403
                                                  Adj R-squared   =     0.3778
Number of clusters (turn)    =         13         Within R-sq.    =     0.4035
Number of clusters (trunk)   =         13         Root MSE        =  2284.8937

                            (Std. Err. adjusted for 13 clusters in turn trunk)
------------------------------------------------------------------------------
             |               Robust
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      weight |   5.688144   2.837967     2.00   0.068    -.4952552    11.87154
      length |  -44.21191   87.68177    -0.50   0.623    -235.2541    146.8302
------------------------------------------------------------------------------

Absorbed degrees of freedom:
---------------------------------------------------------------+
 Absorbed FE |  Num. Coefs.  =   Categories  -   Redundant     | 
-------------+-------------------------------------------------|
        turn |            0              13             13 *   | 
       trunk |            0              13             13 *   | 
---------------------------------------------------------------+
* = fixed effect nested within cluster; treated as redundant for DoF computation

Estimate an IV regression

. reghdfe price weight (length = gear), absorb(turn trunk)
(dropped 9 singleton observations)
(converged in 12 iterations)

HDFE IV (2SLS) estimation
-------------------------

Estimates efficient for homoskedasticity only
Statistics consistent for homoskedasticity only

                                                      Number of obs =       65
                                                      F(  2,    38) =    12.22
                                                      Prob > F      =   0.0001
Total (centered) SS     =  323844734.5                Centered R2   =   0.6293
Total (uncentered) SS   =  323844734.5                Uncentered R2 =        .
Residual SS             =    199090229                Root MSE      =     2289

------------------------------------------------------------------------------
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      length |  -106.3953   407.0322    -0.26   0.795    -930.3889    717.5984
      weight |   6.578179   5.915196     1.11   0.273    -5.396509    18.55287
------------------------------------------------------------------------------
Underidentification test (Anderson canon. corr. LM statistic):           1.342
                                                   Chi-sq(1) P-val =    0.2467
------------------------------------------------------------------------------
Weak identification test (Cragg-Donald Wald F statistic):                0.801
Stock-Yogo weak ID test critical values: 10% maximal IV size             16.38
                                         15% maximal IV size              8.96
                                         20% maximal IV size              6.66
                                         25% maximal IV size              5.53
Source: Stock-Yogo (2005).  Reproduced by permission.
------------------------------------------------------------------------------
Sargan statistic (overidentification test of all instruments):           0.000
                                                 (equation exactly identified)
------------------------------------------------------------------------------
Instrumented:         length
Included instruments: weight
Excluded instruments: gear_ratio
------------------------------------------------------------------------------

Absorbed degrees of freedom:
---------------------------------------------------------------+
 Absorbed FE |  Num. Coefs.  =   Categories  -   Redundant     | 
-------------+-------------------------------------------------|
        turn |           13              13              0     | 
       trunk |           12              13              1     | 
---------------------------------------------------------------+

If you also want the first stage or the OLS version of this regression, check out the stages(...) option (which also supports the reduced form and the “acid” version).