Announcement

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

  • how to use xtreg after ebalance

    Dear Statalist,

    I'm using ebalance (from SSC) for entropy balancing, I wonder how to apply xtreg after I obtain _webal?

    What I did
    Code:
    ebalance treat controls, targets(3) keep(baltable) replace
    xtreg y treat controls i.year [aw=_webal] ,fe vce(cluster firm)
    and I get
    Code:
    weight must be constant within firm
    r(199);
    I also tried pweight and fweight, but still get the same message that weight must be constant within firm. The examples I saw all use reg rather than xtreg. If I want want to run two-way fixed effects model after entropy balancing, how can I achieve this?

    Thanks a lot for any suggestions!

  • #2
    Alice:
    you can go -regress-:
    Code:
    . use "https://www.stata-press.com/data/r17/nlswork.dta"
    (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
    
    . regress ln_wage i.idcode i.year if idcode<=3
    
          Source |       SS           df       MS      Number of obs   =        39
    -------------+----------------------------------   F(16, 22)       =      2.84
           Model |  3.48635949        16  .217897468   Prob > F        =    0.0122
        Residual |  1.68937946        22  .076789976   R-squared       =    0.6736
    -------------+----------------------------------   Adj R-squared   =    0.4362
           Total |  5.17573896        38  .136203657   Root MSE        =    .27711
    
    ------------------------------------------------------------------------------
         ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
          idcode |
              2  |  -.3898423   .1155629    -3.37   0.003     -.629505   -.1501795
              3  |  -.4648596   .1120424    -4.15   0.000    -.6972212   -.2324979
                 |
            year |
             69  |    .208967   .3918928     0.53   0.599    -.6037689    1.021703
             70  |  -.2747772   .3439816    -0.80   0.433    -.9881514    .4385969
             71  |  -.3613911    .326316    -1.11   0.280    -1.038129    .3153467
             72  |  -.2056973    .326316    -0.63   0.535    -.8824352    .4710406
             73  |  -.0310461    .326316    -0.10   0.925     -.707784    .6456917
             75  |   .0416271    .326316     0.13   0.900    -.6351107     .718365
             77  |   .0358937    .326316     0.11   0.913    -.6408441    .7126316
             78  |   .2433199    .326316     0.75   0.464    -.4334179    .9200578
             80  |   .2726139    .326316     0.84   0.412    -.4041239    .9493518
             82  |   .1747839   .3439816     0.51   0.616    -.5385903    .8881581
             83  |   .2924489    .326316     0.90   0.380    -.3842889    .9691868
             85  |   .3712589    .326316     1.14   0.267     -.305479    1.047997
             87  |   .2960361    .326316     0.91   0.374    -.3807017     .972774
             88  |   .3038639    .326316     0.93   0.362    -.3728739    .9806018
                 |
           _cons |   1.958421   .2989038     6.55   0.000     1.338532    2.578309
    ------------------------------------------------------------------------------
    
    . xtreg ln_wage i.year if idcode<=3, fe
    
    Fixed-effects (within) regression               Number of obs     =         39
    Group variable: idcode                          Number of groups  =          3
    
    R-squared:                                      Obs per group:
         Within  = 0.5446                                         min =         12
         Between = 0.2670                                         avg =       13.0
         Overall = 0.3678                                         max =         15
    
                                                    F(14,22)          =       1.88
    corr(u_i, Xb) = -0.0356                         Prob > F          =     0.0897
    
    ------------------------------------------------------------------------------
         ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
            year |
             69  |    .208967   .3918928     0.53   0.599    -.6037689    1.021703
             70  |  -.2747772   .3439816    -0.80   0.433    -.9881514    .4385969
             71  |  -.3613911    .326316    -1.11   0.280    -1.038129    .3153467
             72  |  -.2056973    .326316    -0.63   0.535    -.8824352    .4710406
             73  |  -.0310461    .326316    -0.10   0.925     -.707784    .6456917
             75  |   .0416271    .326316     0.13   0.900    -.6351107     .718365
             77  |   .0358937    .326316     0.11   0.913    -.6408441    .7126316
             78  |   .2433199    .326316     0.75   0.464    -.4334179    .9200578
             80  |   .2726139    .326316     0.84   0.412    -.4041239    .9493518
             82  |   .1747839   .3439816     0.51   0.616    -.5385903    .8881581
             83  |   .2924489    .326316     0.90   0.380    -.3842889    .9691868
             85  |   .3712589    .326316     1.14   0.267     -.305479    1.047997
             87  |   .2960361    .326316     0.91   0.374    -.3807017     .972774
             88  |   .3038639    .326316     0.93   0.362    -.3728739    .9806018
                 |
           _cons |   1.659677   .2833366     5.86   0.000     1.072073    2.247281
    -------------+----------------------------------------------------------------
         sigma_u |  .24956596
         sigma_e |  .27711004
             rho |  .44784468   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    F test that all u_i=0: F(2, 22) = 9.64                       Prob > F = 0.0010
    
    .
    Assuming that you are interested in -idcode- and -i.year- fixed effects, you can see that the two approaches give the same results as far as the shared predictors are concerned.
    It's up to you to add weights- in -regress-.
    A word of caution: despite being feasible if you go -regress-, [aw] should be consistent with the methodology in force in your reserach field..
    Last edited by Carlo Lazzaro; 15 Apr 2022, 02:35.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo,

      Thanks a lot for your reply!

      I tried reg with i.firm and i.year, it works. But I have more than 28,000 firms, so the table goes too long. I think -reghdfe- would also do the same, and I can absorb firm and year fixed effects. My code is
      Code:
      reghdfe y treat controls [aw=_webal], absorb(firm year) vce(cluster firm)
      I suppose this is the same as
      Code:
      reg y treat controls i.firm i.year [aw=_webal] ,vce(cluster firm)

      As for the weight to use, I actually don't know which one is appropriate. I followed other examples to use aweight. This is a robustness check, my main test used PSM (what weight does PSM use? is it aweight?), and I want to keep the two methods consistent in the choice of weight.

      Thanks,
      Alice

      Comment


      • #4
        Alice:
        thanks for clarifying.
        Yes, the community-contributed module -reghdfe- is the way to go there (and your -reghdfe- code equals your -regress- specification).
        As far as I know, PSM use frequency or sampling weights, though.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Hi Carlo,

          Thanks for your reply, I will try fweight or pweight instead.

          Comment


          • #6
            Carlo Lazzaro

            Dear Carlo I am wondering if I can apply two step System GMM after entropy balancing using xtabond2 , as I tried to use the following command but always the prob > F = . and the F of the model is missing

            The code used:


            Code:
             xtabond2 depvar  l.depvar   treat  controls  i.year i.ind [aw=_webal] , gmm(treat controls ,collapse) iv(i.year  i.ind , equation(level)) nodiffsargan twostep robust orthogonal small

            Do you think is there any errors with my code ?


            Comment


            • #7
              Mohamed:
              sorry, but I do not use dynamic panel data regression.
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment


              • #8
                Many Thanks Carlo Lazzaro

                Dear Sebastian Kripfganz Do you think system GMM could works after entropy balancing ? As I tried many times and it does not works


                Many thanks
                Last edited by Mohamed Mahmoud; 19 May 2023, 11:07.

                Comment


                • #9
                  I do not know enough about entropy rebalancing to give a helpful answer. I am not sure it preserves the dynamic structure of the model, which would be a problem.
                  https://www.kripfganz.de/stata/

                  Comment

                  Working...
                  X