Announcement

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

  • Interpreting identical results for -reg- and -xtreg- in panel data and missing output

    Dear Statalist,

    I am working with panel data (17k observations, N= 275, T=65) on Stata 15. I want to compare the residuals from pooled OLS and Fixed effects models. In each case, I am regressing my dependent variable on a constant only. When I ran the -reg- and -xtreg- commands, I noticed that both of the commands produce exactly the same coefficients for the constant and very slightly different standard errors. The predicted residuals are also identically the same. Code and log file for three models is attached: pooled OLS with robust standard errors, FE with and without robust standard errors. I am also not sure why in the FE model with robust SE, there is lots of missing output.

    How should I interpret these results? Am I doing something wrong?

    Best,
    Mihir

    Code:
    xtset id year
    
    panel variable:  id (unbalanced)
    time variable:  year, 1950 to 2014, but with gaps
    delta:  1 unit
    
    *--------------------------------------------*
    Pooled OLS with robust std errors
    *--------------------------------------------*
    
    reg y , r
    predict y_res1, res
    
    
    Linear regression                               Number of obs     =     17,301
                                                    F(0, 17300)       =       0.00
                                                    Prob > F          =          .
                                                    R-squared         =     0.0000
                                                    Root MSE          =     .78842
    
    ------------------------------------------------------------------------------
                 |               Robust
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _cons |    .362956   .0059941    60.55   0.000      .351207     .374705
    ------------------------------------------------------------------------------
    
    *-----------------------------------*
    FE with robust std errors
    *-----------------------------------*
    xtreg y, fe r
    predict y_res2, res
    
    
    
    Fixed-effects (within) regression               Number of obs     =     17,301
    Group variable: area_code                       Number of groups  =        272
    
    R-sq:                                           Obs per group:
         within  =      .                                         min =          6
         between = 0.0163                                         avg =       63.6
         overall =      .                                         max =         65
    
                                                    F(0,271)          =          .
    corr(u_i, Xb)  =      .                         Prob > F          =          .
    
                                (Std. Err. adjusted for 272 clusters in area_code)
    ------------------------------------------------------------------------------
                 |               Robust
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _cons |    .362956          .        .       .            .           .
    -------------+----------------------------------------------------------------
         sigma_u |   .5572325
         sigma_e |  .79466906
             rho |  .32962395   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    *-----------------------------------*
    FE without robust std errors
    *-----------------------------------*
    
    xtreg y, fe
    predict y_res3, res
    
    
    Fixed-effects (within) regression               Number of obs     =     17,301
    Group variable: area_code                       Number of groups  =        272
    
    R-sq:                                           Obs per group:
         within  =      .                                         min =          6
         between = 0.0163                                         avg =       63.6
         overall =      .                                         max =         65
    
                                                    F(0,17029)        =       0.00
    corr(u_i, Xb)  =      .                         Prob > F          =          .
    
    ------------------------------------------------------------------------------
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _cons |    .362956   .0060416    60.08   0.000     .3511139    .3747981
    -------------+----------------------------------------------------------------
         sigma_u |   .5572325
         sigma_e |  .79466906
             rho |  .32962395   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    F test that all u_i=0: F(271, 17029) = 0.00                  Prob > F = 1.0000
    
    *--------------------------------------------*
     check that residuals are the same
    *--------------------------------------------*
    
    assert y_res3 == y_res2
    assert y_res3 == y_res1
    Last edited by Mihir Sharma; 16 Jan 2018, 14:49.

  • #2
    Mihir:
    just a comment about your first code; you did not run a pooled OLS, but an OLS with robust standard errors, which accounts for heteroskedasticity in the residual distribution, but ignores residual autocorrelation. Please note that only under -xtreg- robust/clustered standard errors do the same job (ie, account for heteroskedasticity and/or autocorrelation).
    A pooled OLS requires clustered standard errors, instead (as the observations are not independent).
    Try re-rerunning your code with the amendment suggested above and see what happens.
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

      With just the constant, you're just estimating the mean. I didn't know this, but it is clear that the mean is what you get when you just run the constant in xtreg as well. The fixed effects are set to have mean zero. You might find https://www.stata.com/support/faqs/s...effects-model/
      useful.
      Carlo's suggestions will probably change the standard errors, but not the parameter per se.

      Comment


      • #4
        Phil is right: the point estimates of the pooled OLS will be unaffected by switching from robust to clustered standard error(s).
        The core meaning of my previous reply rests on the fact that any comparison in terms of statistical significance among those three regression models should be taken carefully, as the standard errors in the first model do not take repeated waves of data for the same panel unit into account.
        Kind regards,
        Carlo
        (Stata 18.0 SE)

        Comment


        • #5
          Hi guys, yes, I was getting different coefficients because xtreg, fe was setting the fixed effects to zero. Thanks to both of you!

          Comment

          Working...
          X