Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • xtreg, fe with/without robust and cluster options.

    Dear Statalist users,


    I have the following situation - I run three versions of xtreg on dataset with uneven panels (ID) and gaps in time (Time):

    Code:
    xtset ID Time
    
    */ 1
    xtreg y x1 x2 x3, fe
    
    */ 2
    xtreg y x1 x2 x3, fe vce(robust)
    
    */ 3
    xtreg y x1 x2 x3, fe cluster(ID)

    All three give me exactly the same (identical) results. Digging in the Internet I found out that using "robust" automatically adds "cluster" when FE option is specified, but it still does not explain why all 3 are the same.

    P.S.
    just to be sure I didn't make any mistake in a code, I also run

    Code:
    xtreg y x1 x2 x3, fe vce(conventional)
    and in this case results are very similar, but not identical.

    P.S.2
    What is the difference between:
    Code:
    xtreg y x1 x2 x3, fe vce(cluster ID)
    and
    Code:
    xtreg y x1 x2 x3, fe cluster(ID)
    Last edited by Constantin Alba; 25 May 2017, 07:03.

  • #2
    All three give me exactly the same (identical) results. Digging in the Internet I found out that using "robust" automatically adds "cluster" when FE option is specified, but it still does not explain why all 3 are the same.
    Are you sure they are identical? The coefficients should be exactly the same. But the standard errors in 1 should differ from those in 2 and 3. Perhaps you should show the complete output.


    What is the difference between:
    Code:
    xtreg y x1 x2 x3, fe vce(cluster ID)
    and
    Code:
    xtreg y x1 x2 x3, fe cluster(ID)
    There is no difference between these.

    Comment


    • #3
      Constantin:
      */ 2
      xtreg y x1 x2 x3, fe vce(robust)

      */ 3
      xtreg y x1 x2 x3, fe cluster(ID)
      and

      Code:
      xtreg y x1 x2 x3, fe vce(cluster panelid)
      will give you the same outcomes as well , as you can see from the following toy-example:
      Code:
      . use "http://www.stata-press.com/data/r14/nlswork.dta", clear
      (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
      
      . xtreg ln_wage tenure, fe vce(robust)
      
      Fixed-effects (within) regression               Number of obs     =     28,101
      Group variable: idcode                          Number of groups  =      4,699
      
      R-sq:                                           Obs per group:
           within  = 0.0972                                         min =          1
           between = 0.1966                                         avg =        6.0
           overall = 0.1373                                         max =         15
      
                                                      F(1,4698)         =    1221.93
      corr(u_i, Xb)  = 0.1395                         Prob > F          =     0.0000
      
                                   (Std. Err. adjusted for 4,699 clusters in idcode)
      ------------------------------------------------------------------------------
                   |               Robust
           ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            tenure |   .0341807   .0009778    34.96   0.000     .0322638    .0360977
             _cons |   1.570329   .0030546   514.09   0.000     1.564341    1.576318
      -------------+----------------------------------------------------------------
           sigma_u |  .39172445
           sigma_e |  .30357621
               rho |  .62477177   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      
      . xtreg ln_wage tenure, fe vce(cluster idcode )
      
      Fixed-effects (within) regression               Number of obs     =     28,101
      Group variable: idcode                          Number of groups  =      4,699
      
      R-sq:                                           Obs per group:
           within  = 0.0972                                         min =          1
           between = 0.1966                                         avg =        6.0
           overall = 0.1373                                         max =         15
      
                                                      F(1,4698)         =    1221.93
      corr(u_i, Xb)  = 0.1395                         Prob > F          =     0.0000
      
                                   (Std. Err. adjusted for 4,699 clusters in idcode)
      ------------------------------------------------------------------------------
                   |               Robust
           ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            tenure |   .0341807   .0009778    34.96   0.000     .0322638    .0360977
             _cons |   1.570329   .0030546   514.09   0.000     1.564341    1.576318
      -------------+----------------------------------------------------------------
           sigma_u |  .39172445
           sigma_e |  .30357621
               rho |  .62477177   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      
      . xtreg ln_wage tenure, fe cluster(idcode )
      
      Fixed-effects (within) regression               Number of obs     =     28,101
      Group variable: idcode                          Number of groups  =      4,699
      
      R-sq:                                           Obs per group:
           within  = 0.0972                                         min =          1
           between = 0.1966                                         avg =        6.0
           overall = 0.1373                                         max =         15
      
                                                      F(1,4698)         =    1221.93
      corr(u_i, Xb)  = 0.1395                         Prob > F          =     0.0000
      
                                   (Std. Err. adjusted for 4,699 clusters in idcode)
      ------------------------------------------------------------------------------
                   |               Robust
           ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            tenure |   .0341807   .0009778    34.96   0.000     .0322638    .0360977
             _cons |   1.570329   .0030546   514.09   0.000     1.564341    1.576318
      -------------+----------------------------------------------------------------
           sigma_u |  .39172445
           sigma_e |  .30357621
               rho |  .62477177   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        Are you sure they are identical? The coefficients should be exactly the same. But the standard errors in 1 should differ from those in 2 and 3. Perhaps you should show the complete output.



        There is no difference between these.
        Thank you Clyde and Carlo,

        You right Clyde.

        1. SE are different between
        Code:
        xtreg y x1 x2 x3*Z, fe vce(robust)
        and
        Code:
        xtreg y x1 x2 x3*Z, fe
        but the SAME between
        Code:
        xtreg y x1 x2 x3*Z, fe cluster(ID)
        and
        Code:
        xtreg y x1 x2 x3*Z, fe
        Also, when I use FE option and try to plot with marginplot, margin command fails to estimate 90% of the points (22 out of 24). It does not happen without the FE option. Any idea why and how i can fix it?

        Here is the output

        HTML Code:
        margins, at( x3   =(1 2 3 4 5 6 7 8 9 10 11 12) Z=1 Z=14)
        
        Predictive margins                                Number of obs   =      25911
        Model VCE    : Robust
        
        Expression   : Linear prediction, predict()
        
        1._at        : x3          =           1
                       Z           =           1
        
        2._at        : x3          =           1
                       Z           =          14
        
        3._at        : x3          =           2
                       Z           =           1
        
        4._at        : x3          =           2
                       Z           =          14
        
        5._at        : x3          =           3
                       Z           =           1
        
        6._at        : x3          =           3
                       Z           =          14
        
        7._at        : x3          =           4
                       Z           =           1
        
        8._at        : x3          =           4
                       Z           =          14
        
        9._at        : x3          =           5
                       Z           =           1
        
        10._at       : x3          =           5
                       Z           =          14
        
        11._at       : x3          =           6
                       Z           =           1
        
        12._at       : x3          =           6
                       Z           =          14
        
        13._at       : x3          =           7
                       Z           =           1
        
        14._at       : x3          =           7
                       Z           =          14
        
        15._at       : x3          =           8
                       Z           =           1
        
        16._at       : x3          =           8
                       Z           =          14
        
        17._at       : x3          =           9
                       Z           =           1
        
        18._at       : x3          =           9
                       Z           =          14
        
        19._at       : x3          =          10
                       Z           =           1
        
        20._at       : x3          =          10
                       Z           =          14
        
        21._at       : x3          =          11
                       Z           =           1
        
        22._at       : x3          =          11
                       Z           =          14
        
        23._at       : x3          =          12
                       Z           =           1
        
        24._at       : x3          =          12
                       Z           =          14
        
        ------------------------------------------------------------------------------
                     |            Delta-method
                     |     Margin   Std. Err.      Z   P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                 _at |
                  1  |          .  (not estimable)
                  2  |          .  (not estimable)
                  3  |          .  (not estimable)
                  4  |          .  (not estimable)
                  5  |          .  (not estimable)
                  6  |   5.365236   .0799439    67.11   0.000     5.208548    5.521923
                  7  |          .  (not estimable)
                  8  |          .  (not estimable)
                  9  |    5.11202   .0319418   160.04   0.000     5.049415    5.174625
                 10  |          .  (not estimable)
                 11  |          .  (not estimable)
                 12  |          .  (not estimable)
                 13  |          .  (not estimable)
                 14  |          .  (not estimable)
                 15  |          .  (not estimable)
                 16  |          .  (not estimable)
                 17  |          .  (not estimable)
                 18  |          .  (not estimable)
                 19  |          .  (not estimable)
                 20  |          .  (not estimable)
                 21  |          .  (not estimable)
                 22  |          .  (not estimable)
                 23  |          .  (not estimable)
                 24  |          .  (not estimable)
        ------------------------------------------------------------------------------
        Last edited by Constantin Alba; 25 May 2017, 14:49.

        Comment


        • #5
          You're not showing us your real code, and you didn't show the regression outputs themselves. I know you didn't show the real code because x3*Z as a term in the regresion varlist would be a syntax error.

          If you are interested in getting help with this, use -dataex- to post an example of the data that reproduces this behavior, and then show the exact code and the exact results you got from Stata.

          The most likely reason you are getting (not estimable) as the results from -margins- is because some or all of those combinations of x3 and Z don't actually exist in your data set. But, again, without seeing an example of data that reproduces the problem, that advice can't be given with certainty, because sometimes there can be other causes.

          Comment

          Working...
          X