Announcement

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

  • Estimating FE model with -reg or -xtreg

    Dear,

    I am estimating a panel data fixed effects model (both year and industry). I am aware I can either run -reg or -xtreg for this regression.

    Code:
    reg board sales i.year i.industry, robust
    Code:
    xtset year
    xtset industry
    xtreg board sales, fe vce(robust)
    Both the coefficient and the SE seem to differ for the two different models. What am I doing wrong and what is the right approach?

    In addition to that, when would I be right to leave to constant out. That is, run:

    Code:
    reg board sales i.industry i.year, noconstant robust
    When doing so, the coefficient for sales differs as well.

    Thanks in advance.

  • #2
    Henk:
    below the approach to estimate -fe- specification via OLS and -xtreg-. As you will see, the point estimate of the coefficients in common are the same, whereas the other stuff differs:
    Code:
    . use "https://www.stata-press.com/data/r16/nlswork.dta"
    (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
    
    
    .  reg ln_wage i.idcode c.age##c.age if idcode<=3, vce(cluster idcode)
    
    Linear regression                               Number of obs     =         39
                                                    F(1, 2)           =          .
                                                    Prob > F          =          .
                                                    R-squared         =     0.7407
                                                    Root MSE          =     .19867
    
                                     (Std. Err. adjusted for 3 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          idcode |
              2  |  -.4231615   .0288023   -14.69   0.005    -.5470877   -.2992353
              3  |  -.6126416   .0625166    -9.80   0.010    -.8816288   -.3436544
                 |
             age |   .2512762    .103677     2.42   0.136    -.1948099    .6973623
                 |
     c.age#c.age |  -.0037603   .0015603    -2.41   0.138    -.0104736     .002953
                 |
           _cons |   -1.82398   1.588179    -1.15   0.370    -8.657361      5.0094
    ------------------------------------------------------------------------------
    
    .  xtreg ln_wage c.age##c.age if idcode<=3, fe vce(cluster idcode)
    
    Fixed-effects (within) regression               Number of obs     =         39
    Group variable: idcode                          Number of groups  =          3
    
    R-sq:                                           Obs per group:
         within  = 0.6382                                         min =         12
         between = 0.8744                                         avg =       13.0
         overall = 0.2765                                         max =         15
    
                                                    F(2,2)            =       3.83
    corr(u_i, Xb)  = -0.2473                        Prob > F          =     0.2070
    
                                     (Std. Err. adjusted for 3 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |   .2512762   .1007559     2.49   0.130    -.1822416     .684794
                 |
     c.age#c.age |  -.0037603   .0015163    -2.48   0.131    -.0102844    .0027638
                 |
           _cons |  -2.189815   1.575348    -1.39   0.299    -8.967992    4.588361
    -------------+----------------------------------------------------------------
         sigma_u |  .31366066
         sigma_e |  .19867104
             rho |  .71367959   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    .
    As an aside, please note that, unlike -xtreg-, the -robust- option available from -regress- takes heteroskedasticity only into account.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Carlo,

      Thank you for the explanation. I see what I did wrong in the -xtreg now.
      From your message I derive that including -noconstant - in the -reg would not be the right way to go? What would be the difference between regressing with noconstant or with it anyway (that is, when would I be right to leave it out?

      Also, how do I know whether to do it with -reg or -xtreg (as the SE differ as you say)
      Last edited by Henk Janssen; 21 Nov 2020, 06:03.

      Comment


      • #4
        Henk:
        1) -nocostant- option details: see Example #4, -regress- entry, Stata .pdf manual;
        2) -regress- vs -xtreg-: whenever there is evidence of panel-wise effect, go -xtreg-.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thank you for all your replies. I am reading online that when including fixed effects, the estimator of the constant will be collinear with the dummies for the fixed effects (and thus not interpretable). Therefore, would it be best to leave it out when including fixed effects?

          Comment


          • #6
            Henk:
            see https://www.stata.com/support/faqs/s...effects-model/ and https://stats.idre.ucla.edu/stata/fa...d-by-xtreg-fe/
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Henk: The issue of including a constant or not isn't really important. If you include a constant, one of the dummies will be dropped. It doesn't change anything important.

              The key difference in how you've implemented reg versus xtreg is that in the former case your standard errors are not robust to serial correlation -- and that's a mistake. Using vce(robust) and vce(cluster idcode) is the same for xtreg -- for good theoretical reasons -- but not for reg. If you use reg with i.idcode and vce(cluster idcode) you will get bogus sandard errors on all the idcode dummies.

              You haven't given us much information, but I assume you have a lot more industries than time periods. If not, then there are other considerations.

              The bottom line is to use xtreg with the vce(cluster idcode) (or vce(robust) after a xtset idcode year). If you use

              Code:
              reg board sales i.year i.industry, vce(cluster idcode)
              everything you get will be identical to xtreg, except you'll get standard errors for the industry dummies -- which you should ignore.

              Comment

              Working...
              X