Announcement

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

  • Difference between fixed effects and individual dummies

    Hi everyone,

    I am running a regression with fixed effects and using xtreg. I was wondering what the difference is between

    Code:
    xtreg y x1 x2 i.time, fe cluster (id)
    predict u if e(sample), u 
    list u
    And running
    Code:
    reg y x1 x2 i.time i.id, cluster(id)
    And looking at the individual dummy values for id. I am trying to have a look at the individual fixed effects and see whether the influence on y differs across id’s.

  • #2
    Dana:
    the relationship you're looking for is easy to get, but, since your second code will take forever, you'd be better off by reducing you sample to test it:
    Code:
    use "https://www.stata-press.com/data/r17/nlswork.dta"
    . xtreg ln_wage wks_ue ttl_exp i.year if idcode<=3, fe vce(cluster idcode )
    
    Fixed-effects (within) regression               Number of obs     =         32
    Group variable: idcode                          Number of groups  =          3
    
    R-squared:                                      Obs per group:
         Within  = 0.8596                                         min =          9
         Between = 0.5755                                         avg =       10.7
         Overall = 0.6766                                         max =         12
    
                                                    F(2,2)            =          .
    corr(u_i, Xb) = -0.6640                         Prob > F          =          .
    
                                     (Std. err. adjusted for 3 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
          wks_ue |  -.0059005   .0010199    -5.79   0.029    -.0102886   -.0015123
         ttl_exp |  -.1802504   .0103821   -17.36   0.003     -.224921   -.1355797
                 |
            year |
             69  |   .3129576   .0059897    52.25   0.000      .287186    .3387291
             70  |   .3131149   .0403495     7.76   0.016     .1395049    .4867249
             71  |   .3734201   .2173143     1.72   0.228    -.5616077    1.308448
             72  |   .6047066   .2053181     2.95   0.099    -.2787059    1.488119
             73  |   .9161217   .0569372    16.09   0.004     .6711409    1.161103
             75  |   1.071495    .092861    11.54   0.007     .6719459    1.471043
             77  |   1.200775   .0786513    15.27   0.004     .8623657    1.539184
             78  |   1.549068   .2457137     6.30   0.024     .4918478    2.606289
             80  |   2.210631   .0980471    22.55   0.002     1.788768    2.632493
             83  |   2.314151   .0527242    43.89   0.001     2.087297    2.541005
             85  |   2.587935   .1320649    19.60   0.003     2.019705    3.156164
             87  |   2.877827   .1719838    16.73   0.004     2.137841    3.617814
             88  |   3.144313   .1948402    16.14   0.004     2.305984    3.982643
                 |
           _cons |   1.371913   .0186366    73.61   0.000     1.291726    1.452101
    -------------+----------------------------------------------------------------
         sigma_u |  .29256637
         sigma_e |  .18669493
             rho |  .71062703   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    . 
    . predict fitted_fe, xb
    
    . predict u_i, u
    
    
    . reg ln_wage wks_ue ttl_exp i.idcode i.year if idcode<=3, vce(cluster idcode )
    
    Linear regression                               Number of obs     =         32
                                                    F(1, 2)           =          .
                                                    Prob > F          =          .
                                                    R-squared         =     0.8952
                                                    Root MSE          =     .18669
    
                                     (Std. err. adjusted for 3 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
          wks_ue |  -.0059005   .0010903    -5.41   0.032    -.0105916   -.0012094
         ttl_exp |  -.1802504    .011099   -16.24   0.004    -.2280053   -.1324954
                 |
          idcode |
              2  |  -.2142075   .0199583   -10.73   0.009    -.3000812   -.1283337
              3  |   .3644592   .0565652     6.44   0.023     .1210789    .6078395
                 |
            year |
             69  |   .3129576   .0064032    48.87   0.000     .2854066    .3405085
             70  |   .3131149   .0431355     7.26   0.018      .127518    .4987118
             71  |   .3734201   .2323187     1.61   0.249    -.6261667    1.373007
             72  |   .6047066   .2194943     2.75   0.110    -.3397011    1.549114
             73  |   .9161217   .0608684    15.05   0.004     .6542262    1.178017
             75  |   1.071495   .0992726    10.79   0.008     .6443591     1.49863
             77  |   1.200775   .0840817    14.28   0.005     .8390003    1.562549
             78  |   1.549068    .262679     5.90   0.028      .418852    2.679285
             80  |   2.210631   .1048167    21.09   0.002     1.759641    2.661621
             83  |   2.314151   .0563646    41.06   0.001     2.071634    2.556669
             85  |   2.587935   .1411833    18.33   0.003     1.980472    3.195398
             87  |   2.877827   .1838584    15.65   0.004     2.086749    3.668906
             88  |   3.144313   .2082929    15.10   0.004     2.248101    4.040526
                 |
           _cons |   1.295487   .0464494    27.89   0.001     1.095632    1.495343
    ------------------------------------------------------------------------------
    
    . predict fitted_OLS, xb
    
    
    . list idcode fitted_fe u_i fitted_OLS in 1
    
         +------------------------------------------+
         | idcode     fitted_fe         u_i   fitted~S |
         |------------------------------------------|
      1. |      1   1.477956   -.0764263    1.40153 |
         +------------------------------------------+
    
    . di 1.477956   -.0764263
    1.4015297
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you Carlo,

      I meant it a bit differently however. I was wondering is there was a way to see how the individual fixed effects influence the outcome y.

      I though that the dummies and predict then should then give more or less the same result. Howver if I code:
      Code:
      list idcode fitted_fe u_i fitted_OLS if idcode==2
      
             +------------------------------------------+
             | idcode   fitted~e         u_i   fitted~S |
             |------------------------------------------|
         13. |      2    1.50497   -.2906338   1.214336 |
         14. |      2   1.736703   -.2906338   1.446069 |
         15. |      2   1.818076   -.2906338   1.527442 |
         16. |      2   2.044777   -.2906338   1.754144 |
         17. |      2   1.993807   -.2906338   1.703173 |
             |------------------------------------------|
         18. |      2    2.16185   -.2906338   1.871217 |
         19. |      2          .           .          . |
         20. |      2          .           .          . |
         21. |      2    2.06811   -.2906338   1.777477 |
         22. |      2    2.10139   -.2906338   1.810756 |
             |------------------------------------------|
         23. |      2          .           .          . |
         24. |      2   2.060893   -.2906338   1.770259 |
             +------------------------------------------
      u_i is -0.29 and the dummy gives -0.21.

      Code:
       reg ln_wage wks_ue ttl_exp i.idcode i.year if idcode<=3, vce(cluster idcode )
      
      Linear regression                               Number of obs     =         32
                                                      F(1, 2)           =          .
                                                      Prob > F          =          .
                                                      R-squared         =     0.8952
                                                      Root MSE          =     .18669
      
                                       (Std. Err. adjusted for 3 clusters in idcode)
      ------------------------------------------------------------------------------
                   |               Robust
           ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            wks_ue |  -.0059005   .0010903    -5.41   0.032    -.0105916   -.0012094
           ttl_exp |  -.1802504    .011099   -16.24   0.004    -.2280053   -.1324954
                   |
            idcode |
                2  |  -.2142075   .0199583   -10.73   0.009    -.3000812   -.1283337
                3  |   .3644592   .0565652     6.44   0.023     .1210789    .6078395
                   |
              year |
               69  |   .3129576   .0064032    48.87   0.000     .2854066    .3405085
               70  |   .3131149   .0431355     7.26   0.018      .127518    .4987118
               71  |   .3734201   .2323187     1.61   0.249    -.6261667    1.373007
               72  |   .6047066   .2194943     2.75   0.110    -.3397011    1.549114
               73  |   .9161217   .0608684    15.05   0.004     .6542262    1.178017
               75  |   1.071495   .0992726    10.79   0.008     .6443591     1.49863
               77  |   1.200775   .0840817    14.28   0.005     .8390003    1.562549
               78  |   1.549068    .262679     5.90   0.028      .418852    2.679285
               80  |   2.210631   .1048167    21.09   0.002     1.759641    2.661621
               83  |   2.314151   .0563646    41.06   0.001     2.071634    2.556669
               85  |   2.587935   .1411833    18.33   0.003     1.980472    3.195398
               87  |   2.877827   .1838584    15.65   0.004     2.086749    3.668906
               88  |   3.144313   .2082929    15.10   0.004     2.248101    4.040526
                   |
             _cons |   1.295487   .0464494    27.89   0.001     1.095632    1.495343
      ------------------------------------------------------------------------------
      it seems like if I use

      Code:
      display -.0764263-.2142075
      -.2906338
      I get u_i. Would this be a correct way to approach this? I then ofcourse do not get a p value.

      Comment


      • #4
        Dana:
        your last calculation does not sound correct.
        That said, the -fe- estimator assumes that the -u- term is correlated with the vector of the regressors, whereas OLS does not follow this approach.
        In addition, OLS does not imply demeaning.

        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thank you Carlo.

          since it is not correct, how come u_i is equal to the dummy+u_i of id(1)? Furthermore what would you suggest if I want to see for which panel the fixed effects have the largest impact on y?

          Comment


          • #6
            Dana:
            sorry, my mistake.
            Your calculation was indeed correct.
            Admittedly; i've never challenged myself with this issue, as the fixed effect is a panel-specific constant and, as such, has no within-panel variance
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Thank you Carlo. I agree and I will see

              Comment


              • #8
                Originally posted by Dana Baade View Post
                u_i is equal to the dummy+u_i of id(1)?
                Correct. The reason is because id=1 is the base (omitted) category in the regression with dummy variables.


                I want to see for which panel the fixed effects have the largest impact on y?
                Unless you have a large \(T\) dimension, you should not compare the fixed effects as they are not estimated consistently. If and only if the \(T\) dimension is large, then you can use margins to predict the panel-specific intercepts and then use test for a comparison across any pair. The dummy coefficients from regress compare each panel against the base.

                Code:
                webuse grunfeld, clear
                regress invest mvalue i.company
                margins company, post
                di _b[3.company]- _b[1.company]
                test 1.company=3.company
                Res.:

                Code:
                . regress invest mvalue i.company
                
                      Source |       SS           df       MS      Number of obs   =       200
                -------------+----------------------------------   F(10, 189)      =    106.36
                       Model |   7947627.4        10   794762.74   Prob > F        =    0.0000
                    Residual |  1412316.51       189  7472.57415   R-squared       =    0.8491
                -------------+----------------------------------   Adj R-squared   =    0.8411
                       Total |  9359943.92       199  47034.8941   Root MSE        =    86.444
                
                ------------------------------------------------------------------------------
                      invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                      mvalue |   .1898776   .0179944    10.55   0.000     .1543819    .2253733
                             |
                     company |
                          2  |   250.9496   50.53491     4.97   0.000     151.2647    350.6345
                          3  |  -51.44415   50.99737    -1.01   0.314    -152.0413    49.15302
                          4  |   169.3784   70.98565     2.39   0.018     29.35244    309.4043
                          5  |   232.7314   78.71866     2.96   0.004      77.4514    388.0115
                          6  |    190.568   75.54874     2.52   0.012     41.54088     339.595
                          7  |   234.0336    80.0986     2.92   0.004     76.03153    392.0357
                          8  |   130.3806   71.35614     1.83   0.069    -10.37613    271.1374
                          9  |   193.4162   76.99706     2.51   0.013     41.53223    345.3003
                         10  |   204.4981   81.43403     2.51   0.013     43.86171    365.1345
                             |
                       _cons |  -214.8799   80.34482    -2.67   0.008    -373.3677   -56.39209
                ------------------------------------------------------------------------------
                
                .
                . margins company, post
                
                Predictive margins                              Number of obs     =        200
                Model VCE    : OLS
                
                Expression   : Linear prediction, predict()
                
                ------------------------------------------------------------------------------
                             |            Delta-method
                             |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                     company |
                          1  |  -9.492932   61.63044    -0.15   0.878    -131.0648     112.079
                          2  |   241.4567   25.10364     9.62   0.000     191.9373     290.976
                          3  |  -60.93708   24.75706    -2.46   0.015    -109.7727   -12.10142
                          4  |   159.8854   20.55464     7.78   0.000     119.3395    200.4314
                          5  |   223.2385   24.65136     9.06   0.000     174.6113    271.8657
                          6  |    181.075   22.70359     7.98   0.000       136.29      225.86
                          7  |   224.5407    25.5895     8.77   0.000      174.063    275.0184
                          8  |   120.8877   20.69455     5.84   0.000     80.06575    161.7097
                          9  |   183.9233   23.55442     7.81   0.000       137.46    230.3866
                         10  |   195.0052   26.54116     7.35   0.000     142.6502    247.3601
                ------------------------------------------------------------------------------
                
                .
                . di _b[3.company]- _b[1.company]
                -51.444149
                
                .
                . test 1.company=3.company
                
                 ( 1)  1bn.company - 3.company = 0
                
                       F(  1,   189) =    1.02
                            Prob > F =    0.3144
                
                .
                Last edited by Andrew Musau; 23 Jul 2022, 13:03.

                Comment


                • #9
                  Thank you Andrew

                  Comment

                  Working...
                  X