Announcement

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

  • Constant in Fixed Effect

    I created a dataset using following codes
    Code:
    clear
    set obs  100
    gen id = _n
    expand 10
    bysort id : gen year = 2000 + _n -1
    xtset id year
    
    gen z = rnormal()
    gen u = rnormal()
    gen x = 3 * z + u +rnormal()
    gen y = 6 + 3*x  + u
    And I regressed the model with "reghdfe" command according to the following code:

    Code:
    reghdfe y x z, a(i.id i.year)  // model1
    est sto r1
    
    reghdfe y x z, a(i.id i.year) noconstant  // model2
    est sto r2
    I found the estimate results are completely the same whether I added constant or not.

    while I regressed the model with "reg" command according to:
    Code:
    reg y x z i.id i.year  // model3
    est sto reg1
    
    reg y x z i.id i.year ,noconstant  // model4
    est sto reg2
    the estimate results are different.

    I plot the coefficient like this:



    I am so confused about the difference where only regression command are changed. I compared the result 1 with result 3, and found the estimation are the same. So theoretically result 2 and 4 should be the same, but it's NOT.

    I was wondering what exactly the difference between "reghdfe" and "reg" and "noconstant" option is meaningful in reghdfe ?

    Thanks for Answering
    Best regards!
    Last edited by keiyou Wong; 30 Aug 2024, 01:01.

  • #2
    You cannot separate the constant from the fixed effects, so the regress results with option -nocons- will only affect estimates of the unit dummies if you allow all dummies to be included (or otherwise stated, will not affect estimates of coefficients on the time-varying variables).

    Code:
    reg y x z i.id i.year
    reg y x z ibn.id i.year ,noconstant
    The default with factor variables is to omit the lowest category. So option -nocons- with no changes to the default behavior estimates a different model where more than the required indicators are omitted. In any case, the estimate of the constant term is meaningless in FE models. More discussion of this here: https://www.stata.com/support/faqs/s...effects-model/.
    Last edited by Andrew Musau; 30 Aug 2024, 05:27.

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      You cannot separate the constant from the fixed effects, so the regress results with option -nocons- will only affect estimates of the unit dummies if you allow all dummies to be included (or otherwise stated, will not affect estimates of coefficients on the time-varying variables).

      Code:
      reg y x z i.id i.year
      reg y x z ibn.id i.year ,noconstant
      The default with factor variables is to omit the lowest category. So option -nocons- with no changes to the default behavior estimates a different model where more than the required indicators are omitted. In any case, the estimate of the constant term is meaningless in FE models. More discussion of this here: https://www.stata.com/support/faqs/s...effects-model/.
      Oh I get it !
      Code:
       Source |       SS           df       MS      Number of obs   =     1,000
      -------------+----------------------------------   F(110, 889)     =   1906.00
             Model |  103970.988       110  945.190801   Prob > F        =    0.0000
          Residual |   440.85695       889  .495902081   R-squared       =    0.9958
      -------------+----------------------------------   Adj R-squared   =    0.9953
             Total |  104411.845       999  104.516361   Root MSE        =     .7042
      
      ------------------------------------------------------------------------------
                 y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
                 x |    3.47117   .0166212   208.84   0.000     3.438549    3.503792
                 z |   -1.44663   .0558097   -25.92   0.000    -1.556164   -1.337096
                   |
                id |
                2  |  -.1935297   .3149917    -0.61   0.539    -.8117438    .4246843
                3  |  -.1796347   .3153945    -0.57   0.569    -.7986393    .4393698
                4  |  -.7138173   .3150467    -2.27   0.024    -1.332139   -.0954952
                5  |  -.3636884   .3150227    -1.15   0.249    -.9819632    .2545864
                6  |  -.5128189   .3150383    -1.63   0.104    -1.131125    .1054867
                7  |  -.4384328   .3150544    -1.39   0.164     -1.05677    .1799044
                8  |  -.1211999   .3149669    -0.38   0.700    -.7393652    .4969654
                9  |   .1020693   .3151303     0.32   0.746    -.5164168    .7205554
               10  |  -.1151052   .3150153    -0.37   0.715    -.7333657    .5031552
      I checked the previous regress results with option -nocons- and found it did omit the first id. The results based on your code are consistent.

      Thanks for answering!

      Comment

      Working...
      X