sergiocorreia / ivreghdfe

Run IV/2SLS with many levels of fixed effects (i.e. ivreg2+reghdfe)
MIT License
82 stars 29 forks source link

"Warning: *variance matrix is nonsymmetric or highly singular" with reghdfe #47

Open PaulaSpinola opened 2 years ago

PaulaSpinola commented 2 years ago

I would like to absorb time FE in my regression as well as include a categorical variable among my explanatory variables (for age brackets).

When including age bracket FE as a regressor and absorbing time FE, I get the following message: "Warning: *variance matrix is nonsymmetric or highly singular" and SE are not estimated.

However, when running the exact same model while absorbing both time FE and age bracket FE I get no warning and all SE are estimated. Is it same to use these results?

PS: I am specifying robust standard errors in both estimations mentioned above. The same happens when I specify clustered standard errors for both estimations. This issue only does not happen when my standard errors are neither clustered, nor robust.

. ********************* I get the warning message when I estimate coefficients for age bracket and absorb time FE
. reghdfe avg_peer_cost iv_age iv_fem iv_uni pat_fem pat_age i.age_int, absorb(ym) vce(robust)
(MWFE estimator converged in 1 iterations)
Warning:  variance matrix is nonsymmetric or highly singular

HDFE Linear regression                            Number of obs   =  7,148,998
Absorbing 1 HDFE group                            F(  21,7148887) =   10378.63
                                                  Prob > F        =     0.0000
                                                  R-squared       =     0.0330
                                                  Adj R-squared   =     0.0330
                                                  Within R-sq.    =     0.0292
                                                  Root MSE        =  2096.0537

----------------------------------------------------------------------------------
                 |               Robust
   avg_peer_cost |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-----------------+----------------------------------------------------------------
          iv_age |  -31.59436          .        .       .            .           .
          iv_fem |    411.207          .        .       .            .           .
          iv_uni |   738.8013          .        .       .            .           .
         pat_fem |  -386.0751          .        .       .            .           .
         pat_age |   10.79922          .        .       .            .           .
                 |
         age_int |
 20 to 25 years  |  -1180.342          .        .       .            .           .
 25 to 30 years  |  -1009.705          .        .       .            .           .
 30 to 35 years  |  -795.4957          .        .       .            .           .
 35 to 40 years  |  -708.4765          .        .       .            .           .
 40 to 45 years  |  -698.3601          .        .       .            .           .
 45 to 50 years  |   -755.683          .        .       .            .           .
 50 to 55 years  |  -831.5416          .        .       .            .           .
 55 to 60 years  |  -909.2266          .        .       .            .           .
 60 to 65 years  |  -979.1657          .        .       .            .           .
 65 to 70 years  |  -935.7501          .        .       .            .           .
 70 to 75 years  |  -788.7044          .        .       .            .           .
 75 to 80 years  |  -607.2163          .        .       .            .           .
 80 to 85 years  |  -902.8926          .        .       .            .           .
 85 to 90 years  |  -975.3231          .        .       .            .           .
 90 to 95 years  |  -864.3475          .        .       .            .           .
95 to 100 years  |  -177.4297          .        .       .            .           .
                 |
           _cons |   3718.518          .        .       .            .           .
----------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
          ym |        90           0          90     |
-----------------------------------------------------+
. 
.********************* I don't get the warning any longer when I absorb the coefficients of age brackets together with time FE
. reghdfe avg_peer_cost iv_age iv_fem iv_uni pat_fem pat_age, absorb(ym age_int) vce(robust)
(MWFE estimator converged in 4 iterations)

HDFE Linear regression                            Number of obs   =  7,148,998
Absorbing 2 HDFE groups                           F(   5,7148887) =   39389.47
                                                  Prob > F        =     0.0000
                                                  R-squared       =     0.0330
                                                  Adj R-squared   =     0.0330
                                                  Within R-sq.    =     0.0260
                                                  Root MSE        =  2096.0537

------------------------------------------------------------------------------
             |               Robust
avg_peer_c~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      iv_age |  -31.59436   .2484534  -127.16   0.000    -32.08132    -31.1074
      iv_fem |    411.207   8.263385    49.76   0.000      395.011    427.4029
      iv_uni |   738.8013   4.091539   180.57   0.000      730.782    746.8205
     pat_fem |  -386.0751   2.196373  -175.78   0.000    -390.3799   -381.7703
     pat_age |   10.79922   .0335185   322.19   0.000     10.73353    10.86492
       _cons |   2902.447   12.48775   232.42   0.000     2877.971    2926.922
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
          ym |        90           0          90     |
     age_int |        17           1          16     |
-----------------------------------------------------+
NARAYANKRISHNA1 commented 1 year ago

In my case, I used the second regression and I still get the same result as of first. Could you please suggest me on what should I do? Thanks.