Announcement

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

  • coefplot of results of `lincom`

    Hello,

    I am using lincom to aggregate the results of my difference in difference model using the estimator from Sun and Abraham (2020).

    I would like to do a coefplot of the estimated aggregated estimate from lincom. Does anyone konw how I can do it?


    take the following example.

    Code:
    eventstudyinteract dv1 $eventtt182 if anytrai==1, vce(cluster prod) 
    > absorb(prod yr rsph audcmp audseq auditann) cohort(yr_first_post_trai182) control
    > _cohort(lastcohort182)
    (obs=4,883)
    
    IW estimates for dynamic effects                        Number of obs =  5,913
    Absorbing 6 HDFE groups                                 F(21, 2228)   =   2.09
                                                            Prob > F      = 0.0026
                                                            R-squared     = 0.6140
                                                            Adj R-squared = 0.2464
                                                            Root MSE      = 0.3800
                                   (Std. err. adjusted for 2,229 clusters in prod)
    ------------------------------------------------------------------------------
                 |               Robust
    auditratin~s | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
        L0ttt182 |   .1218806    .040001     3.05   0.002     .0434374    .2003238
        L1ttt182 |   .2393228   .0596118     4.01   0.000     .1224224    .3562232
        L2ttt182 |   .1201224   .0668075     1.80   0.072    -.0108891    .2511339
        F2ttt182 |   .0404785   .0425113     0.95   0.341    -.0428875    .1238445
        F3ttt182 |   .0675974   .0537379     1.26   0.209    -.0377842     .172979
        F4ttt182 |   .0120441   .0752037     0.16   0.873    -.1354326    .1595208
    ------------------------------------------------------------------------------
    
    * Following the .shape file of `eventstudyinteract` I use the `lincom` command to aggregate event study estimates. 
    
    matrix b = e(b_iw)
    
    . matrix V = e(V_iw)
    
    . ereturn post b V
    
    . lincom (L0ttt182 + L1ttt182 + L2ttt182)/3
    
     ( 1)  .3333333*L0ttt182 + .3333333*L1ttt182 + .3333333*L2ttt182 = 0
    
    ------------------------------------------------------------------------------
                 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             (1) |   .1604419   .0484821     3.31   0.001     .0654187    .2554652
    ------------------------------------------------------------------------------
    
    
    * Now I run the same model on a different dependent variable
    
    
    . eventstudyinteract dv2 $eventtt182 if anytrai==1, vce(cluster p
    > rod) absorb(prod yr rsph audcmp audseq auditann) cohort(yr_first_post_trai182) co
    > ntrol_cohort(lastcohort182)
    (obs=4,883)
    
    IW estimates for dynamic effects                        Number of obs =  5,913
    Absorbing 6 HDFE groups                                 F(21, 2228)   =   1.10
                                                            Prob > F      = 0.3449
                                                            R-squared     = 0.5438
                                                            Adj R-squared = 0.1093
                                                            Root MSE      = 0.3491
                                   (Std. err. adjusted for 2,229 clusters in prod)
    ------------------------------------------------------------------------------
                 |               Robust
    par~inv_pass | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
        L0ttt182 |   .0461567   .0343948     1.34   0.180    -.0212925    .1136059
        L1ttt182 |    .054493   .0552511     0.99   0.324     -.053856    .1628419
        L2ttt182 |   .0184704   .0557928     0.33   0.741     -.090941    .1278818
        F2ttt182 |   .0150241   .0393211     0.38   0.702    -.0620857    .0921339
        F3ttt182 |  -.0337918   .0490002    -0.69   0.491    -.1298825     .062299
        F4ttt182 |   -.006068    .066574    -0.09   0.927    -.1366216    .1244855
    ------------------------------------------------------------------------------
    
    . 
    end of do-file
    
    . do "/var/folders/d8/4ly8xgqn22bc36_bmmy54625n0kgs3/T//SD55008.000000"
    
    . */
    . matrix b = e(b_iw)
    
    . matrix V = e(V_iw)
    
    . ereturn post b V
    
    . lincom (L0ttt182 + L1ttt182 + L2ttt182)/3
    
     ( 1)  .3333333*L0ttt182 + .3333333*L1ttt182 + .3333333*L2ttt182 = 0
    
    ------------------------------------------------------------------------------
                 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             (1) |   .0397067   .0428879     0.93   0.355    -.0443521    .1237655
    ------------------------------------------------------------------------------
    
    
    * here I would like to create my coefplot with the impact of my aggregated treatment effect on the two different dependent variables.
    In sum, I have my two regressions on different DVs and I do the lincom of post treatment effects. I would like to plot these results using coefplot. does anyone knows how to do it?


    thanks a lot

  • #2
    This is my exact problem right now lol, did u figure it out yet?

    Comment


    • #3
      Here's how I might do this. Note the use of a reproducible example that anyone come run. Providing one in your question, even if it errors out, makes it more likely that someone will answer since it requires less effort to tweak broken code than making a working example from scratch.

      Code:
      webuse nlswork, clear
      gen union_year = year if union == 1
      bysort idcode: egen first_union = min(union_year)
      drop union_year
      gen ry = year - first_union
      gen never_union = (first_union == .)
      forvalues k = 18(-1)2 {
          gen g_`k' = ry == -`k'
      }
      forvalues k = 0/18 {
          gen g`k' = ry == `k'
      }
      capture ssc install avar
      capture ssc install xlincom
      set matsize 800
      eventstudyinteract ln_wage g_* g0-g18, cohort(first_union) control_cohort(never_union) covariates(south) absorb(i.idcode i.year) vce(cluster idcode)
      matrix b = e(b_iw)
      matrix V = e(V_iw)
      ereturn post b V
      xlincom [(g0 + g1 + g2 + g3 + g4)/5], post
      estimates store b1
      eventstudyinteract wks_work g_* g0-g18, cohort(first_union) control_cohort(never_union) covariates(south) absorb(i.idcode i.year) vce(cluster idcode)
      matrix b = e(b_iw)
      matrix V = e(V_iw)
      ereturn post b V
      xlincom [(g0 + g1 + g2 + g3 + g4)/5], post
      estimates store b2
      coefplot b1 b2

      Comment

      Working...
      X