Announcement

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

  • Difference in difference Post and Treatment dummies

    I want to apply a difference in difference estimations to observe differences in the dependent variable for firms that appoint a female director(s) for the first time and those who did not appoint any female directors while controlling for a set of variables (i have put size as a sample here) and year and industry dummies. i am interested in creating treated and control groups wherein treated are firms who hired the female director for the first time and control firms are similar firms based on control variables who did not hire any female director (all male firm). Based on this psmatch sample i want to create two dummies of post and treatment wherein post is equal to 1 for each firm in three years following the event of hiring a female and zero for three years pre-event (we exclude the event year) and treatment is equal to 1 for three years pre and three years post hiring for all the firms who hired the female for the first time and zero otherwise (again with a window of three year pre and post the event while excluding the year of the event).


    I am attaching below the sample data and the sequence I am following.
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long gvkey double year int sic3 float(size_w aray_w total_females all_male total_board)
    1004 1996 508  6.272092  .23215203 0 1  0
    1004 1997 508  6.508111  .24361615 0 1  5
    1004 1998 508  6.588418   .2261151 0 1  5
    1004 1999 508  6.607998  .17320964 0 1  5
    1004 2000 508  6.553725   .1641182 0 1  5
    1004 2001 508  6.565545  .10916377 0 1  7
    1004 2002 508  6.531783  .09659186 0 1  8
    1004 2003 508  6.564267    .147557 0 1  7
    1004 2004 508  6.596095    .173608 0 1  8
    1004 2005 508  6.886347  .13922083 0 1  7
    1004 2006 508  6.973199  .17018114 0 1  9
    1004 2007 508  7.216717  .14865677 0 1 11
    1004 2008 508  7.228034  .16500776 0 1 11
    1004 2009 508  7.313915  .15886697 0 1 11
    1004 2010 508  7.440574  .17402378 0 1 10
    1004 2011 508  7.694235  .14796464 0 1 11
    1004 2012 508  7.667111  .14759699 0 1 11
    1004 2013 508  7.695985  .13543987 0 1 11
    1004 2014 508  7.323171  .15254125 0 1 11
    1004 2015 508  7.273856  .16829623 0 1 11
    1004 2017 508  7.329553  .13314095 1 0 12
    1004 2018 508  7.324622    .170116 1 0 12
    1013 1996 366  6.644785  .21231325 0 1  0
    1013 1997 366  6.841939  .26299286 1 0  6
    1013 1998 366  7.170571  .28140295 1 0  6
    1013 1999 366  7.422092   .2611321 1 0  6
    1013 2000 366  8.286647   .1799018 1 0  7
    1013 2001 366  7.823926  .11229347 1 0  7
    1013 2002 366  7.042461   .1231428 1 0  8
    1013 2003 366  7.167732    .108875 1 0  9
    1013 2004 366    7.2641  .13619494 1 0 10
    1013 2005 366  7.336286  .15224756 2 0 13
    1013 2006 366  7.384859  .11983369 1 0 12
    1013 2008 366  7.560601  .12524727 1 0 10
    1013 2009 366  7.203108   .1490771 1 0 10
    1034 1997 283  6.448678   .2020001 0 1  3
    1034 1998 283  6.812274   .1867502 0 1  3
    1034 1999 283  7.056405  .16311863 0 1  3
    1034 2000 283   7.38426  .15122187 1 0  4
    1034 2001 283  7.779052  .10847077 1 0  4
    1034 2002 283  7.739326  .10201775 1 0  5
    1034 2003 283  7.753309  .11096662 3 0  8
    1034 2004 283  7.602822  .11307827 3 0  9
    1034 2005 283  7.392268  .05599295 3 0 10
    1034 2006 283  6.832211  .11630982 1 0  6
    1034 2007 283  7.160974  .10110972 0 1  6
    1045 2015 451 10.787565 .029433027 1 0 11
    1045 2016 451  10.84494  .03108788 2 0 13
    1045 2017 451 10.847316 .034088258 2 0 13
    1045 2018 451  11.01172  .02816111 2 0 12
    1045 2019 451 11.002016   .0291691 2 0 10
    1055 1996 357  6.722698  .48138815 0 1  0
    1056 1996 382 4.7575736   .2989072 0 1  0
    1056 2002 382  5.763513   .2132699 0 1  8
    1056 2003 382  5.800958   .1973377 0 1 10
    1056 2004 382  6.312444  .17597495 0 1 11
    1056 2005 382  6.379867   .1717677 0 1  7
    1056 2006 382  6.458373  .18854523 0 1  9
    1072 1998 367  6.964173  .15128823 0 1  1
    1072 1999 367  7.176507  .19481233 0 1  1
    1072 2000 367  7.541735  .16252047 0 1  1
    1072 2001 367   7.43343  .07638513 0 1  1
    1075 1996 491  8.852134 .032150213 0 1  0
    1075 1997 491  8.832065  .03533595 2 0  6
    1075 1998 491  8.828281  .04419576 2 0  6
    1075 1999 491  8.796113  .04804686 2 0  8
    1075 2000 491  8.874749   .0823018 3 0 10
    1075 2001 491  8.984913  .05554823 3 0 11
    1075 2002 491  9.039055  .05315931 3 0 12
    1075 2003 491  9.162869  .04667789 3 0 12
    1075 2004 491  9.199962  .04609535 3 0 12
    1075 2005 491   9.33456  .04395634 3 0 12
    1075 2006 491  9.346264  .04329901 3 0 12
    1075 2007 491  9.327564  .04013132 2 0 11
    1075 2008 491  9.360491 .033509888 3 0 12
    1075 2009 491  9.376546 .034445092 3 0 13
    1075 2010 491   9.42244 .033934165 3 0 11
    1075 2011 491  9.481208 .030941457 3 0 12
    1075 2012 491  9.501488  .02755909 2 0 10
    1075 2013 491  9.511088 .029129185 2 0 10
    1075 2014 491   9.56896  .02760877 2 0 11
    1075 2015 491  9.617687 .024474293 1 0 10
    1075 2016 491   9.68061 .022206785 1 0 10
    1075 2017 491   9.74209  .02438839 2 0 11
    1075 2018 491  9.779295   .0227006 2 0 10
    1075 2019 491  9.824404 .020911025 2 0 11
    1076 2001 735   5.98443 .063975975 1 0  8
    1076 2002 735  6.181357   .0557699 1 0  8
    1076 2003 735  6.319494  .05560678 1 0  9
    1076 2004 735  6.551492  .04674648 1 0 10
    1076 2005 735  6.755204   .0498675 1 0 10
    1076 2006 735   6.88715  .04440051 0 1 10
    1076 2010 735  7.314601  .04637727 0 1 11
    1076 2011 735  7.458848  .05041123 0 1 10
    1076 2012 735  7.502699  .05469437 1 0  9
    1076 2013 735  7.510527  .03759025 2 0 10
    1076 2014 735  7.806633  .09421762 2 0  9
    1076 2015 735  7.885658  .14231884 2 0 10
    1076 2016 735  7.869301  .07357968 2 0 10
    1076 2017 735  7.898138  .10731563 2 0  9
    end



    Code:
    *hired female first time
    
    bys gvkey: gen hired_female=1 if total_females>0 & total_females[_n-1]==0 /// there are missing years in the data
    replace hired_female=0 if hired_female==. & all_male==1 /// I need to match firms that hired females with those that did not hire females hence I need to keep only those who hired females for the first time and match them with all male firms
    
    tsset gvkey year
    *to keep only first female hiring event per firm
    tsspell hired_female if hired_female==1
    summarize _spell, detail
    forvalues x = 1/`=r(max)'{
        gen hired_female_`x' = (_spell == `x')
    }  /// there are missing years so the code gave me a warning. Anyways, the purpose was to only keep the first female hiring event per firm and that was fulfilled i suppose. 
    
    
    drop _*
    
    psmatch2 hired_female_1 size_w i.year i.sic3 , out(aray_w) neighbor(1) noreplacement caliper(0.01)
    
    *generating treatment
    bys gvkey: egen treatment=max( hired_female_1) if _weight==1
    *generating post
    by gvkey (year): gen byte post = sum( hired_female_1 ) if _weight==1
    *alternate generating treatment
    by gvkey (year): egen byte treatment1= max(post) if _weight==1
    
    *three years window
    by gvkey (year): gen post1 = inlist(1, hired_female_1 , L1.hired_female_1 , /// 
    F1.hired_female_1) if _weight==1 /// I have doubts about this code. this did not generate what I wanted
    * i need to run a three-year window for the treatment group as well but i don't know how to do it. 
    
    
    
    *alternatively, I did this to generate post and treatment observations after psmatch2 command
    
    gen control=1 if _weight==1 & _treated==0
    gen treated=1 if _weight==1 & _treated==1
    
    *control group
    bysort gvkey: egen before_after_control = min(cond(control== 1, year, .)) 
    
    gen before_after_dummy_control = before_after_control == year
    
    forvalues i = 1/3 {
        gen before_after_dummy_cminus`i' = year == (before_after_control - `i') 
    }
    forvalues i = 1/3 {
        gen before_after_cplus`i' = year == (before_after_control + `i')
    }
    
    *treatment group
    bysort gvkey: egen before_after_treated = min(cond(treated== 1, year, .)) 
    gen before_after_dummy_treated = before_after_treated == year
    
    forvalues i = 1/3 {
        gen before_after_dummy_minus`i' = year == (before_after_treated - `i') 
    }
    forvalues i = 1/3 {
        gen before_after_plus`i' = year == (before_after_treated + `i') 
    }
    
    gen treatment=1 if before_after_dummy_minus1==1 | before_after_dummy_minus2==1| before_after_dummy_minus3==1 | before_after_plus1==1 | before_after_plus2==1 | before_after_plus3==1
    replace treatment=0 if before_after_dummy_cminus1==1 | before_after_dummy_cminus2==1 | before_after_dummy_cminus3==1 | before_after_cplus1==1 | before_after_cplus2==1| before_after_cplus3==1
    tab treatment
    gen post=1 if before_after_cplus1==1 | before_after_cplus2==1 | before_after_cplus3==1 | before_after_plus1==1 | before_after_plus2==1 | before_after_plus3==1
    replace post=0 if before_after_dummy_cminus1==1| before_after_dummy_cminus2==1 | before_after_dummy_cminus3==1 | before_after_dummy_minus1==1 | before_after_dummy_minus2==1 | before_after_dummy_minus3==1
    
    *Please suggest if I did it correctly or if there is any error in the code!

  • #2
    I'd be looking at -csdid- since the treatment does not occur at the same time for all firms.

    Comment


    • #3
      Thank you George Ford for the suggestion regarding csdid. I tried to implement csdid based on the event year, however, no observation remains after running the regression. Specifically, I run the following code

      Code:
      csdid aray_w fem_ratio size i.year i.sic3 , ivar(gvkey) time(year) gvar( treat_year )
      treat_year is the year in which the female joins the board of all male members for the first time. What I learned is that in csdid, we can not run a window of three years pre and post-event, so I am going to run the regression based on all the pre and post-year periods.

      Here is the data example for the regression

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input long gvkey double year float(aray_w fem_ratio size_w) int sic3 float treat_year
      1004 1996  .23215203         0  6.272092 508    0
      1004 1997  .24361615         0  6.508111 508    0
      1004 1998   .2261151         0  6.588418 508    0
      1004 1999  .17320964         0  6.607998 508    0
      1004 2000   .1641182         0  6.553725 508    0
      1004 2001  .10916377         0  6.565545 508    0
      1004 2002  .09659186         0  6.531783 508    0
      1004 2003    .147557         0  6.564267 508    0
      1004 2004    .173608         0  6.596095 508    0
      1004 2005  .13922083         0  6.886347 508    0
      1004 2006  .17018114         0  6.973199 508    0
      1004 2007  .14865677         0  7.216717 508    0
      1004 2008  .16500776         0  7.228034 508    0
      1004 2009  .15886697         0  7.313915 508    0
      1004 2010  .17402378         0  7.440574 508    0
      1004 2011  .14796464         0  7.694235 508    0
      1004 2012  .14759699         0  7.667111 508    0
      1004 2013  .13543987         0  7.695985 508    0
      1004 2014  .15254125         0  7.323171 508    0
      1004 2015  .16829623         0  7.273856 508    0
      1004 2017  .13314095 .08333334  7.329553 508 2017
      1004 2018    .170116 .08333334  7.324622 508    0
      1013 1996  .21231325         0  6.644785 366    0
      1013 1997  .26299286 .16666667  6.841939 366    0
      1013 1998  .28140295 .16666667  7.170571 366    0
      1013 1999   .2611321 .16666667  7.422092 366    0
      1013 2000   .1799018 .14285715  8.286647 366    0
      1013 2001  .11229347 .14285715  7.823926 366    0
      1013 2002   .1231428      .125  7.042461 366    0
      1013 2003    .108875 .11111111  7.167732 366    0
      1013 2004  .13619494        .1    7.2641 366    0
      1013 2005  .15224756 .15384616  7.336286 366    0
      1013 2006  .11983369 .08333334  7.384859 366    0
      1013 2008  .12524727        .1  7.560601 366    0
      1013 2009   .1490771        .1  7.203108 366    0
      1034 1997   .2020001         0  6.448678 283    0
      1034 1998   .1867502         0  6.812274 283    0
      1034 1999  .16311863         0  7.056405 283    0
      1034 2000  .15122187       .25   7.38426 283 2000
      1034 2001  .10847077       .25  7.779052 283    0
      1034 2002  .10201775        .2  7.739326 283    0
      1034 2003  .11096662      .375  7.753309 283    0
      1034 2004  .11307827  .3333333  7.602822 283    0
      1034 2005  .05599295        .3  7.392268 283    0
      1034 2006  .11630982 .16666667  6.832211 283    0
      1034 2007  .10110972         0  7.160974 283    0
      1045 2015 .029433027  .0909091 10.787565 451    0
      1045 2016  .03108788 .15384616  10.84494 451    0
      1045 2017 .034088258 .15384616 10.847316 451    0
      1045 2018  .02816111 .16666667  11.01172 451    0
      1045 2019   .0291691        .2 11.002016 451    0
      1055 1996  .48138815         0  6.722698 357    0
      1056 1996   .2989072         0 4.7575736 382    0
      1056 2002   .2132699         0  5.763513 382    0
      1056 2003   .1973377         0  5.800958 382    0
      1056 2004  .17597495         0  6.312444 382    0
      1056 2005   .1717677         0  6.379867 382    0
      1056 2006  .18854523         0  6.458373 382    0
      1072 1998  .15128823         0  6.964173 367    0
      1072 1999  .19481233         0  7.176507 367    0
      1072 2000  .16252047         0  7.541735 367    0
      1072 2001  .07638513         0   7.43343 367    0
      1075 1996 .032150213         0  8.852134 491    0
      1075 1997  .03533595  .3333333  8.832065 491    0
      1075 1998  .04419576  .3333333  8.828281 491    0
      1075 1999  .04804686       .25  8.796113 491    0
      1075 2000   .0823018        .3  8.874749 491    0
      1075 2001  .05554823 .27272728  8.984913 491    0
      1075 2002  .05315931       .25  9.039055 491    0
      1075 2003  .04667789       .25  9.162869 491    0
      1075 2004  .04609535       .25  9.199962 491    0
      1075 2005  .04395634       .25   9.33456 491    0
      1075 2006  .04329901       .25  9.346264 491    0
      1075 2007  .04013132  .1818182  9.327564 491    0
      1075 2008 .033509888       .25  9.360491 491    0
      1075 2009 .034445092 .23076923  9.376546 491    0
      1075 2010 .033934165 .27272728   9.42244 491    0
      1075 2011 .030941457       .25  9.481208 491    0
      1075 2012  .02755909        .2  9.501488 491    0
      1075 2013 .029129185        .2  9.511088 491    0
      1075 2014  .02760877  .1818182   9.56896 491    0
      1075 2015 .024474293        .1  9.617687 491    0
      1075 2016 .022206785        .1   9.68061 491    0
      1075 2017  .02438839  .1818182   9.74209 491    0
      1075 2018   .0227006        .2  9.779295 491    0
      1075 2019 .020911025  .1818182  9.824404 491    0
      1076 2001 .063975975      .125   5.98443 735    0
      1076 2002   .0557699      .125  6.181357 735    0
      1076 2003  .05560678 .11111111  6.319494 735    0
      1076 2004  .04674648        .1  6.551492 735    0
      1076 2005   .0498675        .1  6.755204 735    0
      1076 2006  .04440051         0   6.88715 735    0
      1076 2010  .04637727         0  7.314601 735    0
      1076 2011  .05041123         0  7.458848 735    0
      1076 2012  .05469437 .11111111  7.502699 735 2012
      1076 2013  .03759025        .2  7.510527 735    0
      1076 2014  .09421762 .22222222  7.806633 735    0
      1076 2015  .14231884        .2  7.885658 735    0
      1076 2016  .07357968        .2  7.869301 735    0
      1076 2017  .10731563 .22222222  7.898138 735    0
      end


      Here is the picture of the output.

      Click image for larger version

Name:	did output.png
Views:	1
Size:	21.5 KB
ID:	1699347



      Can you please guide what is wrong here?

      Comment


      • #4
        You're not new here, so you should know better than to post screenshots. As the FAQ says, they do not help us help you.

        -csdid- is telling you what's wrong. Your panel isn't balanced, and you need for it to be balanced.

        Comment


        • #5
          Thanks Jared Greathouse. Apologies for posting the picture. It was a mistake. What do you think can be a possible solution? the regression omits the interaction term of the treatment and post if I run the model based on calculations of the code in 1.

          Comment


          • #6
            You need to have the same number of observations in each panel. How you do that isn't really for me to comment on, but that seems to be the issue.

            Comment


            • #7
              csdid doesn't require a strongly balanced panel. I'm not too familiar with this command, but I can see an issue with your gvar variable, which should be set up as follows

              Code:
              egen first_treat = max(treat_year), by(gvkey)
              Also, I'd remove i.year from your csdid call.

              Comment


              • #8
                Thank you Justin Niakamal and Jared Greathouse. Though the csdid did not work for me, I have resolved the issue with the classical did command with the code in 1.

                Comment


                • #9
                  Hi Asad.
                  If you can send me your data I can try check why it didnt work (specially if its a bug in csdid)
                  F

                  Comment


                  • #10
                    Dear FernandoRios,

                    Please find the data sample below

                    Code:
                    * Example generated by -dataex-. To install: ssc install dataex
                    clear
                    input long gvkey double year float(aray_w fem_ratio size_w) int sic3 float treat_year
                     14590 1996   .06124639         0  8.259855 100    0
                     10884 1996   .10283697         0  7.810731 100    0
                     11993 1996   .03183024         0  8.822617 100    0
                     10390 1996      .09084         0 4.7575736 100    0
                      8596 1996   .17088607         0   7.25982 100    0
                     10884 1997   .11334632         0  7.783896 100    0
                     14590 1997   .03121495      .125  8.331396 100    0
                     14881 1997   .15013345         0  6.108358 100    0
                     11993 1997   .03111937  .6666667   8.77323 100    0
                      8596 1997   .18777293         0  7.379632 100    0
                     10390 1997   .13263623         0 4.7575736 100    0
                     10390 1998    .1007889         0 4.7575736 100    0
                     28524 1998   .43822455         0  5.528599 100    0
                     14590 1998   .05450082      .125 8.3410845 100    0
                     10884 1998   .13146652         0  7.827693 100    0
                     11993 1998   .02190601  .6666667  8.583168 100    0
                      8596 1998   .23296447         0  7.448334 100    0
                     14881 1998    .1176371         0  6.381477 100    0
                     14590 1999   .04231339      .125  8.314567 100    0
                     10390 1999   .05484107         0 4.7575736 100    0
                     10884 1999   .13912956         0  7.861776 100    0
                     14590 2000   .03773596  .0909091  8.281658 100    0
                     10390 2000   .08383612         0 4.7575736 100    0
                     28524 2000    .4647249         0   5.96649 100    0
                     10884 2000    .1226809         0  7.790195 100    0
                     10390 2001           .         0 4.7575736 100    0
                     28524 2001    .4281118         0   6.01986 100    0
                     14590 2001   .02816073 .07692308  8.345676 100    0
                     28524 2002    .3807361         0  5.948406 100    0
                     14590 2002   .04544376 .07692308   8.34098 100    0
                    140760 2003    .2888701  .2857143  9.154933 100    0
                     28524 2003    .3868642         0  6.067388 100    0
                     14590 2003   .04163306 .07692308  8.459218 100    0
                    140760 2004   .21595374 .22222222  9.123038 100    0
                     28524 2004    .4042663         0  6.124734 100    0
                     14590 2004   .08552437         0  8.534443 100    0
                    140760 2005   .17421307 .22222222  9.266626 100    0
                     28524 2005    .5209662         0  6.084918 100    0
                     14590 2005   .12395377  .0909091  8.621591 100    0
                     28524 2006   .53402835         0  6.227038 100    0
                    140760 2006    .1533936 .22222222  9.369735 100    0
                     14590 2006   .09012743  .0909091  8.592264 100    0
                    140760 2007   .14680736 .11111111  9.471396 100    0
                    140760 2008    .1561336 .11111111  9.797626 100    0
                     14590 2008   .05189911         0  10.05848 100    0
                     14590 2009   .06935682     .0625 10.165698 100    0
                    140760 2009   .12362253        .2   9.79127 100    0
                    140760 2010   .12922922  .1818182  9.789871 100    0
                     14590 2010   .08252229         0 10.288274 100    0
                    140760 2011   .13837937        .3  9.895657 100    0
                     14590 2011  .035609603         0 10.375676 100    0
                     14590 2012   .04596501         0 10.475596 100    0
                    140760 2012    .1244561 .27272728  9.914625 100    0
                    140760 2013    .1191928 .27272728  9.936149 100    0
                     14590 2013   .04036362         0  11.05837 100    0
                    140760 2014   .12879305       .25  9.997933 100    0
                     14590 2014   .04359214      .125 10.981812 100    0
                     14590 2015   .04888679      .125 10.748862 100    0
                    140760 2015   .11126824 .23076923  9.995154 100    0
                    140760 2016   .13584313 .23076923    9.8902 100    0
                     14590 2016   .05611384       .25 10.527205 100    0
                     14590 2017    .0421157  .2857143 10.526802 100    0
                    140760 2017   .14006469 .23076923  9.968011 100    0
                     14590 2018   .03131514  .2857143 10.650555 100    0
                     30443 2019    .1310487       .25  8.116686 100    0
                      3107 2019   .04355272 .27272728  8.161603 100    0
                     14590 2019   .02859663        .4 10.616658 100    0
                      7881 1996  .013787112         0  7.640639 104    0
                     30344 1996 .0007469064         0  7.170142 104    0
                     10174 1996   .02487534         0 4.7575736 104    0
                      5560 1996   .09474912         0  5.592453 104    0
                      5686 1996  .032150153         0  7.301221 104    0
                      7881 1997   .01450201         0  8.192566 104    0
                      5686 1997  .030938225         0   7.17375 104    0
                      5560 1997   .10068297         0  5.524129 104    0
                      7881 1998  .016338255         0  8.066758 104    0
                      5686 1998   .02785441         0  7.407033 104    0
                      5560 1998    .1071403         0  5.529675 104    0
                      5560 1999   .10881773         0  5.592318 104    0
                      7881 1999  .011985936         0  8.126631 104    0
                      5686 1999  .027524535         0  7.399073 104    0
                      3153 1999   .04342926         0   5.86943 104    0
                      7881 2000  .004899018         0  8.163572 104    0
                      3153 2000  .035780482         0  5.603509 104    0
                      5686 2000  .028607976         0  7.213727 104    0
                      5560 2000   .05729947         0  5.272158 104    0
                      7881 2001  .004608749         0  8.328858 104    0
                      5560 2001   .04341806         0  5.031196 104    0
                      3153 2001  .028053997         0  5.348916 104    0
                      7881 2002 .0043832706         0  9.225674 104    0
                      7881 2003  .008206749         0  9.310202 104    0
                      7881 2004  .016481258         0  9.454907 104    0
                      7881 2005  .016437965         0  9.546241 104    0
                      7881 2006  .022947246 .14285715   9.65509 104 2006
                      7881 2007   .02211822 .16666667  9.654898 104    0
                      7881 2008   .02121346  .1818182  9.670231 104    0
                      7881 2009   .02470963 .16666667 10.012297 104    0
                      7881 2010  .026107626  .1818182 10.152805 104    0
                      7881 2011  .023003567        .2 10.220995 104    0
                      7881 2012  .032715008 .27272728 10.297217 104    0
                      7881 2013   .02471329        .3 10.117146 104    0
                      7881 2014   .02408091  .3333333 10.123265 104    0
                      7881 2015  .017671352  .3333333 10.133884 104    0
                      7881 2016  .016309258        .3  9.953753 104    0
                      7881 2017  .011525556        .3  9.931249 104    0
                      7881 2018  .016702872  .4166667  9.938613 104    0
                      7881 2019  .009331065  .4166667 10.595984 104    0
                     31203 1997  .030215645         0  5.434678 109    0
                     31203 2001  .025077716         0  6.766446 109    0
                     31203 2002  .020396756         0  6.818065 109    0
                     31203 2012  .005264013 .14285715  7.544736 109 2012
                     31203 2013  .006674191      .125  7.205398 109    0
                     31203 2014 .0009125816 .14285715  7.243747 109    0
                     31203 2015 .0006239227 .14285715  7.156341 109    0
                     31203 2016 .0012215183 .14285715  7.190704 109    0
                    141400 1996           .         0         . 122    0
                     28591 1996   .12525372         0  6.561004 122    0
                    141400 1997           .  .3333333         . 122    0
                     28591 1997   .09721912         0  6.483386 122    0
                     28591 1998   .14078888         0  6.463753 122    0
                    141400 1998  .073397726       .25  7.515855 122    0
                    141400 1999   .07145465 .22222222  7.590851 122    0
                     15274 1999    .4871601         0  8.073368 122    0
                    141400 2000    .0997506 .22222222  7.678387 122    0
                     15274 2000    .5072562         0  8.038613 122    0
                     15274 2001    .5766946         0  8.107081 122    0
                    141400 2001   .08849473       .25  7.726947 122    0
                     14793 2002   .07642908         0  7.688367 122    0
                    141400 2002    .0813016 .14285715   7.71487 122    0
                     14793 2003       .0621         0  7.778064 122    0
                    141400 2003   .07082059 .14285715  7.773484 122    0
                    141400 2004   .07761463 .14285715  7.882657 122    0
                     14793 2004  .066115975         0  8.088419 122    0
                    141400 2005    .0570946      .125  8.001828 122    0
                     14793 2005   .07196733 .11111111  8.023369 122 2005
                     14793 2006   .07852683  .0909091  8.107965 122    0
                    141400 2007   .06043128         0  7.958811 122    0
                    141400 2008   .06526053         0  8.209536 122    0
                    141400 2009   .03477222        .1   8.24267 122    0
                    141400 2010  .066728085         0  8.436196 122    0
                    162448 2011   .05799478         0  9.711771 122    0
                    180635 2011   .04126987         0  7.749029 122    0
                    162448 2012   .05063559 .11111111  9.479589 122 2012
                    180635 2012   .03303587         0  7.762733 122    0
                    162448 2013   .04347494 .11111111  9.375792 122    0
                    180635 2013  .031733777         0  7.765325 122    0
                    180635 2014    .0403094         0  7.677825 122    0
                    162448 2014  .034984708 .11111111  9.281372 122    0
                    180635 2015   .02889144         0  7.496741 122    0
                    180635 2016  .029690174         0  7.447038 122    0
                    180635 2017   .02970093 .16666667  7.437619 122 2017
                    180635 2018   .05312516 .16666667  6.833738 122    0
                     32372 2018   .04670654         0  7.923249 122    0
                     30397 2019   .08498554 .14285715  7.203602 122    0
                     32372 2019   .06409974 .16666667  7.898709 122 2019
                      8468 1996   .06069655         0   8.32464 131    0
                      8549 1996   .14673753         0  9.513994 131    0
                     11038 1996   .11257262         0  9.118554 131    0
                     14878 1996           .         0  7.567863 131    0
                     11923 1996   .08777916         0  7.857105 131    0
                      6819 1996    .1104191         0  7.218763 131    0
                      8068 1996   .04939322         0  9.777584 131    0
                      7017 1996   .06038814         0 9.2253275 131    0
                      7276 1996    .0522375         0  7.101576 131    0
                      8655 1996   .13575187         0  6.172206 131    0
                     10743 1996   .06618306         0  6.818404 131    0
                      7620 1996   .14246501         0   7.71592 131    0
                      1678 1996   .06836148         0  8.141024 131    0
                     12045 1996   .04978723         0  7.571476 131    0
                      9406 1996   .09741072         0  7.021084 131    0
                     15084 1996   .07831325         0  8.370085 131    0
                      7912 1996   .10534365         0  7.579136 131    0
                      6403 1996   .12003841         0  8.046869 131    0
                      1380 1996   .10895126         0 8.9598875 131    0
                     14359 1996   .06914778         0  7.089964 131    0
                      7466 1996   .13307545         0  7.524408 131    0
                      1380 1997   .12516014 .14285715  8.978991 131    0
                      6403 1997    .0885013 .16666667  8.037867 131    0
                     22255 1997    .0394094         0   6.30278 131    0
                      8655 1997    .1278286         0  6.517106 131    0
                     28651 1997   .08929465         0  6.785616 131    0
                     11038 1997    .1191235 .16666667   8.92665 131    0
                     22974 1997  .073460564         0   6.89776 131    0
                      8549 1997   .12388168  .3333333  9.536762 131    0
                     28256 1997   .05580027         0  6.670075 131    0
                      9406 1997   .08987197        .2   6.67064 131    0
                      7620 1997   .12171947        .2   7.71348 131    0
                     14878 1997           .       .25  7.653495 131    0
                      7912 1997   .08673334         0  7.536622 131    0
                     10743 1997   .05931028         0  7.001281 131    0
                     12045 1997    .0406479         0  7.611623 131    0
                     15084 1997   .06459371 .16666667  8.669228 131    0
                      8468 1997   .05317476         0  8.390697 131    0
                      8068 1997   .05319984 .11111111  9.634431 131    0
                      7017 1997   .08102224         0  9.265302 131    0
                     11558 1997   .05407454         0  5.539521 131    0
                     29173 1997   .09776182         0   6.31648 131    0
                      8049 1997   .12368675         0 4.7575736 131    0
                     20548 1997   .11013556         0  6.294906 131    0
                      8627 1997    .1788678         0   6.32224 131    0
                    end

                    Comment


                    • #11
                      Ok, the problem is that your "treat_year" is not correctly defined, because takes values other than zero only the same year it happens.
                      try the following
                      gen tt=treat_year>0
                      egen gvar=csgvar(treat), ivar(gvkey) tvar(year)

                      and redo the analysis with gvar

                      Comment

                      Working...
                      X