Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard errors attached to incorrect coefficients #94

Closed
NilsEnevoldsen opened this issue Apr 16, 2017 · 5 comments
Closed

Standard errors attached to incorrect coefficients #94

NilsEnevoldsen opened this issue Apr 16, 2017 · 5 comments

Comments

@NilsEnevoldsen
Copy link

NilsEnevoldsen commented Apr 16, 2017

. clear

. input w x y unity

             w          x          y      unity
  1. 1    -1.10565   -1.223344       1
  2. 1   -1.109139   -1.127615       1
  3. 0   -.8497003   -1.207231       1
  4. 1   -.2734231   -1.294683       1
  5. 0    .0063879   -.8343916       1
  6. 1    .7669702   -.8245103       1 
  7. end

. reghdfe y i.w##i.unity x, a(unity)
(converged in 1 iterations)
note: 1bn.w omitted because of collinearity
note: 1bn.unity omitted because of collinearity

HDFE Linear regression                            Number of obs   =          6
Absorbing 1 HDFE group                            F(   2,      3) =       2.07
                                                  Prob > F        =     0.2726
                                                  R-squared       =     0.6044
                                                  Adj R-squared   =     0.3407
                                                  Within R-sq.    =     0.6044
                                                  Root MSE        =     0.1666

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         1.w |          0   .1442878     0.00   1.000     -.459188     .459188
     1.unity |          0  (omitted)
             |
     w#unity |
        1 1  |   -.094956          .        .       .            .           .
             |
           x |   .2046129   .1006242     2.03   0.135    -.1156182    .5248439
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
       unity |         1           0           1     |
-----------------------------------------------------+

. reghdfe y i.unity##i.w x, a(unity)
(converged in 1 iterations)
note: 1bn.unity omitted because of collinearity
note: 1bn.unity#1bn.w omitted because of collinearity

HDFE Linear regression                            Number of obs   =          6
Absorbing 1 HDFE group                            F(   2,      3) =       2.29
                                                  Prob > F        =     0.2488
                                                  R-squared       =     0.6044
                                                  Adj R-squared   =     0.3407
                                                  Within R-sq.    =     0.6044
                                                  Root MSE        =     0.1666

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     1.unity |          0  (omitted)
         1.w |   -.094956   .1442878    -0.66   0.557     -.554144    .3642321
             |
     unity#w |
        1 1  |          0  (omitted)
             |
           x |   .2046129   .1006242     2.03   0.135    -.1156182    .5248439
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
       unity |         1           0           1     |
-----------------------------------------------------+

Note that reghdfe y i.w##i.unity x, a(unity) omits 1bn.w because of collinearity, but wrongly attaches the standard error of 1.w#1.unity to it.

Reversing the order of the interaction, as in reghdfe y i.unity##i.w x, a(unity), sidesteps the issue.

(This contrived example is a reduced testcase of a more meaningful regression I run that uses triple interactions.)

@sergiocorreia
Copy link
Owner

AFAIK, this is because the betas are computed with qrsolve() and the variance with invsym(), so they decide to drop different regressors.

If I compute inv(X'X) first and then use that to select the columns used to call qrsolve, this might sidestep the issue, but I still need to dig a bit deeper.

@sergiocorreia
Copy link
Owner

I just added a commit aimed at tackling this (it also fixes some corner-case bugs, and tries to be more methodical when dealing with omitted variables)

Let me know how it goes..

@NilsEnevoldsen
Copy link
Author

Great. Are you going to release, or should I install from GitHub?

@sergiocorreia
Copy link
Owner

GitHub. Release schedule on SSC is slower so until not much happens in terms of commits + issues), I will keep the old version there.

@NilsEnevoldsen
Copy link
Author

I think this fixed all my tables. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants