Announcement

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

  • Using setting of reghdfe

    Dear All,

    I'm new here as junior researcher of Economy & Finance.

    My data is like " Company-Institute Investors-Year" level and I'm cofused that if I could use reghdfe on such a special panel for multi-way fixed effects?

    Or I could just use reghdfe withour setting a panel firstly?

    I'm so grateful if some experts and friends here could help me with these Qs!

    Hundreds of thousands of thanks!

  • #2
    Jason:
    welcome to this forum.
    Please read and act on the FAQ on how to post more effectively. Thanks.
    You can use -xtreg,fe- or the n-way fixed effects estimator provided by the community-contributed module -reghdfe-:
    Code:
    . xtset idcode year
    
    Panel variable: idcode (unbalanced)
     Time variable: year, 68 to 88, but with gaps
             Delta: 1 unit
    
    . xtreg ln_wage c.age##c.age i.year, fe vce(cluster idcode)
    
    Fixed-effects (within) regression               Number of obs     =     28,510
    Group variable: idcode                          Number of groups  =      4,710
    
    R-squared:                                      Obs per group:
         Within  = 0.1162                                         min =          1
         Between = 0.1078                                         avg =        6.1
         Overall = 0.0932                                         max =         15
    
                                                    F(16, 4709)       =      79.11
    corr(u_i, Xb) = 0.0613                          Prob > F          =     0.0000
    
                                 (Std. err. adjusted for 4,710 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             age |   .0728746    .013687     5.32   0.000     .0460416    .0997075
                 |
     c.age#c.age |  -.0010113   .0001076    -9.40   0.000    -.0012224   -.0008003
                 |
            year |
             69  |   .0647054   .0155249     4.17   0.000     .0342693    .0951415
             70  |   .0284423   .0264639     1.07   0.283    -.0234395     .080324
             71  |   .0579959   .0384111     1.51   0.131    -.0173078    .1332996
             72  |   .0510671   .0502675     1.02   0.310    -.0474808     .149615
             73  |   .0424104   .0624924     0.68   0.497    -.0801038    .1649247
             75  |   .0151376    .086228     0.18   0.861    -.1539096    .1841848
             77  |   .0340933   .1106841     0.31   0.758    -.1828994     .251086
             78  |   .0537334   .1232232     0.44   0.663    -.1878417    .2953084
             80  |   .0369475   .1473725     0.25   0.802    -.2519716    .3258667
             82  |   .0391687   .1715621     0.23   0.819    -.2971733    .3755108
             83  |    .058766   .1836086     0.32   0.749    -.3011928    .4187249
             85  |   .1042758   .2080199     0.50   0.616    -.3035406    .5120922
             87  |   .1242272   .2327328     0.53   0.594    -.3320379    .5804922
             88  |   .1904977   .2486083     0.77   0.444    -.2968909    .6778863
                 |
           _cons |   .3937532   .2469015     1.59   0.111    -.0902893    .8777957
    -------------+----------------------------------------------------------------
         sigma_u |  .40275174
         sigma_e |  .30127563
             rho |  .64120306   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    . reghdfe ln_wage c.age##c.age, abs(idcode year) vce(cluster idcode)
    (dropped 551 singleton observations)
    (MWFE estimator converged in 8 iterations)
    
    HDFE Linear regression                            Number of obs   =     27,959
    Absorbing 2 HDFE groups                           F(   2,   4158) =      44.91
    Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                      R-squared       =     0.6593
                                                      Adj R-squared   =     0.5995
                                                      Within R-sq.    =     0.0115
    Number of clusters (idcode)  =      4,159         Root MSE        =     0.3013
    
                                 (Std. err. adjusted for 4,159 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             age |   .0728746   .0136873     5.32   0.000     .0460402    .0997089
                 |
     c.age#c.age |  -.0010113   .0001076    -9.39   0.000    -.0012224   -.0008003
                 |
           _cons |   .4586164   .3651743     1.26   0.209    -.2573205    1.174553
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
          idcode |      4159        4159           0    *|
            year |        15           0          15     |
    -----------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation
    
    . help reghdfe
    
    . reghdfe ln_wage c.age##c.age, abs(FE1=idcode FE2=year) vce(cluster idcode)
    (dropped 551 singleton observations)
    (MWFE estimator converged in 8 iterations)
    
    HDFE Linear regression                            Number of obs   =     27,959
    Absorbing 2 HDFE groups                           F(   2,   4158) =      44.91
    Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                      R-squared       =     0.6593
                                                      Adj R-squared   =     0.5995
                                                      Within R-sq.    =     0.0115
    Number of clusters (idcode)  =      4,159         Root MSE        =     0.3013
    
                                 (Std. err. adjusted for 4,159 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             age |   .0728746   .0136873     5.32   0.000     .0460402    .0997089
                 |
     c.age#c.age |  -.0010113   .0001076    -9.39   0.000    -.0012224   -.0008003
                 |
           _cons |   .4586164   .3651743     1.26   0.209    -.2573205    1.174553
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
          idcode |      4159        4159           0    *|
            year |        15           0          15     |
    -----------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation
    
    . sum FE*
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
             FE1 |     27,959   -2.13e-16    .3590021  -1.416543   2.059387
             FE2 |     27,959   -4.29e-17    .0477131  -.0629913   .1275064
    
    .
    The second -reghdfe- code allows you to save your FEs.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Thank you Mr.Lazzaro!

      I'll try to post more effectively next time and many thanks to your kind advice and code.
      Best regards,
      Jason
      (StataNow 17.0)

      Comment

      Working...
      X