Announcement

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

  • Scul, donoradj, multiple treted units and synthetic control

    Hello Jared Greathouse ,


    It seems that you are the appropriate correspondent on my subject, as I intend to us the scul package for my analysis "The effect of inter-organizational collaborations reform on transfers between French public hospitals"

    For now I use a regular DiD regression analysis with two different control groups, but as with the majority of wide ranging Public Policy, both of my control group are not random at all.


    Here is an exemple of my data:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
     id  year yit pred_output pred_outputsq techefficiency hhi_zrsqrt hhi_zr int r80 score_esatis esatis_miss rh30_stand tx_morta_30j ghm3_4 bedblock alone housecon nosocial age_median pctsexe IMR
     1 2013  1.736461  1.1665902  1.3609327  -.3784718  .06308113 .0039792294 341     0 1  .12629741  .004746761  .05  .01731738  .004722922 .003148615  .05037783   63      .463  .2001672
     1 2014  1.784329  1.1914508   1.419555  -.3681692  .06772107 .0045861434 351     0 1  .13382226  .004832016 .048  .03194451  .007605835  .01064817  .05019851   64      .472 .21172294
     1 2015 1.6292444  1.2057023   1.453718  -.3638036  .06097652 .0037181356 352     0 1  .13298072  .005372833  .05  .07747664 .0014899354 .011919484 .074496776   64      .483  .2140295
     1 2016  1.674268  1.1998575   1.439658  -.4126975  .06588429   .00434074 353     0 1  .13547793  .005708918  .05  .12968656 .0043714573  .02331444  .05537179   65      .507  .2316775
     1 2017 1.7336923  1.1768126   1.384888  -.5057704  .06599804 .0043557417 348 71.07 0  .12865204  .004620602 .047  .11111586  .007122811  .04985968 .028491246   65       .49 .24152154
     1 2018 1.7524136  1.1853139   1.404969  -.5050719 .063318744 .0040092636 343 75.09 0  .13070688  .005455788 .044  .10399247  .014053036  .06183336  .04778032   65      .487  .2293208
     1 2019 1.7517908  1.1755782  1.3819842  -.5185177   .0634391  .004024519 334 73.94 0  .12603237  .005181639 .047  .10758472  .022649415  .09342884 .032558534   66      .478 .24060562
     1 2020  1.749198  1.1316744   1.280687  -.5202639 .063324645 .0040100105 334 72.97 0  .11696005  .006155661    0  .17788455   .02432609  .08210056  .02736685   66      .483 .26080182
     1 2021 1.7840792  1.1830986  1.3997222  -.4591466  .05124504  .002626054 318     0 1  .12186077  .006238575    0  .18313155    .0755781 .068310976   .0290685   66      .487  .3433572
     2 2013  5.602523   .2614765 .068369955   .6149461   .2161759   .04673202 254     0 1   .1088779  .014140875 .143 .067096084  .067096084 .026838433   .5367687   56      .452  .2001672
     2 2014  5.580445  .27524924  .07576215   .6219309   .2154063   .04639988 254     0 1   .1167754   .01159573 .165  .13176967  .026353933  .10541573   .6324944   58      .455 .21172294
     2 2015 4.1726522   .3106742  .09651847   .6978909  .21319814   .04545345 264 70.57 0  .12692028  .010530422 .177  .13059945    .1175395   .3656785  .50933784   59      .471  .2140295
     2 2016 4.1721935  .22957987  .05270692  .37012765  .23878112   .05701643 284 70.13 0   .1205603  .009270407 .177  .10852526  .072350174  .12058362   .3255758   62      .477  .2316775
     2 2017  4.294554   .2664633  .07100269  .50353795  .23798504   .05663688 289 69.76 0  .12326622  .011987147 .192 .024752475    .4331683 .074257426   .4207921   62      .465 .24152154
     2 2018 4.7381244  .27954435  .07814504   .5120944  .23519003   .05531435 281 71.79 0   .1145336  .009484436 .196   .3288672    5.115713   .4628502   .5602923   63      .479  .2293208
     2 2019  4.641505  .28281462  .07998411   .5246671  .28086498   .07888514 283 70.93 0  .10341528  .009649444 .193   .0977159    8.415781   .6351533  .50079393   63      .457 .24060562
     2 2020  6.112335   .2496339  .06231709   .6242009  .24343805   .05926208 283 74.21 0   .1145904  .012515472    0  .09636564    9.471366  .53689426   .3303965   63      .467 .26080182
     2 2021  4.919976  .28949082  .08380494  .49585465  .18907157  .035748057 267     0 1  .11617166  .008414316    0  .07113219    8.678127  .28452876  .32009485   63       .48  .3433572
     3 2013 37.636887  -.3976861  .15815423  1.1805428   .1111081  .012345009  97     0 1  .15265006   .02764977 .449    .518732    .4034582  .23054755  .17291066   85      .405  .2001672
     3 2014 37.332993  -.3708866  .13755685  1.0722779  .10806213  .011677423 106     0 1  .05797906   .02720739  .42   1.438849   .15416238   .2569373  .05138746   84      .397 .21172294
     3 2015 35.982864  -.3066886  .09405788  1.1175047  .12358624   .01527356 115     0 1  .05837222   .02901998 .437   .4759638   4.6644454   .2379819  .09519277   84      .424  .2140295
     3 2016 36.984127 -.29757524  .08855102  1.0663408  .11677724  .013636923 111     0 1  .10976562  .028429603 .428  .09070295    20.27211   .8163266  .13605443   84       .39  .2316775
     3 2017  38.69622  -.2759825  .07616634  1.0712303   .1322464  .017489111 124     0 1  .07188526  .027510917 .478  .17559263    21.64179   1.097454   .4389816   84      .387 .24152154
     3 2018  42.38351 -.22811563  .05203674   1.223674  .12247716  .015000654 120     0 1   .1601802   .03297683 .515   .4480287    23.29749   1.657706   .8064516   84      .392  .2293208
     3 2019  40.03864 -.26973182 .072755255  1.0530697  .15221286   .02316875 108     0 1  .14748935   .02991453 .514   9.059682    27.13611   .9446114  1.2022327   84      .419 .24060562
     3 2020  40.38172  -.3444404  .11863917  1.1042336  .13038336  .016999818  99     0 1  .08826672  .028414754    0   8.488197    23.80713   .3013561  1.0045203   84      .421 .26080182
     3 2021  40.57528  -.3055967  .09338937  1.5058614  .10489064  .011002045  98     0 1  .10538717   .03658537    0   8.629131     24.6634   .4895961  1.1015912   84      .396  .3433572
     4 2013  11.11111 -2.2176068    4.91778   .7057489  .25386366  .064446755  35     0 1 .006843676   .06837607 .385  1.7094017           0          0          0   87      .333  .2001672
     4 2014        10  -2.232484   4.983985   .7628499  .21570234    .0465275  32     0 1          0   .02727273 .436   7.272727           0          0          0   85      .227 .21172294
     4 2015      12.5  -2.192268   4.806038   .8927678   .3735643   .13955027  39     0 1          0    .0462963 .389  3.7037036           0          0          0   84       .38  .2140295
     4 2016 13.135593 -2.1455512  4.6033897   .8753057   .2687224   .07221172  40     0 1 .026992347   .05932203 .542  12.711864           0          0          0   84      .339  .2316775
     4 2018  26.68919 -2.0753677   4.307151   .7057489   .3051593   .09312221  58     0 1  .06788135    .0472973 .568  16.216217           0   .6756757          0   86      .345  .2293208
     4 2019 23.333334  -2.104309   4.428117   .7733271  .20407957   .04164847  49     0 1          0   .05185185 .585   10.37037           0          0          0   87      .422 .24060562
     4 2020  20.96774 -2.1547549  4.6429687   .4336896  .25568458   .06537461  51     0 1          0   .07741936    0  3.2258065   1.2903225          0          0   86      .329 .26080182
     4 2021  39.14141  -1.993182   3.972774   .4675661  .22790316   .05193985  46     0 1          0   .05050505    0   3.030303   12.121212   .5050505          0   86      .318  .3433572
     5 2013  36.88213  -1.601232  2.5639446  1.0249557    .429487   .18445905  72     0 1 .008557783   .02661597 .403  4.1825094           0          0   .3802281   85      .414  .2001672
     5 2014  31.70732 -1.5900956   2.528404   .9193101   .4290761    .1841063  71     0 1 .025097147   .04529617 .341   4.181185           0          0   .6968641   86      .439 .21172294
     5 2015  31.29139 -1.5593636   2.431615   .9189609   .4454138    .1983934  65     0 1  .07337412   .05298013 .358   .9933775    5.960265          0   .6622517   85      .454  .2140295
     5 2016      28.6  -1.614292   2.605939  1.0696586   .4739092   .22458993  44     0 1  .05124889         .04 .352        2.8        13.2         .4         .8   87      .408  .2316775
     5 2017 23.469387  -1.589987   2.528058  1.1622077   .4615773    .2130536  54     0 1   .0984086   .08163265 .441   7.346939   17.959183          0   .8163266   88      .478 .24152154
     5 2018 33.084576  -1.615175    2.60879  1.4021367  .58449984   .34164006  53     0 1  .02654238   .05970149 .388   7.960199    12.43781   .9950249   .4975124   87      .398  .2293208
     5 2019  28.35366  -1.650057  2.7226875   1.625826          1           1  52     0 1  .03273046    .0792683 .439   5.487805   16.463415          0  1.2195122   88      .482 .24060562
     5 2020   29.6875 -1.7548814   3.079609  1.1183778   .3553893   .12630154  45     0 1 .013795683   .05208334    0     4.6875   22.916666   .5208333          0 86.5       .51 .26080182
     5 2021   43.0622  -1.593592  2.5395355   1.396898   .2400274   .05761315  68     0 1  .05156477   .07655502    0    4.30622    25.83732          0          0   86      .411  .3433572
     6 2013       7.5  -1.951902   3.809922   .8988795   .3607178   .13011736  30     0 1   .0949122      .01875 .275          0           0          0          0   82      .363  .2001672
     6 2014     8.125 -1.9089084   3.643931  1.0078429   .2962061   .08773804  37     0 1  .12871438      .01875 .356          0           0      1.875       .625 79.5      .463 .21172294
     6 2015  11.96319  -1.908444   3.642159   .9804274   .2882287   .08307578  39     0 1  .14113499  .018404908 .331   1.226994           0    .613497    .613497   80      .448  .2140295
     6 2016         7 -1.8951645   3.591648  1.1416024  .28019032   .07850662  36     0 1  .07492578         .02  .44          0           0          0          0 82.5      .393  .2316775
     6 2017  8.445946 -1.8764583   3.521096  1.2097045  .29168928   .08508264  46     0 1  .11687173  .067567565 .568   .6756757           0          0   .6756757   82      .405 .24152154
     6 2018        10 -1.8971013   3.598993  1.4164556   .2413001   .05822574  41     0 1    .064823        .024  .56          4           0         .8        2.4   80        .4  .2293208
     6 2019  6.849315 -1.8492148   3.419595  1.2996342  .28932807   .08371074  39     0 1  .04436227   .01369863 .432   4.109589    .6849315          0   4.109589   81      .404 .24060562
     6 2020 14.285714 -1.9827323  3.9312274  1.1042336  .26069164   .06796013  26     0 1  .04120446   .08270676    0   4.511278           0   .7518797   .7518797   84      .444 .26080182
     6 2021  15.21739  -1.954569  3.8203404  1.7410756    .207876   .04321243  29     0 1  .14794105   .04347826    0   4.347826           0          0  3.2608695 83.5      .326  .3433572
     7 2013  8.766233  -2.262571   5.119228  .17053606   .2518942   .06345069  49     0 1 .036888584  .012987013 .474          0           0          0          0   86      .338  .2001672
     7 2014  7.692307 -2.2663748   5.136455  .14119977  .19082977     .036416  35     0 1  .07394603   .03205128 .429          0           0          0          0   85      .288 .21172294
     7 2015   12.1118 -2.2511473   5.067664    .131421   .2078461       .0432  44     0 1  .12810221  .018518519   .5          0           0          0          0   86      .333  .2140295
     7 2016 10.927153 -2.1740122   4.726329   .4249586   .3912965   .15311295  48     0 1 .016530111  .006622517 .623          0           0  1.3245033          0   86      .411  .2316775
     7 2017  9.090909 -2.2126439   4.895793   .1911413  .24411197   .05959066  32     0 1  .09378067  .024242425 .715  1.2121212    .6060606   .6060606          0   86      .352 .24152154
     7 2018   8.79397 -2.1305232  4.5391293  .11186347   .3304051   .10916753  50     0 1  .04204682    .0201005 .688  2.0100503           0          0          0   87      .402  .2293208
     7 2019  9.947644 -2.0885053   4.361854  .28124565  .23636293   .05586743  47     0 1  .10597069  .015706806 .686   4.188482           0  1.0471205          0   85      .414 .24060562
     7 2020  5.528846  -2.205032   4.862166 -.14465451  .21080606    .0444392  42     0 1 .013400955   .06730769    0  1.4423077           0  1.4423077          0   87      .327 .26080182
     7 2021  6.976744  -2.190748   4.799376   .6242009  .15965354  .025489254  45     0 1  .07776604   .04651163    0  4.6511626           0  1.5503876          0   86      .388  .3433572
     9 2013  8.983051 -2.1331904  4.5505013  -.4982617  .02489895 .0006199577   5     0 1  .11861194   .00671141 .101   .3389831           0          0          0   52      .685  .2001672
     9 2014  6.443299 -2.1254158   4.517392  -.8986672  .01497633 .0002242905   2     0 1          0    .0230179 .054          0           0  .25773194  .25773194   48      .665 .21172294
     9 2015 8.4080715 -2.1200943  4.4947996  -1.098608 .016248059 .0002639994   2     0 1  .12438045  .004474273 .072  1.3452915    7.174888   .6726457   .4484305   50        .7  .2140295
     9 2016 22.348484 -2.2319834    4.98175   .4843297   .1255925  .015773475  11     0 1          0   .02255639  .18  2.2727273   20.454546  2.2727273   .7575758   68      .571  .2316775
     9 2017 35.114502  -1.581141   2.500007  1.0817075  .09199627  .008463314  13     0 1 .008127311  .027131785 .271   5.343512    29.77099   .3816794   .3816794   79      .438 .24152154
     9 2018  32.69962  -1.580795   2.498913  1.0768181  .08462198   .00716088  12     0 1  .09963424  .071698114 .185  1.9011407    14.44867   .3802281          0   80 .50200003  .2293208
     9 2019  26.62722 -1.6279558    2.65024  .57251316  .07942177  .006307817  16     0 1   .0586813   .06213018  .18  4.1420116    11.83432    .887574          0   76       .53 .24060562
     9 2020 28.434505  -1.734491   3.008459   .4204184   .0730273  .005332986   9     0 1  .05394188    .0543131    0   5.750799    8.306709  1.2779553          0   78       .45 .26080182
     9 2021 33.887043    -1.6883   2.850357   .5974839  .04757354 .0022632414   6     0 1  .10772017   .07615894    0   16.27907   12.624585   .9966778          0   80      .467  .3433572
    10 2013  4.182967   .3886634  .15105927   .4907906   .3745917   .14031896 241     0 1   .1205463  .004996502 .071  .18055974   1.7353797    .310964   .4814926   49      .448  .2001672
    10 2014  4.512601   .3418243  .11684385  .29050055  .31657735   .10022122 232     0 1  .10690453  .005595069 .065  .21873514    1.616738   .3233476   .5420827   49      .455 .21172294
    10 2015 4.2736645   .3751349  .14072621   .3523163   .3182321   .10127167 226     0 1  .11353926  .005710006 .063  .17806935    2.239925   .3186504  .55295223   50      .457  .2140295
    10 2016  4.156609   .4254002  .18096533  .52536553    .318948   .10172783 225     0 1  .11179615  .005506182 .062  .22207204    3.340736   .4344887   .6179395   50      .471  .2316775
    10 2017  4.229154   .4081649   .1665986   .5351443   .3275275   .10727423 230  72.5 0  .10765078  .007584074 .067     .19996    4.079184    .429914    .589882   51      .472 .24152154
    10 2018  3.802565  .35345265  .12492878    .387939  .28217486   .07962265 224 73.88 0  .10159553  .005364061 .071  .13917884   4.2946615   .2982404   .4374192   49      .469  .2293208
    10 2019  3.770978   .3408243   .1161612   .4003371   .3084979   .09517096 223 75.05 0  .09955941  .005721876 .081  .28653294    6.273025   .6139992  .54236597   52      .453 .24060562
    10 2020   4.73301   .3108659  .09663761  .51104665    .311659   .09713133 232 74.48 0  .11063652  .010039235    0   .8321775    7.420249  1.1673602   .6472492   54      .462 .26080182
    10 2021  4.054487   .3932178   .1546202   .5990555  .23916264   .05719877 207     0 1  .10265282  .009387668    0    .715812    6.068376  1.0790598   .4059829   54      .455  .3433572
    12 2013  2.866242   .6895422   .4754684  .21419127  .06680514 .0044629266 141     0 1   .0874911  .003811363 .035   .1732484           0          0          0   61      .533  .2001672
    12 2014  2.551238   .6691688   .4477869  .04952384 .067410044 .0045441138 126     0 1  .09826506 .0037269425 .031   .2319307   .04259952  .00473328          0   61      .538 .21172294
    12 2015   2.71019   .6044056   .3653061 -.08720426  .06612115 .0043720067 128 74.47 0  .10362696  .003077071  .03  .26017827   .18790653 .004818116          0   61      .522  .2140295
    12 2016  2.588011   .5787914   .3349995 -.20629565  .06420117 .0041217897 124 74.78 0   .1038646   .00241748 .026    .325536   .13951541          0          0   63      .516  .2316775
    12 2017  2.848439   .5972126   .3566629 -.22812326 .063478954 .0040295776 121 74.83 0  .10460123  .003200711 .028   .4669572   .24459665          0          0   64       .51 .24152154
    12 2018 2.7155704   .6218285   .3866707 -.17922944  .05971329 .0035656765 127     0 1  .10738558 .0022013825  .03   .4055722    .3791218 .008816787          0   63 .52599996  .2293208
    12 2019 2.7969804   .6504035   .4230247  -.1663075  .06150743  .003783164 121 73.16 0  .10378234   .00292472 .028    .411383   .24174052          0          0   64      .528 .24060562
    12 2020  2.639728   .6009113   .3610944 -.01595897  .06140596  .003770692 129 72.23 0  .10438174 .0043213014    0   .2690492    .2690492          0   .0050764   64      .525 .26080182
    12 2021  2.927672   .3671175  .13477524  -.7771311  .04656455 .0021682573 112     0 1  .10314665 .0040043686    0   .3591399   .27731055 .009092149          0   63      .525  .3433572
    15 2013  22.47993  -.8835082   .7805867   .6196608   .3334634   .11119785 155     0 1   .1290566  .018733274  .46  .08920607           0   .4460303   6.868867   78      .434  .2001672
    15 2014  24.56822  -.8918066    .795319  .54876477   .3058875   .09356717 151     0 1   .1912343   .02761001   .5   .3454231           0   .3454231   8.117444   80      .447 .21172294
    15 2015  22.82507  -.9091692   .8265886   .6275187    .371837   .13826273 142     0 1   .1493241   .02897196 .439   .3741815           0   .4677269   7.390084   80      .441  .2140295
    15 2016  27.70213  -.8531772   .7279113   .6242009   .3020504   .09123444 159     0 1  .16768974  .020373514 .508  .25531915   .08510638  1.1914893   9.702127   80      .415  .2316775
    15 2017  30.18018  -.8530192   .7276418    .565703  .24881655   .06190967 160     0 1  .14563902  .027777776  .55  1.5561016    7.371007  1.6380017  12.612613   81       .45 .24152154
    15 2018  29.63896  -.8107097   .6572502   .7111621  .24208248   .05860393 139     0 1  .17342955  .015926236 .497  4.1141896   34.508816  2.2670026  12.258606   79      .416  .2293208
    15 2019  26.97176   -.827953   .6855062   .8946886  .28543624   .08147385 129     0 1  .13577272    .0232333 .458   4.186952    31.74294  1.4605647   13.04771   80       .47 .24060562
    15 2020  31.47023  -.9425667    .888432   .9439316  .28503242   .08124348 112     0 1   .1729504  .018203883    0   7.047388   33.657352   1.944107  12.150668   78      .494 .26080182
    15 2021  28.23834  -.8876783   .7879728  1.1812414  .23567747   .05554387 114     0 1  .14849998   .02842377    0   7.901555   31.865286   5.958549  11.528498   77      .468  .3433572
    16 2013  5.493184 -1.0519202   1.106536  -1.032776  .23575374   .05557983   1     0 1  .25921544  .011651265 .079          0           0  .04009623          0   82      .299  .2001672
    16 2014  4.985755 -1.0116354  1.0234063 -1.1125777  .27529803   .07578901   1     0 1  .26143956  .011244106 .079 .035612535           0   .1068376  .07122507   83      .319 .21172294
    end

    Listed 100 out of 10634 observations


    I also have treated and post-tretment dummies not shown here. My treatment took place in 2016, treated hospitals are "public" and control/donor pool are "private" and "grouped public".


    My main question was on the donoradj() option. As I understand it, it is non-optional and informs the donor pool, only et & nt are available.

    Stata does not like this option, and returns option donoradj() not allowed.

    For now my code looks like this:

    Code:
    scul yit, treated(treated) donoradj(et) after(2016)
    Another question is on the time period of my study, For now my panel range from 2013 to 2022, with a treatment in 2016, this might be a bit light for parallel trend hypothesis, and its equivalent (?) in SCA, should I gather more data, knowing that our data manager has a long waiting list, or can I perform the analysis on this small pre-treatment period?


    Excuse me for my (I hope not) broken english.



    Loïc Guérin
    Last edited by Loic Guerin; 10 May 2023, 09:39.

  • #2
    So I'm still developing SCUL (for submission to SJ), but the syntax SHOULD be the same here... Anyways, I have two thoughts about this. Firstly: do not use only 3 pre-intervention periods. SCUL will perform terribly here, for reasons I mention and cite in my paper (which has also been heavily edited, thanks to the comments of the referees and editor). You generally want at least 12 pre-intervention time periods. Anyways.

    According to my current syntax in the ado file, the actual way to specify donor adjustment is donadj. I think this was a mistake in the help file. My apologies! There's also an issue with how you're specifying your event time (before and after). The before and after options specify event time windows. So, let's say we're only interested looking at the effect for the window of 8 years before and 2 years after an intervention, we'd do before(8) after(2). For proof of this, see this mini example.
    Code:
    clear *
    
    import delim "https://raw.githubusercontent.com/synth-inference/synthdid/master/data/california_prop99.csv", clear
    
    
    mkf otherdata
    
    cwf otherdata
    cls
    import delim "https://chronicdata.cdc.gov/api/views/7nwe-3aj9/rows.csv?accessType=DOWNLOAD&api_foundry=true", clear
    
    keep if submeasureiddisplayorder == 2 & inrange(year,1970,2000) & locationabbr =="MA"
    
    keep locationdesc year data_value
    
    rename (data loca) (packspercapita state)
    
    tempfile two
    
    sa `two'
    
    cwf default
    ap using `two'
    
    egen id = group(state), label(state)
    
    replace treated = 1 if id == 16 & year >= 1993
    
    replace treat = 0 if treat == .
    
    drop state
    
    order id, first
    
    xtset id year, y
    
    cls
    
    
    scul packs, treated(treat) donadj("nt") before(8) after(2)
    See? 8 years before....... 2 years after. So, you really need to think about the reasonable time period an effect might take place. If we'd expect an effect to appear after a week or two, for example, a treated unit with only one day may not be informative.

    But all this really is for when you have more data to work with. At present, scul will produce garbage with only 3 preintervention periods. In fact, I'm almost certain it shouldn't be able to run at all.



    Alright I was wrong. It will run. But please, don't do it!!! See this example for why.
    Code:
    clear *
    
    import delim "https://raw.githubusercontent.com/synth-inference/synthdid/master/data/california_prop99.csv", clear
    
    egen id = group(state), label(state)
    drop state
    
    order id, first
    
    xtset id year, y
    
    cls
    
    br
    drop if year < 1985
    
    scul packs, treated(treat)
    Generally, an extended pre-intervention period is needed for SCM to work well. So, under some regularity assumptions, the more pre-intervention data you have, the better you'll be. See how improved it is when we have more pre-periods
    Code:
    clear *
    
    import delim "https://raw.githubusercontent.com/synth-inference/synthdid/master/data/california_prop99.csv", clear
    
    egen id = group(state), label(state)
    drop state
    
    order id, first
    
    xtset id year, y
    
    cls
    
    drop if year < 1979
    
    scul packs, treated(treat)
    Still not good, but much better than before.
    Last edited by Jared Greathouse; 10 May 2023, 09:58.

    Comment


    • #3
      Thanks Jared Greathouse for your quick reply,

      I will try to access a larger dataset, what would be the minimum time requirement? As I understand it the longer the better, but this would be costly for my coworkers. (edit:read to fast: 12 years)
      • On another note, the first code runs OK, but the other codes provided in your reply do not run to their full complition on my computer, and stops at:
      Second exemple;
      ------------------------------------------------------------------------------------------------------------------------------------------------------------
      Third Step: Estimation
      ------------------------------------------------------------------------------------------------------------------------------------------------------------
      Optimizing (optimal lambda)... This could take quite a while...

      no observations
      r(2000);


      Third exemple;

      ------------------------------------------------------------------------------------------------------------------------------------------------------------
      Third Step: Estimation
      ------------------------------------------------------------------------------------------------------------------------------------------------------------
      Optimizing (optimal lambda)... This could take quite a while...


      Warning: lopt is at the limit of the lambda range.
      no observations
      r(2000);
      • I take note that I do not have enough pre-treatment periods (be assured that I am now fully aware of the potential biases). I tried to make your first code work on my dataset but with a stupid timeframe, as it will take some weeks to access a longer one.
      Code:
      gene treated = 0
      replace treated=1 if oldght==2 & year>2016
      replace treated = 0 if treated == .
      scul yit, treated(treated) donadj("nt") before(3) after(1)
      I am now faced with a new error type:

      ------------------------------------------------------------------------------------------------------------------------------------------------------------
      Collecting our treated units...
      ------------------------------------------------------------------------------------------------------------------------------------------------------------
      expression too long
      r(130);

      I guessed that this is due to the code's inability to handle large treatment groups ?
      Code:
      Oldght==2
      represents all small and medium sized hospitals in France, so I have 2918 treated and 7761 untreated obs over the period.
      • This tool seems very promising for my analysis, namely in the form of robustness checks of my main DiD model. I am now faced with more theoretical questions on Scul.
        • Can the synthetic group characteristics be multivaried or is it limited to previous values of my Y variable?
          • Abadie & Vives-i-Bastida (2022) talk about including observed covariate to their simulations
        • Can the package handle very large datasets ? as previously mentionned I have for now ~10.000 obs. adding 10years of pretreatment will double this number.
        • Could I split the treated group in multiple subcategories (8) within one model? DiD estimators let me do this, and I find heterogenous effects between subcategories.
      Last edited by Loic Guerin; 11 May 2023, 04:39.

      Comment


      • #4
        In the version of scul that's current, you can use other covariates, but it's not an approach I recommend. The new version will take away this possibility, restricting you only to the outcome variable.

        I think the "expression too long" error comes from how many treated units you have. 2918 treated units? Oh yeah, under the hood, scul uses levelsof to collect the treated units. It passes this to inlist which has an upper limit of 256 numeric arguments, in other words, way more than what you currently have. I guess I never really counted on people having more than that, in honesty. You may actually need to limit your analyses to subgroups using -if- for scul to run at all, in this instance.

        Which code blocks didn't work now? The second and third ones from my above post in #2?

        Comment


        • #5
          Hi Jared Greathouse

          Firstly, thanks for your scul command and I anxious to decipt your paper in SJ, soon.

          Meanwhile, I have been playing round with and keep receiving the following error message and hope you can help me.

          Code:
          . xtset S T, week
          
          Panel variable: S (strongly balanced)
           Time variable: T, 2023w19 to 2023w33
                   Delta: 1 week
          
          . xtdes
          
                 S:  1, 2, ..., 203                                    n =         38
                 T:  2023w19, 2023w20, ..., 2023w33                    T =         15
                     Delta(T) = 1 week
                     Span(T)  = 15 periods
                     (S*T uniquely identifies each observation)
          
          Distribution of T_i:   min      5%     25%       50%       75%     95%     max
                                  15      15      15        15        15      15      15
          
               Freq.  Percent    Cum. |  Pattern
           ---------------------------+-----------------
                 38    100.00  100.00 |  111111111111111
           ---------------------------+-----------------
                 38    100.00         |  XXXXXXXXXXXXXXX
          
          . xtdidregress (Y) (D), group(S ) time(T)
          
          Treatment and time information
          
          Time variable: T
          Control:       D = 0
          Treatment:     D = 1
          -----------------------------------
                       |   Control  Treatment
          -------------+---------------------
          Group        |
                     S |        28         10
          -------------+---------------------
          Time         |
               Minimum |      3294       3307
               Maximum |      3294       3307
          -----------------------------------
          
          Difference-in-differences regression                       Number of obs = 570
          Data type: Longitudinal
          
                                               (Std. err. adjusted for 38 clusters in S)
          ------------------------------------------------------------------------------
                       |               Robust
                     Y | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
          -------------+----------------------------------------------------------------
          ATET         |
                     D |
             (1 vs 0)  |   105.4398   1777.595     0.06   0.953    -3496.309    3707.189
          ------------------------------------------------------------------------------
          Note: ATET estimate adjusted for panel effects and time effects.
          
          
          . scul Y, treated(D) donadj("nt") before(10) after(2)
          (150 observations deleted)
          
          invalid file specification
          r(198);
          see below the related dataex:

          clear
          input float T int S byte D float Y
          3294 1 0 47360.5
          3295 1 0 51277.8
          3296 1 0 51387.9
          3297 1 0 51942.35
          3298 1 0 65411.8
          3299 1 0 57312.55
          3300 1 0 58172.95
          3301 1 0 51881.05
          3302 1 0 51800.95
          3303 1 0 49025.45
          3304 1 0 49308.15
          3305 1 0 53727
          3306 1 0 56713.6
          3307 1 0 55246.35
          3308 1 0 58639
          3294 2 0 80884.5
          3295 2 0 92749.85
          3296 2 0 101667.25
          3297 2 0 115738
          3298 2 0 117085.15
          3299 2 0 114430.85
          3300 2 0 109020.45
          3301 2 0 106294.5
          3302 2 0 109969.35
          3303 2 0 98372.05
          3304 2 0 100934.7
          3305 2 0 106422.05
          3306 2 0 110508.95
          3307 2 0 99132.5
          3308 2 0 99410.6
          3294 4 0 46372.7
          3295 4 0 42224.05
          3296 4 0 41938.9
          3297 4 0 37914.8
          3298 4 0 47864.45
          3299 4 0 47267
          3300 4 0 37752.85
          3301 4 0 34843.3
          3302 4 0 37791.7
          3303 4 0 41148.15
          3304 4 0 41132.85
          3305 4 0 38653.1
          3306 4 0 42152.9
          3307 4 0 39251.15
          3308 4 0 41474.2
          3294 5 0 72807.2
          3295 5 0 78715.35
          3296 5 0 65886.5
          3297 5 0 77397.85
          3298 5 0 85062.4
          3299 5 0 101441.65
          3300 5 0 72384.25
          3301 5 0 77392.9
          3302 5 0 73317.15
          3303 5 0 72710
          3304 5 0 74953.2
          3305 5 0 82744.65
          3306 5 0 85747.7
          3307 5 0 77839
          3308 5 0 68905.1
          3294 6 0 35236.45
          3295 6 0 38536.3
          3296 6 0 38011.7
          3297 6 0 43891.75
          3298 6 0 48966.6
          3299 6 0 53764.55
          3300 6 0 39806.05
          3301 6 0 38261.9
          3302 6 0 46105
          3303 6 0 40208
          3304 6 0 34366.75
          3305 6 0 35939.95
          3306 6 0 41574.05
          3307 6 0 39187.7
          3308 6 0 42698.8
          3294 7 0 18381
          3295 7 0 19529.3
          3296 7 0 21344.4
          3297 7 0 28190
          3298 7 0 27113.05
          3299 7 0 30448.05
          3300 7 0 22663.6
          3301 7 0 26450.95
          3302 7 0 20871.4
          3303 7 0 21674.9
          3304 7 0 19262.05
          3305 7 0 21690.25
          3306 7 0 26234.2
          3307 7 0 22438.35
          3308 7 0 22680.7
          3294 8 0 122547.65
          3295 8 0 114551.15
          3296 8 0 115471.65
          3297 8 0 126760.6
          3298 8 0 136908.7
          3299 8 0 119255.8
          3300 8 0 117945.75
          3301 8 0 117154.9
          3302 8 0 125337.6
          3303 8 0 128668.9
          3304 8 0 117671.3
          3305 8 0 121914.2
          3306 8 0 127813.45
          3307 8 1 128461.5
          3308 8 1 135585.55
          3294 9 0 36912.75
          3295 9 0 42562.81
          3296 9 0 30316.6
          3297 9 0 30909.45
          3298 9 0 42497.55
          3299 9 0 51519.97
          3300 9 0 41294.45
          3301 9 0 39321.2
          3302 9 0 42717
          3303 9 0 39357.15
          3304 9 0 36910.55
          3305 9 0 35085.8
          3306 9 0 36493.55
          3307 9 0 39051.95
          3308 9 0 39428.85
          3294 10 0 32971.3
          3295 10 0 41873.85
          3296 10 0 38741.8
          3297 10 0 40789.5
          3298 10 0 50920.85
          3299 10 0 56300.15
          3300 10 0 43120
          3301 10 0 42903.6
          3302 10 0 36266.95
          3303 10 0 39171.5
          3304 10 0 34992.5
          3305 10 0 39246.15
          3306 10 0 41181.1
          3307 10 0 36371.65
          3308 10 0 39596.7
          3294 11 0 40284.35
          3295 11 0 46892.9
          3296 11 0 43806.95
          3297 11 0 48058.05
          3298 11 0 53174.85
          3299 11 0 58943.3
          3300 11 0 44315.6
          3301 11 0 45787.1
          3302 11 0 48323
          3303 11 0 30232.05
          3304 11 0 35098.25
          3305 11 0 54573.3
          3306 11 0 51315.3
          3307 11 0 46503.9
          3308 11 0 48712.2
          3294 12 0 61438.3
          3295 12 0 64319.75
          3296 12 0 62567.8
          3297 12 0 66027.35
          3298 12 0 73685.2
          3299 12 0 82633.85
          3300 12 0 72058.55
          3301 12 0 68844.15
          3302 12 0 65699.25
          3303 12 0 70715.7
          3304 12 0 68602.8
          3305 12 0 72989.7
          3306 12 0 68084.65
          3307 12 0 67944.4
          3308 12 0 66428.1
          3294 13 0 80817.85
          3295 13 0 88665.95
          3296 13 0 79340.7
          3297 13 0 93611.6
          3298 13 0 101683.35
          3299 13 0 109198.1
          3300 13 0 92421
          3301 13 0 88126.65
          3302 13 0 86987.9
          3303 13 0 85757.7
          3304 13 0 82737.6
          3305 13 0 89677.05
          3306 13 0 93592.4
          3307 13 0 84386
          3308 13 0 86662.21
          3294 14 0 56430.15
          3295 14 0 58107.15
          3296 14 0 52905
          3297 14 0 72820.8
          3298 14 0 62893.75
          3299 14 0 67448.8
          3300 14 0 62879.9
          3301 14 0 58111.35
          3302 14 0 60897.3
          3303 14 0 53968.75
          3304 14 0 60192.95
          3305 14 0 58574.49
          3306 14 0 56335.25
          3307 14 1 60790.7
          3308 14 1 58819.8
          3294 41 0 68097.35
          3295 41 0 77556.05
          3296 41 0 70582.25
          3297 41 0 80139
          3298 41 0 105046.65
          3299 41 0 105161.45
          3300 41 0 85373.45
          3301 41 0 83568.15
          3302 41 0 80070.05
          3303 41 0 83753.9
          3304 41 0 72307.8
          3305 41 0 83320.55
          3306 41 0 88074.15
          3307 41 1 76698.1
          3308 41 1 78033.1
          3294 42 0 43002.57
          3295 42 0 44644.15
          3296 42 0 41271.06
          3297 42 0 45076.6
          3298 42 0 58851.75
          3299 42 0 56147.45
          3300 42 0 51917.8
          3301 42 0 53946.31
          3302 42 0 51333.4
          3303 42 0 47674.6
          3304 42 0 48827.1
          3305 42 0 53241.4
          3306 42 0 50999.9
          3307 42 0 51616.3
          3308 42 0 47274.4
          3294 43 0 54023.1
          3295 43 0 69723.45
          3296 43 0 57887.15
          3297 43 0 59786.95
          3298 43 0 70192.8
          3299 43 0 74729.25
          3300 43 0 65953.85
          3301 43 0 75542.75
          3302 43 0 68836.4
          3303 43 0 72228.7
          3304 43 0 67192
          3305 43 0 66839.8
          3306 43 0 73957.8
          3307 43 0 63600.55
          3308 43 0 68822.3
          3294 44 0 97810.65
          3295 44 0 108301.2
          3296 44 0 94361.25
          3297 44 0 119779.35
          3298 44 0 129676.25
          3299 44 0 112693.95
          3300 44 0 114988.3
          3301 44 0 128522.65
          3302 44 0 111415.8
          3303 44 0 108950.3
          3304 44 0 106444.05
          3305 44 0 111471.7
          3306 44 0 111198.25
          3307 44 0 105288.25
          3308 44 0 109252.4
          3294 45 0 25587.5
          3295 45 0 34987.9
          3296 45 0 20496.25
          3297 45 0 23738
          3298 45 0 37726.99
          3299 45 0 47150.55
          3300 45 0 26954.75
          3301 45 0 24709.15
          3302 45 0 31916.25
          3303 45 0 34063.3
          3304 45 0 28936.7
          3305 45 0 29076.15
          3306 45 0 27768.7
          3307 45 0 24249.7
          3308 45 0 30549.3
          3294 46 0 21768.7
          3295 46 0 26610.6
          3296 46 0 22059.15
          3297 46 0 24702.05
          3298 46 0 30895.8
          3299 46 0 27555.7
          3300 46 0 20528.45
          3301 46 0 22346.9
          3302 46 0 22760.8
          3303 46 0 25458.45
          3304 46 0 19625.35
          3305 46 0 22127.45
          3306 46 0 21495.65
          3307 46 0 20740.5
          3308 46 0 22828.7
          3294 47 0 47102.85
          3295 47 0 50651
          3296 47 0 46836.85
          3297 47 0 53858.55
          3298 47 0 63355.3
          3299 47 0 70732.35
          3300 47 0 49655.55
          3301 47 0 46801.45
          3302 47 0 55372.3
          3303 47 0 56325.35
          3304 47 0 49490.1
          3305 47 0 59324.45
          3306 47 0 51273.5
          3307 47 0 48172.3
          3308 47 0 58344.65
          3294 48 0 49403.1
          3295 48 0 55455.1
          3296 48 0 47548.4
          3297 48 0 50706.25
          3298 48 0 76480.55
          3299 48 0 85876.6
          3300 48 0 56056.85
          3301 48 0 59074.25
          3302 48 0 59632.55
          3303 48 0 57549
          3304 48 0 56127.25
          3305 48 0 50728
          3306 48 0 54834.7
          3307 48 0 59457.7
          3308 48 0 62456.8
          3294 49 0 72222.25
          3295 49 0 75341.95
          3296 49 0 76259.5
          3297 49 0 80058.75
          3298 49 0 96383.75
          3299 49 0 92901.15
          3300 49 0 79940.6
          3301 49 0 83036
          3302 49 0 85214.7
          3303 49 0 84540.15
          3304 49 0 82510.2
          3305 49 0 91810.35
          3306 49 0 89976.7
          3307 49 0 82737.45
          3308 49 0 83621.25
          3294 50 0 28051.5
          3295 50 0 31838.8
          3296 50 0 29355.35
          3297 50 0 34854.05
          3298 50 0 38779.55
          3299 50 0 37628.95
          3300 50 0 35268.05
          3301 50 0 41925.7
          3302 50 0 35546.35
          3303 50 0 33898.06
          3304 50 0 34866.25
          3305 50 0 35605.9
          3306 50 0 39128.25
          3307 50 0 36773.3
          3308 50 0 41058.1
          3294 51 0 48280.75
          3295 51 0 52799.35
          3296 51 0 49187.85
          3297 51 0 63373.6
          3298 51 0 69856.05
          3299 51 0 77087.85
          3300 51 0 55724.7
          3301 51 0 59960.3
          3302 51 0 59602.95
          3303 51 0 56325
          3304 51 0 50712.55
          3305 51 0 55308.7
          3306 51 0 53249.2
          3307 51 0 53747.35
          3308 51 0 57911.1
          3294 52 0 49397.75
          3295 52 0 58908
          3296 52 0 59295.9
          3297 52 0 70836.65
          3298 52 0 84899.15
          3299 52 0 92521.05
          3300 52 0 65743.75
          3301 52 0 74885.25
          3302 52 0 75241.2
          3303 52 0 78608.75
          3304 52 0 70489.6
          3305 52 0 59874.1
          3306 52 0 59035.9
          3307 52 1 60072.5
          3308 52 1 72282.25
          3294 67 0 64588.8
          3295 67 0 77534.7
          3296 67 0 64244.65
          3297 67 0 73957.8
          3298 67 0 88403.4
          3299 67 0 91614.4
          3300 67 0 80808.2
          3301 67 0 78885.05
          3302 67 0 78164.1
          3303 67 0 74462.8
          3304 67 0 74608.4
          3305 67 0 70626.45
          3306 67 0 69754.05
          3307 67 1 71524.7
          3308 67 1 80155.6
          3294 68 0 12941.9
          3295 68 0 14684.9
          3296 68 0 12182.3
          3297 68 0 12736.5
          3298 68 0 19652.9
          3299 68 0 19142.3
          3300 68 0 15249.3
          3301 68 0 13825.45
          3302 68 0 16280.85
          3303 68 0 13956.65
          3304 68 0 17209.5
          3305 68 0 17939.75
          3306 68 0 18749.45
          3307 68 0 19226.6
          3308 68 0 21454.75
          3294 69 0 33922.3
          3295 69 0 32963.45
          3296 69 0 28772.35
          3297 69 0 32838.4
          3298 69 0 47682.85
          3299 69 0 44085.2
          3300 69 0 37630.55
          3301 69 0 37452
          3302 69 0 41449.05
          3303 69 0 34261.36
          3304 69 0 34023.4
          3305 69 0 36708.55
          3306 69 0 37739.6
          3307 69 0 35731.45
          3308 69 0 33897.2
          3294 70 0 36846.15
          3295 70 0 40219.55
          3296 70 0 38805.15
          3297 70 0 44876.7
          3298 70 0 52415.8
          3299 70 0 58861.9
          3300 70 0 48126.45
          3301 70 0 50431.7
          3302 70 0 49013.9
          3303 70 0 60397.45
          3304 70 0 56144.95
          3305 70 0 54416
          3306 70 0 54487.45
          3307 70 0 51997.9
          3308 70 0 53427.2
          3294 71 0 55963.55
          3295 71 0 71827.85
          3296 71 0 63113.5
          3297 71 0 70695
          3298 71 0 85404.4
          3299 71 0 85215.15
          3300 71 0 69222.65
          3301 71 0 71727.4
          3302 71 0 71395.35
          3303 71 0 71302.95
          3304 71 0 69619.1
          3305 71 0 77055
          3306 71 0 80837.15
          3307 71 0 72927.85
          3308 71 0 73145.8
          3294 72 0 29558.8
          3295 72 0 27901.1
          3296 72 0 24998.05
          3297 72 0 28214.2
          3298 72 0 41978.9
          3299 72 0 43996.95
          3300 72 0 37769.25
          3301 72 0 37720.9
          3302 72 0 35195.15
          3303 72 0 32725.55
          3304 72 0 29513.3
          3305 72 0 34043.9
          3306 72 0 33304.8
          3307 72 0 26080.2
          3308 72 0 32604.6
          3294 73 0 57388.1
          3295 73 0 68222.45
          3296 73 0 58209.95
          3297 73 0 76288.05
          3298 73 0 80162
          3299 73 0 91733.3
          3300 73 0 66000.15
          3301 73 0 77836.25
          3302 73 0 65839.6
          3303 73 0 66984.4
          3304 73 0 62461.9
          3305 73 0 59292.3
          3306 73 0 70882.2
          3307 73 1 62950.25
          3308 73 1 64861.9
          3294 86 0 112192.25
          3295 86 0 126352.8
          3296 86 0 108332.95
          3297 86 0 131716.36
          3298 86 0 142456.05
          3299 86 0 143551.55
          3300 86 0 125503.55
          3301 86 0 127686.85
          3302 86 0 115947.75
          3303 86 0 125054.75
          3304 86 0 125602.05
          3305 86 0 130743.1
          3306 86 0 141252.45
          3307 86 1 123167.2
          3308 86 1 134234.6
          3294 88 0 39376.75
          3295 88 0 40965.4
          3296 88 0 47390.95
          3297 88 0 45980.55
          3298 88 0 60383.35
          3299 88 0 60558.55
          3300 88 0 54282.75
          3301 88 0 54749
          3302 88 0 58120.2
          3303 88 0 51702.9
          3304 88 0 49812.45
          3305 88 0 53027.3
          3306 88 0 54648.55
          3307 88 0 58947.55
          3308 88 0 57558.85
          3294 89 0 46760.45
          3295 89 0 50666.9
          3296 89 0 43878.75
          3297 89 0 57053.5
          3298 89 0 63306.45
          3299 89 0 60045.4
          3300 89 0 48627.35
          3301 89 0 53596.5
          3302 89 0 49109.95
          3303 89 0 50274.8
          3304 89 0 49783.3
          3305 89 0 55930.25
          3306 89 0 54127.9
          3307 89 0 56890.85
          3308 89 0 55515
          3294 91 0 94093.2
          3295 91 0 106292.95
          3296 91 0 97524.95
          3297 91 0 102439.7
          3298 91 0 128052.55
          3299 91 0 127794.5
          3300 91 0 99851.65
          3301 91 0 108298.5
          3302 91 0 103931.45
          3303 91 0 103590.35
          3304 91 0 106548.75
          3305 91 0 106191.15
          3306 91 0 102537.3
          3307 91 1 98698.9
          3308 91 1 101440.9
          3294 111 0 35691.65
          3295 111 0 34179.55
          3296 111 0 36388
          3297 111 0 41772.5
          3298 111 0 54748.75
          3299 111 0 55384.85
          3300 111 0 42304.25
          3301 111 0 47940.05
          3302 111 0 43244.8
          3303 111 0 48937.3
          3304 111 0 39600.6
          3305 111 0 49552.15
          3306 111 0 47748.65
          3307 111 1 51015.65
          3308 111 1 52563.95
          3294 203 0 79916.4
          3295 203 0 89474.8
          3296 203 0 77192.45
          3297 203 0 106667.9
          3298 203 0 117778.15
          3299 203 0 108004.25
          3300 203 0 90405.95
          3301 203 0 97958.75
          3302 203 0 98342.8
          3303 203 0 86889.95
          3304 203 0 92461.4
          3305 203 0 99068.25
          3306 203 0 102727.3
          3307 203 1 98019.8
          3308 203 1 92876.5
          end
          format %tw T

          [/CODE]


          Comment


          • #6
            Show me the code trace. It likely has to do with the fact that your units do not have labeled names, but this is only my guess

            Comment


            • #7
              Hi Jared Greathouse ,

              the trace log file is large, so I will send you personally at your @student.gsu.edu. Thanks

              Comment


              • #8
                Dear Jared Greathouse,

                I am trying to run a synthetic control regression using your scul command, and I am running into the same error as Luis Pecht:

                invalid file specification
                r(198);

                Were you able to solve this issue with Luis? If so, could you please share the solution? I would deeply appreciate your help.

                Thanks,
                Jacob

                Comment


                • #9
                  I don't remember finding the solution, I'm so sorry. If you could give a reproducible example of the error, I'll look at it.

                  But, if I'm being honest with you, I've kind of moved away from SCUL (the paper too). Not cuz it isn't useful or good, it's just that I felt a better contribution to Stata's SCM capabilities would be better off done via its Python integration. I can still troubleshoot for SCUL and stuff, but it isn't "my preferred" way of doing SCM these days.

                  Comment

                  Working...
                  X