Announcement

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

  • csdid with three cohorts

    Dear all,

    I'm trying to implement a staggered diff-in-diff estimation model with time variation of treatment effects.

    My dataset is a sample of firms which receive a treatment in different point in time (2009q2; 2010q2; 2011q3). As a result I have three different cohorts.

    I try to estimate the average treatment effects across cohort by using the -csdid- command.

    Code:
    csdid ESGScore size lev mtb roa cash divid capex ppeg salesgr cfo cur_rat, ivar(cusip_id) time(calendar_qtr) gvar(first_treat) method(dripw) agg(group) notyet
    where -ESGScore- is my outcome of interest and from -size- to -cur_rat- I have my control variables.
    I identified the treatment period of each observation with a variable -first_treat- (i.e. a variable that tells me the first time the firm has been treated. Then I carry backward and forward that identification date value across the panel)

    There is the option -notyet- because I don't have firms never treated. Throughout the time, all firms receive the treatment.
    The issue is that when I run the -csdid- command as above I have this outcome
    Click image for larger version

Name:	DiD.png
Views:	1
Size:	17.4 KB
ID:	1656250







    I'm wondering why I don't have the ATT for the third cohort?

    It's the first time that I implement -csdid- so it might be that I'm missing something.
    FernandoRios , I kindly ask your specific help regarding this command. In case you have any advice. Many thanks

    Below, an example of my dataset



    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(cusip_id calendar_qtr first_treat) double ESGScore float(size lev mtb roa cash divid capex ppeg salesgr cfo cur_rat)
     1717 162 205 .         .         .          .            .          .           .           .          . .            .         .
    11056 162 205 . 3.0105224  .4631491   .7113667   .015842067          .           0   .00536193  .33360955 .    .04245674  5.506432
     1739 162 205 .         .         .          .            .          .           .           .          . .            .         .
     8859 162 201 .   8.62513  .7456099  1.0718229    .04286504 .004225761           .           .   .4906725 .            .  .7566832
    12521 162 201 .  8.162637   .619559   1.221232   .015227363          .   .03144017 .0002506643          . .    .04467605         .
     1164 162 201 .   8.13088  .4730813          .    .05778094          .           0    .2217634   .4594994 .    .18458244 2.0917983
     1175 162 205 .  4.173787  .3289204          .    .03358446          .           0   .02935383   .3935253 .    .06627988   3.96497
     9260 162 205 .  2.704042  .5056225   .6171811   .005174821          .           0  .002451231  .14026487 .   -.11779526 2.2012725
    14174 162 205 .   5.06636 .11009105          .            .          .           .           . .015422817 .            .  9.636494
    14200 162 205 .  3.105349  .6173321          .            .          .           .           .          . .            . 1.1057146
     9945 162 205 .  5.855665    .15575   8.135866      .068892          .           0    .1812927   .2055621 .    .09153683 4.6512103
      587 162 205 .  3.711472 .37979665  3.1304395     .0898808          .   .05098499    .0821202    .715369 .    .19728632  .8949946
     9997 162 201 .  7.866638  .6269057   1.749897    .03871606          .           0   .04337056   .7740817 .    .02071698 1.0839332
    11513 162 205 .  6.877117  .4362587    .748989   .032063063          .   .01945813   .05802334   .3525617 .    .07519276 4.0344753
     9259 162 205 .  3.795062  .3298037  16.075735   -.03816701          .           0   .07696964  .20312357 .   -.08795665  3.764005
     8844 162 205 . 2.6732516 .13991855  14.266404   -.21031325          .           0   .04028916  .09953414 .    -.4303293  5.281697
    12715 162 201 .  7.439071  .5233025   2.997776    .04575763          .           0   .04437522   .5338311 .    .09541574  1.867141
       46 162 205 .  5.228635 .51341283   .3716462   .014444145          .           0   .02695837   .2155185 .   -.04494345 3.3292935
    12419 162 201 .   6.66012 .50464934   7.361979            .          .           0   .06817951  .11048158 .    .09261508 11.602832
       34 162 197 . 10.542812  .8917265          .            .          . .0016093288 .0003650682 .012803463 .    .06813737         .
     3675 162 205 .  6.848838 1.2323043 -.10860642   .035465416          .           0   .02462749   .4441699 .  -.024314225   .440455
     2033 162 205 .         .         .          .            .          .           .           .          . .            .         .
    13699 162 205 .  4.426916 .18440835   2.564921    .06692289          .   .04288122   .12341386   .6097121 .     .1761591 2.0984213
     4058 162 205 .         .         .          .            .          .           .           .          . .            .         .
     1919 162 201 . 4.7281575  .2575716   1.923916    .04228651          .           0    .0430421  .23365587 .    .13199757 3.2869086
     6458 162 205 . 4.1067176 .16338256   4.243679            .          .           0           .          . .            . 10.959726
     8486 162 205 .  8.215322  .8661453   .5165787   .003758709          .           0           0          . .   .031744014         .
    10724 162 197 .  8.531191  .6274631   6.006215    .08447158          .  .026995275  .011597147   .0897523 .   .062948704  1.234882
     2581 162 201 .  5.238759  .2012991          .    -.0752723          .  .036070604   .02975597  .13280527 .    -.2649679  6.629703
    10648 162 201 .   5.75483  .7425249   5.473234   .025786527          .  .014342185   .03682316  .15699776 .   .009051853  .8510608
    12678 162 205 .  4.434263   .653565   .8863738    .02470279          .  .003559141    .3006789   .8259319 .   .072833546 1.1629992
     1337 162 201 .  9.106756  .9282521          .   .007620651          .           .           .  .01440397 .            .         .
     3198 162 201 .  7.757931  .7649482  1.4821112            .          .           0           .          . .            .  2.078471
     5834 162 205 .  5.759567  .9768072  11.532588    .06460729          .           0   .13065045  .36967105 .    .15164465 1.0966895
     5108 162 205 . 4.5645356  .3067758  2.7874644            .          .  .008321356           0  .13271536 .   .025594866   6.60692
    13071 162 205 .  12.37916 .13760704          .            .          . .0024313966           .          . .            . 2.8421924
    11593 162 205 .   6.30232 .45427665   .7767091    .01904036          .           0   .03044014  .08789437 .   .031968992         .
     9263 162 201 .  6.812297  .8049421  1.7725058            .          .           0  .030814227  .16160735 .   .033687662     .7496
    13395 162 205 . 2.6333985  .6786869  1.2308283  .0003037091          .           0  .020348506  .40089595 .   -.07600319  1.350954
     9546 162 205 .  6.476024  .4984447  1.1509856            .          .  .029897565           0          . .    .04434728         .
     1659 162 205 . 4.7577195  .6188101   .9081094            .          .           0  .037056535  .07787094 .    .04095136  .9433692
     2322 162 205 .  2.643476  .3424833   2.990266    .08122823          .           0   .27025262   .8042973 .     .2058653  .7517867
    13243 162 205 .   7.73761  .8888881          .   .006204254          .           .           . .023673635 .            .         .
     5188 162 205 .  2.994682 .29210672   1.213931            .          .   .01271335      .07972   .1431737 .    .13642544 2.9362576
     3438 162 205 .  6.828034  .3519917   .4338639   .004468592          .  .003822936  .010060942  .08432043 .  -.012189472    6.9703
     9427 162 201 .  6.643393  .6584359  1.2362876    .05746971          .  .003998984   .02366424  .15320566 .   -.07404339  2.653811
     3770 162 201 . 9.0050955  .6633481  .26874313    .01241984          . .0013632543  .019495707   .4431586 .    .06189856  2.622879
     9581 162 197 .  7.828397  .7530326  26.788557            .          .  .008894811           .          . .            .  1.281754
     2667 162 205 . 3.6121604 .17224532   1.008657    .02235173          .           0   .15802537   .8907233 .     .1531985  .7158753
     3932 162 205 .  4.482539 .17989124   11.33462            .          .           0           .          . .            .   9.37874
    14037 162 201 .  7.387352 .53192043          .   .015370923          .           .           .   .1696113 .  -.030758677 2.2761872
      974 162 201 .  7.723332  .9060549  1.7971756   .027491193          .  .002912656    .0453355   .6345334 .     .0559465  .7412569
    12524 162 205 .  3.743107    .59336  .52703524   .035620376          .           0  .028795475   .2877444 .  .0045577255 1.2576902
     2571 162 205 .  6.852143  .9293576          .   .005834902          .           .           .  .00934154 .            .         .
     1443 162 205 .  5.951715  .9150001          .   .007750934          .           .           .  .00660627 .            .         .
     3408 162 205 .  6.271638  .4457461  2.9025304  -.019497063          .           0  .035430104  .05385209 .   -.16560484  .8616663
     5957 162 205 .  4.507513  .6776925    .466954            .          .  .013550763           0          . .    .02859717         .
     8446 162 205 .  5.285202  .4745585  1.1768849   .037130747          .           0   .00707847   .3081957 .   .032699835  2.160521
     1141 162 205 .  5.921552  .7912357   .5751466   .007918614          .           0 .0007515415          . .   .027165206         .
     7544 162 201 .  6.965368 .58405936   1.241557    .05857951          .  .003732636           0 .002900473 .    -.1058328         .
      436 162 201 .   6.88442   .440017    1.44608    .05432484          .   .01505832   .04132806   .4961309 .    .12363583 2.1880116
     4978 162 201 .  8.050263  .7506707   2.076004   .005598946          .  .016633265  .029401524   .3834697 .    .06047234 1.0191048
    13707 162 205 .         .         .          .            .          .           .           .          . .            .         .
    13675 162 201 .  7.897913 .39870235   3.402879   .012273638          .           0  .009722014  .08291313 . -.0035975776 3.2802854
    10964 162 201 .  7.023561   .518668  1.2096968    .02233472          .           0   .04135999   .4675177 .    .03544647  4.574239
    10093 162 205 .  6.305129   .471418    .782564            .          .   .00720351           0          . .   -.00596372         .
    11337 162 205 .  7.410995  .7319922   .7743193    .03777938          .           0  .034622397  .04344322 .   .033685092 1.3464807
    13249 162 205 .  7.221001  .9125662          .   .007194922          .           .           .  .02149165 .            .         .
     4198 162 205 . 3.3755376 .28491792   .3518007  .0043157474          .  .006155951 .0011741372  .05137644 .   .014533915 4.3837533
      732 162 205 . 4.5149827   .397194  1.2969925            .          .           0  .010129306   .1952987 .  -.014280494 1.5158124
    11578 162 201 .  6.385208  .6623705  2.8389156    .03895241          .           0  .013462705  .12511168 .    .00923026  1.945245
     5893 162 201 .  5.562119 .28088441   2.169961    .05933297          .           0   .09353508   .3205304 .    .13554703 3.0176916
    13421 162 201 .  6.294731  .4023943          .    .04392084          .  .008028281   .01283258   .1857562 .  .0004599624  7.187948
     4223 162 205 .  5.441361  .6495086   .4331991    .02476634          .           0  .008904751  .04206346 .   -.01494726  8.289263
     6199 162 205 .  4.494149  .5417691   .3893615  -.005367978          .           0  .019780183  .16510597 .   -.08183184 1.9310915
    13054 162 205 .   7.55017  .4177435   14.46652            .          .           0    .0481617  .07594889 .    .08158159 12.429214
     6569 162 205 .  7.423398 .56440765   .3035601   .001631431          .           0  .016265452  .14221278 .   -.05344993 1.9992297
    12735 162 201 .  5.091238  .2245635   1.205927    .04541375          .           0   .15754615   .5567563 .    .02309992  2.140835
     6753 162 197 .  7.870612  .6304586  2.0374057    .02610851          .           0   .04508202  .29051316 .    .04256862 1.0186433
      316 162 201 .  5.853739  .5563602   5.402216     .0716973          .           0   .07364646  .20568693 .    .06756282 2.0663385
     4041 162 205 .  4.448259  .5651396  1.0544198    .05695616          .    .0140504   .04614978   .3237584 .    .09081939  2.964731
     5259 162 205 .  2.854399  .2457959   .5927383            .          .           0           .          . .            . 2.2770822
     7741 162 201 .  8.571537  .8691546  1.6089678 -.0023134442          .           0           0          . .   .004926193         .
     7368 162 205 .  4.826985  .3558085   .8512877    .04409377          .   .01668616   .01440713  .11592212 .    .09514061 1.8995655
    10629 162 205 .  3.146477 .07228864  1.5158473   -.05944825          .           0   .02832066   .4630596 .    -.1507363  7.144557
    12621 162 197 .         .         .          .            .          .           .           .          . .            .         .
    12696 162 205 .  6.010247  .9454836          .  .0005598032          .           .           .  .02612173 .            .         .
     3697 162 205 .         .         .          .            .          .           .           .          . .            .         .
    11184 162 205 .  7.531128  .9091008          .   .006744571          .           .           . .025511524 .            .         .
     8742 162 197 .  10.93184  .8598354          .            .          .           0           .          . .            .  .9038271
     3661 162 201 .   5.73094  .6185642   2.733001    .10139057          .           0     .209624   .8383147 .    .23396015 1.1346033
      701 162 205 .         .         .          .            .          .           .           .          . .            .         .
    11136 162 205 .  4.819103 .08451887          .   .005709975          .           0           .  .04653144 .   -.06785462  10.41054
      784 162 205 .   6.15765  .6076004  1.3874477   .012658502          .           0   .02961791  .18544045 .   .021340284         .
     6453 162 205 .  6.564983 .59213865   .3433312    .04712852          .           0    .0068673   .1147243 .     .1561974  1.496805
     5902 162 201 .  5.498815 .59454095   .5059047 -.0004755178          .    .0247052   .04577359   .6914109 .   -.01880493 .55671304
     4196 162 205 .  5.700333 .23847783  1.2275796            .          .           0           .          . .            .         .
     3959 162 205 .  3.382524  .6298523          .            .          .           .           .          . .            .         .
    10639 162 205 . 1.3467736 .28582576  2.5967884   -.05470175          .           0  .021099245    .167752 .   -.14665277 1.8935395
     7253 162 205 .         .         .          .            .          .           .           .          . .            .         .
    end
    format %tq calendar_qtr
    format %tq first_treat
    Last edited by Marco Errico; 25 Mar 2022, 10:48.

  • #2
    Hi Marco
    1 short answer and 1 suggestion.
    1) if you have only 3 points in time, and are using not yet as reference, you cannot estimate effects for the last cohort, because there is no comparison group (everybody else was already treated)
    2) I would suggest to recode your time variable. from whichever format it has to only = 1, 2, 3.
    F

    Comment

    Working...
    X