Announcement

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

  • Areg and xtreg giving different results

    Unfortunately, my data is confidential so I cannot post it here, but I ran three different regressions with an unbalanced panel dataset of individuals over 20 months.

    Code:
    areg hoursworked age, a(ID)
    Then I demeaned hoursworked and age by ID and ran:

    Code:
    reg hoursworkeddemeaned agedemeaned
    These two regressions provided the same coefficients.

    But then I did

    Code:
    xtset ID
    
    xtreg hoursworked age, fe
    I have got very similar coefficients but not exactly the same, there was a slight difference.

    Anyone knows why something like this would occur? I thought these approaches were equivalent.

  • #2
    You can post the regression results, possibly excluding the variable names. The coefficients should be identical, but the standard errors may differ due to different degrees of freedom adjustments.

    Comment


    • #3
      Deni:
      the following approaches give back the same results for the coefficients that are shared among the three regressions (-age- is the only one that the three codes have in common):
      Code:
      use "https://www.stata-press.com/data/r17/nlswork.dta"
      
      . xtreg ln_wage age if idcode<=3, fe
      
      Fixed-effects (within) regression               Number of obs     =         39
      Group variable: idcode                          Number of groups  =          3
      
      R-squared:                                      Obs per group:
           Within  = 0.3795                                         min =         12
           Between = 0.6496                                         avg =       13.0
           Overall = 0.1214                                         max =         15
      
                                                      F(1,35)           =      21.40
      corr(u_i, Xb) = -0.2960                         Prob > F          =     0.0000
      
      ------------------------------------------------------------------------------
           ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
               age |   .0307608   .0066489     4.63   0.000     .0172629    .0442588
             _cons |   .8796702   .1939752     4.53   0.000     .4858795    1.273461
      -------------+----------------------------------------------------------------
           sigma_u |  .30623358
           sigma_e |  .25645513
               rho |  .58777837   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      F test that all u_i=0: F(2, 35) = 17.07                      Prob > F = 0.0000
      
      . areg ln_wage age if idcode<=3, abs(idcode)
      
      Linear regression, absorbing indicators             Number of obs     =     39
      Absorbed variable: idcode                           No. of categories =      3
                                                          F(1, 35)          =  21.40
                                                          Prob > F          = 0.0000
                                                          R-squared         = 0.5552
                                                          Adj R-squared     = 0.5171
                                                          Root MSE          = 0.2565
      
      ------------------------------------------------------------------------------
           ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
               age |   .0307608   .0066489     4.63   0.000     .0172629    .0442588
             _cons |   .8796702   .1939752     4.53   0.000     .4858795    1.273461
      ------------------------------------------------------------------------------
      F test of absorbed indicators: F(2, 35) = 17.073              Prob > F = 0.000
      
      . reg ln_wage age i.idcode if idcode<=3
      
            Source |       SS           df       MS      Number of obs   =        39
      -------------+----------------------------------   F(3, 35)        =     14.57
             Model |   2.8738157         3  .957938567   Prob > F        =    0.0000
          Residual |  2.30192326        35  .065769236   R-squared       =    0.5552
      -------------+----------------------------------   Adj R-squared   =    0.5171
             Total |  5.17573896        38  .136203657   Root MSE        =    .25646
      
      ------------------------------------------------------------------------------
           ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
               age |   .0307608   .0066489     4.63   0.000     .0172629    .0442588
                   |
            idcode |
                2  |  -.3831397   .1049083    -3.65   0.001    -.5961148   -.1701645
                3  |  -.6053814   .1044625    -5.80   0.000    -.8174516   -.3933112
                   |
             _cons |   1.230398   .1900956     6.47   0.000     .8444837    1.616313
      ------------------------------------------------------------------------------
      
      .
      Kind regards,
      Carlo
      (StataNow 18.5)

      Comment

      Working...
      X