Announcement

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

  • Errors in -synth_runner- -- would like to try -allsynth-

    Hi

    I am looking to try a synthetic control method. My starting sample consists of 287 treated firms and 1,002 control firms.

    I have tried using the synth_runner command but have encountered several strange errors (particularly when having larger samples of c500 treated firms) and have just been told about -allsynth- as a potential option. The dummy variable treat=1 for treated firms, and 0 for controls. The variable treatyear is equal to 2020 for all treated units, which is the first year of the treatment (for all units).

    I am looking to gauge what happens to turnover before and after the treatment event, and use the following variables to match treated-synthetic units on: TotalAssets logturnover lev sic2 age.



    Code:

    Code:
    capture mkdir "allsynth_turnover"
    
    **Setup
    
    bysort id (logturnover): drop if missing(logturnover[1]) | missing(logturnover[_N])
    
    bysort id (TotalAssets): drop if missing(TotalAssets[1]) | missing(TotalAssets[_N])
    
    bysort id (sic2): drop if missing(sic2[1]) | missing(sic2[_N])
    
    bysort id (lev): drop if missing(lev[1]) | missing(lev[_N])
    
    bysort id (age): drop if missing(age[1]) | missing(age[_N])
    
    bysort id (Turnover): drop if missing(Turnover[1]) | missing(Turnover[_N])
    
    
    
    **ensure strongly balanced panel
    
    
    tsset id Year
    
    
    **check no. of firms in treated and control groups
    
    egen firmtag = tag(BvDIDnumber)
    
    count if firmtag==1
    
    count if firmtag==1 & treat==0
    count if firmtag==1 & treat==1
    
    
    **allsynth
    
    capture mkdir "allsynth_turnover"
    
    
    allsynth logturnover logturnover(2016(1)2019) TotalAssets(2017(1)2019) lev(2017(1)2019) age sic2, keep(allsynth-sales, replace) stacked(trunits(treat) trperiods(post), clear figure(classic bcorrect, save(allsynth_turnover/ate, replace)))
    
    
    allsynth logturnover logturnover(2016(1)2019) TotalAssets(2017(1)2019) lev(2017(1)2019) age sic2, keep(allsynth-sales, replace) stacked(trunits(treat) trperiods(post), clear sampleavgs(1000) figure(bcorrect placebos), save(allsynth_turnover/ate2, replace)))


    Data example:


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str79 BvDIDnumber float treat int Year double(TotalAssets Turnover) byte sic2 float(id logturnover lev age post treatpost) byte firmtag float treatyear
    "GB00035668" 0 2014             225358     255647 79  6 12.451552 1.1960392 122 0 0 1 2020
    "GB00035668" 0 2015             367096     297947 79  6  12.60467  .7703761 123 0 0 0 2020
    "GB00035668" 0 2016             443808     301765 79  6 12.617404  .8660277 124 0 0 0 2020
    "GB00035668" 0 2017             481495     364246 79  6 12.805585  .7953416 125 0 0 0 2020
    "GB00035668" 0 2018             666265     455089 79  6 13.028248  .6874892 126 0 0 0 2020
    "GB00035668" 0 2019             744539     533022 79  6 13.186318  .6666031 127 0 0 0 2020
    "GB00035668" 0 2020             748971     489860 79  6 13.101875  .7212509 128 1 0 0 2020
    "GB00035668" 0 2021             693441     487365 79  6 13.096768  .7126792 129 1 0 0 2020
    "GB00049116" 0 2014              73824     101016 79  8 11.523034  1.714307 118 0 0 1 2020
    "GB00049116" 0 2015             118715      97007 79  8 11.482538  1.659386 119 0 0 0 2020
    "GB00049116" 0 2016             141198     104072 79  8 11.552838 1.7542245 120 0 0 0 2020
    "GB00049116" 0 2017             144671     123504 79  8  11.72403  1.757501 121 0 0 0 2020
    "GB00049116" 0 2018              68861      63691 79  8 11.061798  .8672398 122 0 0 0 2020
    "GB00049116" 0 2019              34570      58693 79  8 10.980076 1.0607463 123 0 0 0 2020
    "GB00049116" 0 2020              24936      29152 79  8  10.28028  .8284408 124 1 0 0 2020
    "GB00049116" 0 2021              18495      10727 79  8 9.2805195 1.4037308 125 1 0 0 2020
    "GB00055771" 0 2014           13047.58   6972.427 39 11  8.849719  .3521092 116 0 0 1 2020
    "GB00055771" 0 2015          12255.946    6445.65 39 11  8.771161 .32074896 117 0 0 0 2020
    "GB00055771" 0 2016           12118.22   6947.497 39 11  8.846137   .417848 118 0 0 0 2020
    "GB00055771" 0 2017          10437.837   6601.382 39 11  8.795034  .2946308 119 0 0 0 2020
    "GB00055771" 0 2018           9901.898   6804.802 39 11  8.825384  .3343683 120 0 0 0 2020
    "GB00055771" 0 2019               9061       7557 39 11  8.930229 .26774088 121 0 0 0 2020
    "GB00055771" 0 2020               8945       7491 39 11  8.921457  .4695361 122 1 0 0 2020
    "GB00055771" 0 2021           8649.847    7655.11 39 11  8.943129  .2410422 123 1 0 0 2020
    "GB00056547" 1 2014           5822.801   9734.323 50 13 9.1834135   .728576 116 0 0 1 2020
    "GB00056547" 1 2015           5803.314   9231.177 50 13  9.130342  .6072513 117 0 0 0 2020
    "GB00056547" 1 2016            7416.09   9316.197 50 13   9.13951  .5752535 118 0 0 0 2020
    "GB00056547" 1 2017           7765.058   11236.77 50 13  9.326946  .6312733 119 0 0 0 2020
    "GB00056547" 1 2018            8238.65  12698.383 50 13   9.44923  .6585686 120 0 0 0 2020
    "GB00056547" 1 2019              10768      13427 50 13  9.505023  .7272474 121 0 0 0 2020
    "GB00056547" 1 2020               9693      10781 50 13  9.285541   .698339 122 1 1 0 2020
    "GB00056547" 1 2021          11368.929  16787.488 50 13  9.728389  .6152374 123 1 1 0 2020
    "GB00061274" 0 2014              29566      33546 80 16 10.420673  .4236285 115 0 0 1 2020
    "GB00061274" 0 2015              35052      37496 80 16  10.53199  .3576971 116 0 0 0 2020
    "GB00061274" 0 2016              35905      36493 80 16 10.504876  .3999443 117 0 0 0 2020
    "GB00061274" 0 2017              40557      37322 80 16 10.527338  .3986735 118 0 0 0 2020
    "GB00061274" 0 2018              38441      35015 80 16 10.463531  .3809214 119 0 0 0 2020
    "GB00061274" 0 2019              36801      35044 80 16  10.46436  .4055596 120 0 0 0 2020
    "GB00061274" 0 2020              30267      35618 80 16 10.480606  .3803813 121 1 0 0 2020
    "GB00061274" 0 2021              33625      34573 80 16 10.450829  .3632416 122 1 0 0 2020
    "GB00062904" 0 2014             249471     563724 20 17  13.24232  .7337807 115 0 0 1 2020
    "GB00062904" 0 2015             259978     545988 20 17 13.210352  .7301233 116 0 0 0 2020
    "GB00062904" 0 2016             263663     512832 20 17 13.147703  .7051957 117 0 0 0 2020
    "GB00062904" 0 2017             262495     544223 20 17 13.207114  .6686413 118 0 0 0 2020
    "GB00062904" 0 2018             273589     585801 20 17 13.280735    .62845 119 0 0 0 2020
    "GB00062904" 0 2019             244266     564079 20 17  13.24295  .6086602 120 0 0 0 2020
    "GB00062904" 0 2020             253278     524316 20 17  13.16985  .6845877 121 1 0 0 2020
    "GB00062904" 0 2021             218090     557707 20 17  13.23159  .5404879 122 1 0 0 2020
    "GB00075614" 0 2014           7278.402  18670.275 73 19  9.834688   .614406 112 0 0 1 2020
    "GB00075614" 0 2015          11545.413  21324.409 73 19  9.967607  .6872487 113 0 0 0 2020
    "GB00075614" 0 2016          11201.199  21952.732 73 19  9.996647  .5975792 114 0 0 0 2020
    "GB00075614" 0 2017          10878.801  21967.541 73 19  9.997321  .5278867 115 0 0 0 2020
    "GB00075614" 0 2018          12528.706  24519.143 73 19  10.10721 .55363446 116 0 0 0 2020
    "GB00075614" 0 2019              12193      25707 73 19  10.15452 .50020504 117 0 0 0 2020
    "GB00075614" 0 2020              11185      25119 73 19  10.13138  .4033974 118 1 0 0 2020
    "GB00075614" 0 2021          11843.284  21298.645 73 19  9.966399  .3688681 119 1 0 0 2020
    "GB00077797" 0 2014             892388     332347 79 21 12.713935  .8196424 111 0 0 1 2020
    "GB00077797" 0 2015             881646     318061 79 21 12.669998  .8671632 112 0 0 0 2020
    "GB00077797" 0 2016             703779     369675 79 21  12.82038  .8268278 113 0 0 0 2020
    "GB00077797" 0 2017             675270     351229 79 21 12.769194  .7834303 114 0 0 0 2020
    "GB00077797" 0 2018             669715     375527 79 21 12.836085  .7878605 115 0 0 0 2020
    "GB00077797" 0 2019             683851     467227 79 21  13.05457  .7669287 116 0 0 0 2020
    "GB00077797" 0 2020             727168     335088 79 21  12.72215  .7653802 117 1 0 0 2020
    "GB00077797" 0 2021             864349     443021 79 21 13.001372  .6572345 118 1 0 0 2020
    "GB00083405" 0 2014              99844      65390 87 24 11.088124  .6913685 109 0 0 1 2020
    "GB00083405" 0 2015             110874      73066 87 24  11.19912  .6873298 110 0 0 0 2020
    "GB00083405" 0 2016             143980      78358 87 24 11.269043  .7193152 111 0 0 0 2020
    "GB00083405" 0 2017             144651     111496 87 24 11.621744  .6833689 112 0 0 0 2020
    "GB00083405" 0 2018             164349     232397 87 24 12.356202  .6946559 113 0 0 0 2020
    "GB00083405" 0 2019             179926     242674 87 24 12.399474   .783322 114 0 0 0 2020
    "GB00083405" 0 2020             159922     228069 87 24 12.337403  .6960518 115 1 0 0 2020
    "GB00083405" 0 2021             176412     210339 87 24 12.256475  .6863989 116 1 0 0 2020
    "GB00112626" 1 2014              14977      18642 34 30  9.833173  .5739467 104 0 0 1 2020
    "GB00112626" 1 2015              13305      22204 34 30 10.008028  .5155956 105 0 0 0 2020
    "GB00112626" 1 2016              12804      20098 34 30  9.908376 .56044984 106 0 0 0 2020
    "GB00112626" 1 2017              14281      14378 34 30  9.573455  .6233457 107 0 0 0 2020
    "GB00112626" 1 2018               9868      13336 34 30  9.498222   .796818 108 0 0 0 2020
    "GB00112626" 1 2019               7144      12157 34 30  9.405661  .8233483 109 0 0 0 2020
    "GB00112626" 1 2020               7524       5702 34 30  8.648572 1.1404837 110 1 1 0 2020
    "GB00112626" 1 2021               7705      14231 34 30  9.563178 1.0250486 111 1 1 0 2020
    "GB00123414" 0 2014          61064.878  98691.997 79 32  11.49976  .6707655 102 0 0 1 2020
    "GB00123414" 0 2015          99213.051  103928.36 79 32 11.551457   .796724 103 0 0 0 2020
    "GB00123414" 0 2016          92437.383  97151.029 79 32 11.484022  .9274216 104 0 0 0 2020
    "GB00123414" 0 2017         130069.575 127761.106 79 32 11.757917  .8485079 105 0 0 0 2020
    "GB00123414" 0 2018          116079.68 126830.558 79 32 11.750607  .8549927 106 0 0 0 2020
    "GB00123414" 0 2019              79298      68185 79 32  11.12998  .8637923 107 0 0 0 2020
    "GB00123414" 0 2020              50460      49966 79 32 10.819098  .7521799 108 1 0 0 2020
    "GB00123414" 0 2021 47364.702000000005  27557.105 79 32 10.224015   .822553 109 1 0 0 2020
    "GB00124503" 0 2014          12395.069  24814.731 20 33 10.119193  .4589001 102 0 0 1 2020
    "GB00124503" 0 2015          13418.634  28082.411 20 33   10.2429  .4331882 103 0 0 0 2020
    "GB00124503" 0 2016          17604.476  30089.589 20 33 10.311934  .4056296 104 0 0 0 2020
    "GB00124503" 0 2017          13983.768  31417.855 20 33 10.355132  .4289629 105 0 0 0 2020
    "GB00124503" 0 2018          15123.333  34087.981 20 33   10.4367  .4142084 106 0 0 0 2020
    "GB00124503" 0 2019              18715      34334 20 33 10.443892  .4232968 107 0 0 0 2020
    "GB00124503" 0 2020              18684      34277 20 33  10.44223  .4038214 108 1 0 0 2020
    "GB00124503" 0 2021          19827.702  31617.321 20 33  10.36146  .3221354 109 1 0 0 2020
    "GB00131237" 0 2014              48185      36477 41 35 10.504437  .9240012 101 0 0 1 2020
    "GB00131237" 0 2015              42910      62320 41 35 11.040038  .7261478 102 0 0 0 2020
    "GB00131237" 0 2016              44120      56838 41 35  10.94796   .668971 103 0 0 0 2020
    "GB00131237" 0 2017              52259      62581 41 35 11.044217  .7233012 104 0 0 0 2020
    end


    I have tried to adapt code from the Wiltshire (2021) allsynth paper figures 14 and 15.

    In running the first -allsynth- line of code, I get an error:

    "variable gap_bc not found"

    (I am assuming if this first line won't run, the second won't either..)



    Also, I wanted to ask if -allsynth- (and other synth coding) ran faster when using Stata MP??

    I have tried to give as much detail as possible - please ask if anything is missing.


    Many thanks for any advice

    Paul

  • #2
    Just so I understand you, if I get up from bed right now and put this example dataset into Stata, I'll be able to reproduce the first error you speak of?

    Comment


    • #3
      No - the "variable bc_gap" error isn't reproducing on the example. I am getting a different error on the data example:

      "control units: for 1 of out 11 units outcome variable logturnover is missing in 2018 pre-intervention MSPE period - check mspeperiod()"

      However the variable logturnover is not missing for any of the 100 observations.

      Please note however there was a slight error in the data and code in the original post. New dataex and code below:


      Dataex:


      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str79 BvDIDnumber float treat int Year double(TotalAssets Turnover) byte sic2 float(id logturnover lev age post treatpost) byte firmtag float treatyear
      "GB00035668" 0 2014             225358     255647 79  6 12.451552 1.1960392 122 0 0 1    .
      "GB00035668" 0 2015             367096     297947 79  6  12.60467  .7703761 123 0 0 0    .
      "GB00035668" 0 2016             443808     301765 79  6 12.617404  .8660277 124 0 0 0    .
      "GB00035668" 0 2017             481495     364246 79  6 12.805585  .7953416 125 0 0 0    .
      "GB00035668" 0 2018             666265     455089 79  6 13.028248  .6874892 126 0 0 0    .
      "GB00035668" 0 2019             744539     533022 79  6 13.186318  .6666031 127 0 0 0    .
      "GB00035668" 0 2020             748971     489860 79  6 13.101875  .7212509 128 1 0 0    .
      "GB00035668" 0 2021             693441     487365 79  6 13.096768  .7126792 129 1 0 0    .
      "GB00049116" 0 2014              73824     101016 79  8 11.523034  1.714307 118 0 0 1    .
      "GB00049116" 0 2015             118715      97007 79  8 11.482538  1.659386 119 0 0 0    .
      "GB00049116" 0 2016             141198     104072 79  8 11.552838 1.7542245 120 0 0 0    .
      "GB00049116" 0 2017             144671     123504 79  8  11.72403  1.757501 121 0 0 0    .
      "GB00049116" 0 2018              68861      63691 79  8 11.061798  .8672398 122 0 0 0    .
      "GB00049116" 0 2019              34570      58693 79  8 10.980076 1.0607463 123 0 0 0    .
      "GB00049116" 0 2020              24936      29152 79  8  10.28028  .8284408 124 1 0 0    .
      "GB00049116" 0 2021              18495      10727 79  8 9.2805195 1.4037308 125 1 0 0    .
      "GB00055771" 0 2014           13047.58   6972.427 39 11  8.849719  .3521092 116 0 0 1    .
      "GB00055771" 0 2015          12255.946    6445.65 39 11  8.771161 .32074896 117 0 0 0    .
      "GB00055771" 0 2016           12118.22   6947.497 39 11  8.846137   .417848 118 0 0 0    .
      "GB00055771" 0 2017          10437.837   6601.382 39 11  8.795034  .2946308 119 0 0 0    .
      "GB00055771" 0 2018           9901.898   6804.802 39 11  8.825384  .3343683 120 0 0 0    .
      "GB00055771" 0 2019               9061       7557 39 11  8.930229 .26774088 121 0 0 0    .
      "GB00055771" 0 2020               8945       7491 39 11  8.921457  .4695361 122 1 0 0    .
      "GB00055771" 0 2021           8649.847    7655.11 39 11  8.943129  .2410422 123 1 0 0    .
      "GB00056547" 1 2014           5822.801   9734.323 50 13 9.1834135   .728576 116 0 0 1 2020
      "GB00056547" 1 2015           5803.314   9231.177 50 13  9.130342  .6072513 117 0 0 0 2020
      "GB00056547" 1 2016            7416.09   9316.197 50 13   9.13951  .5752535 118 0 0 0 2020
      "GB00056547" 1 2017           7765.058   11236.77 50 13  9.326946  .6312733 119 0 0 0 2020
      "GB00056547" 1 2018            8238.65  12698.383 50 13   9.44923  .6585686 120 0 0 0 2020
      "GB00056547" 1 2019              10768      13427 50 13  9.505023  .7272474 121 0 0 0 2020
      "GB00056547" 1 2020               9693      10781 50 13  9.285541   .698339 122 1 1 0 2020
      "GB00056547" 1 2021          11368.929  16787.488 50 13  9.728389  .6152374 123 1 1 0 2020
      "GB00061274" 0 2014              29566      33546 80 16 10.420673  .4236285 115 0 0 1    .
      "GB00061274" 0 2015              35052      37496 80 16  10.53199  .3576971 116 0 0 0    .
      "GB00061274" 0 2016              35905      36493 80 16 10.504876  .3999443 117 0 0 0    .
      "GB00061274" 0 2017              40557      37322 80 16 10.527338  .3986735 118 0 0 0    .
      "GB00061274" 0 2018              38441      35015 80 16  10.46353  .3809214 119 0 0 0    .
      "GB00061274" 0 2019              36801      35044 80 16  10.46436  .4055596 120 0 0 0    .
      "GB00061274" 0 2020              30267      35618 80 16 10.480606  .3803813 121 1 0 0    .
      "GB00061274" 0 2021              33625      34573 80 16 10.450829  .3632416 122 1 0 0    .
      "GB00062904" 0 2014             249471     563724 20 17  13.24232  .7337807 115 0 0 1    .
      "GB00062904" 0 2015             259978     545988 20 17 13.210352  .7301233 116 0 0 0    .
      "GB00062904" 0 2016             263663     512832 20 17 13.147703  .7051957 117 0 0 0    .
      "GB00062904" 0 2017             262495     544223 20 17 13.207114  .6686413 118 0 0 0    .
      "GB00062904" 0 2018             273589     585801 20 17 13.280735    .62845 119 0 0 0    .
      "GB00062904" 0 2019             244266     564079 20 17  13.24295  .6086602 120 0 0 0    .
      "GB00062904" 0 2020             253278     524316 20 17  13.16985  .6845877 121 1 0 0    .
      "GB00062904" 0 2021             218090     557707 20 17  13.23159  .5404879 122 1 0 0    .
      "GB00075614" 0 2014           7278.402  18670.275 73 19  9.834688   .614406 112 0 0 1    .
      "GB00075614" 0 2015          11545.413  21324.409 73 19  9.967607  .6872487 113 0 0 0    .
      "GB00075614" 0 2016          11201.199  21952.732 73 19  9.996647  .5975792 114 0 0 0    .
      "GB00075614" 0 2017          10878.801  21967.541 73 19  9.997321  .5278867 115 0 0 0    .
      "GB00075614" 0 2018          12528.706  24519.143 73 19  10.10721 .55363446 116 0 0 0    .
      "GB00075614" 0 2019              12193      25707 73 19  10.15452 .50020504 117 0 0 0    .
      "GB00075614" 0 2020              11185      25119 73 19  10.13138  .4033974 118 1 0 0    .
      "GB00075614" 0 2021          11843.284  21298.645 73 19  9.966399  .3688681 119 1 0 0    .
      "GB00077797" 0 2014             892388     332347 79 21 12.713935  .8196424 111 0 0 1    .
      "GB00077797" 0 2015             881646     318061 79 21 12.669998  .8671632 112 0 0 0    .
      "GB00077797" 0 2016             703779     369675 79 21  12.82038  .8268278 113 0 0 0    .
      "GB00077797" 0 2017             675270     351229 79 21 12.769194  .7834303 114 0 0 0    .
      "GB00077797" 0 2018             669715     375527 79 21 12.836085  .7878605 115 0 0 0    .
      "GB00077797" 0 2019             683851     467227 79 21  13.05457  .7669287 116 0 0 0    .
      "GB00077797" 0 2020             727168     335088 79 21  12.72215  .7653802 117 1 0 0    .
      "GB00077797" 0 2021             864349     443021 79 21 13.001372  .6572345 118 1 0 0    .
      "GB00083405" 0 2014              99844      65390 87 24 11.088124  .6913685 109 0 0 1    .
      "GB00083405" 0 2015             110874      73066 87 24  11.19912  .6873298 110 0 0 0    .
      "GB00083405" 0 2016             143980      78358 87 24 11.269043  .7193152 111 0 0 0    .
      "GB00083405" 0 2017             144651     111496 87 24 11.621744  .6833689 112 0 0 0    .
      "GB00083405" 0 2018             164349     232397 87 24 12.356202  .6946559 113 0 0 0    .
      "GB00083405" 0 2019             179926     242674 87 24 12.399474   .783322 114 0 0 0    .
      "GB00083405" 0 2020             159922     228069 87 24 12.337403  .6960518 115 1 0 0    .
      "GB00083405" 0 2021             176412     210339 87 24 12.256475  .6863989 116 1 0 0    .
      "GB00112626" 1 2014              14977      18642 34 30  9.833173  .5739467 104 0 0 1 2020
      "GB00112626" 1 2015              13305      22204 34 30 10.008028  .5155956 105 0 0 0 2020
      "GB00112626" 1 2016              12804      20098 34 30  9.908376 .56044984 106 0 0 0 2020
      "GB00112626" 1 2017              14281      14378 34 30  9.573455  .6233457 107 0 0 0 2020
      "GB00112626" 1 2018               9868      13336 34 30  9.498222   .796818 108 0 0 0 2020
      "GB00112626" 1 2019               7144      12157 34 30  9.405661  .8233483 109 0 0 0 2020
      "GB00112626" 1 2020               7524       5702 34 30  8.648572 1.1404837 110 1 1 0 2020
      "GB00112626" 1 2021               7705      14231 34 30  9.563178 1.0250486 111 1 1 0 2020
      "GB00123414" 0 2014          61064.878  98691.997 79 32  11.49976  .6707655 102 0 0 1    .
      "GB00123414" 0 2015          99213.051  103928.36 79 32 11.551457   .796724 103 0 0 0    .
      "GB00123414" 0 2016          92437.383  97151.029 79 32 11.484022  .9274216 104 0 0 0    .
      "GB00123414" 0 2017         130069.575 127761.106 79 32 11.757917  .8485079 105 0 0 0    .
      "GB00123414" 0 2018          116079.68 126830.558 79 32 11.750607  .8549927 106 0 0 0    .
      "GB00123414" 0 2019              79298      68185 79 32  11.12998  .8637923 107 0 0 0    .
      "GB00123414" 0 2020              50460      49966 79 32 10.819098  .7521799 108 1 0 0    .
      "GB00123414" 0 2021 47364.702000000005  27557.105 79 32 10.224015   .822553 109 1 0 0    .
      "GB00124503" 0 2014          12395.069  24814.731 20 33 10.119193  .4589001 102 0 0 1    .
      "GB00124503" 0 2015          13418.634  28082.411 20 33   10.2429  .4331882 103 0 0 0    .
      "GB00124503" 0 2016          17604.476  30089.589 20 33 10.311934  .4056296 104 0 0 0    .
      "GB00124503" 0 2017          13983.768  31417.855 20 33 10.355132  .4289629 105 0 0 0    .
      "GB00124503" 0 2018          15123.333  34087.981 20 33   10.4367  .4142084 106 0 0 0    .
      "GB00124503" 0 2019              18715      34334 20 33 10.443892  .4232968 107 0 0 0    .
      "GB00124503" 0 2020              18684      34277 20 33  10.44223  .4038214 108 1 0 0    .
      "GB00124503" 0 2021          19827.702  31617.321 20 33  10.36146  .3221354 109 1 0 0    .
      "GB00131237" 0 2014              48185      36477 41 35 10.504437  .9240012 101 0 0 1    .
      "GB00131237" 0 2015              42910      62320 41 35 11.040038  .7261478 102 0 0 0    .
      "GB00131237" 0 2016              44120      56838 41 35  10.94796   .668971 103 0 0 0    .
      "GB00131237" 0 2017              52259      62581 41 35 11.044217  .7233012 104 0 0 0    .
      end


      Allsynth code:

      Code:
      allsynth logturnover logturnover(2016(1)2019) TotalAssets(2017(1)2019) lev(2017(1)2019) age sic2, keep(allsynth-sales, replace) stacked(trunits(treat) trperiods(treatyear), clear figure(classic bcorrect, save(allsynth_turnover/ate, replace)))

      I have tried using other variables in my full data set and gotten the same "variable bc_gap missing" error after the full run. I noticed that there was a warning that the W matrix is unlikely unique (too fe predictors) - could it be to do with that?

      Comment


      • #4
        EDIT: The problem here, is that the last unit has 4 observations whereas the rest have 8

        SECOND EDIT:


        The problem here is that you forgot to specify bcorrect outside of the stacked option!

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input str79 BvDIDnumber float treat int Year double(TotalAssets Turnover) byte sic2 float(id logturnover lev age post treatpost) byte firmtag float treatyear
        "GB00035668" 0 2014             225358     255647 79  6 12.451552 1.1960392 122 0 0 1    .
        "GB00035668" 0 2015             367096     297947 79  6  12.60467  .7703761 123 0 0 0    .
        "GB00035668" 0 2016             443808     301765 79  6 12.617404  .8660277 124 0 0 0    .
        "GB00035668" 0 2017             481495     364246 79  6 12.805585  .7953416 125 0 0 0    .
        "GB00035668" 0 2018             666265     455089 79  6 13.028248  .6874892 126 0 0 0    .
        "GB00035668" 0 2019             744539     533022 79  6 13.186318  .6666031 127 0 0 0    .
        "GB00035668" 0 2020             748971     489860 79  6 13.101875  .7212509 128 1 0 0    .
        "GB00035668" 0 2021             693441     487365 79  6 13.096768  .7126792 129 1 0 0    .
        "GB00049116" 0 2014              73824     101016 79  8 11.523034  1.714307 118 0 0 1    .
        "GB00049116" 0 2015             118715      97007 79  8 11.482538  1.659386 119 0 0 0    .
        "GB00049116" 0 2016             141198     104072 79  8 11.552838 1.7542245 120 0 0 0    .
        "GB00049116" 0 2017             144671     123504 79  8  11.72403  1.757501 121 0 0 0    .
        "GB00049116" 0 2018              68861      63691 79  8 11.061798  .8672398 122 0 0 0    .
        "GB00049116" 0 2019              34570      58693 79  8 10.980076 1.0607463 123 0 0 0    .
        "GB00049116" 0 2020              24936      29152 79  8  10.28028  .8284408 124 1 0 0    .
        "GB00049116" 0 2021              18495      10727 79  8 9.2805195 1.4037308 125 1 0 0    .
        "GB00055771" 0 2014           13047.58   6972.427 39 11  8.849719  .3521092 116 0 0 1    .
        "GB00055771" 0 2015          12255.946    6445.65 39 11  8.771161 .32074896 117 0 0 0    .
        "GB00055771" 0 2016           12118.22   6947.497 39 11  8.846137   .417848 118 0 0 0    .
        "GB00055771" 0 2017          10437.837   6601.382 39 11  8.795034  .2946308 119 0 0 0    .
        "GB00055771" 0 2018           9901.898   6804.802 39 11  8.825384  .3343683 120 0 0 0    .
        "GB00055771" 0 2019               9061       7557 39 11  8.930229 .26774088 121 0 0 0    .
        "GB00055771" 0 2020               8945       7491 39 11  8.921457  .4695361 122 1 0 0    .
        "GB00055771" 0 2021           8649.847    7655.11 39 11  8.943129  .2410422 123 1 0 0    .
        "GB00056547" 1 2014           5822.801   9734.323 50 13 9.1834135   .728576 116 0 0 1 2020
        "GB00056547" 1 2015           5803.314   9231.177 50 13  9.130342  .6072513 117 0 0 0 2020
        "GB00056547" 1 2016            7416.09   9316.197 50 13   9.13951  .5752535 118 0 0 0 2020
        "GB00056547" 1 2017           7765.058   11236.77 50 13  9.326946  .6312733 119 0 0 0 2020
        "GB00056547" 1 2018            8238.65  12698.383 50 13   9.44923  .6585686 120 0 0 0 2020
        "GB00056547" 1 2019              10768      13427 50 13  9.505023  .7272474 121 0 0 0 2020
        "GB00056547" 1 2020               9693      10781 50 13  9.285541   .698339 122 1 1 0 2020
        "GB00056547" 1 2021          11368.929  16787.488 50 13  9.728389  .6152374 123 1 1 0 2020
        "GB00061274" 0 2014              29566      33546 80 16 10.420673  .4236285 115 0 0 1    .
        "GB00061274" 0 2015              35052      37496 80 16  10.53199  .3576971 116 0 0 0    .
        "GB00061274" 0 2016              35905      36493 80 16 10.504876  .3999443 117 0 0 0    .
        "GB00061274" 0 2017              40557      37322 80 16 10.527338  .3986735 118 0 0 0    .
        "GB00061274" 0 2018              38441      35015 80 16  10.46353  .3809214 119 0 0 0    .
        "GB00061274" 0 2019              36801      35044 80 16  10.46436  .4055596 120 0 0 0    .
        "GB00061274" 0 2020              30267      35618 80 16 10.480606  .3803813 121 1 0 0    .
        "GB00061274" 0 2021              33625      34573 80 16 10.450829  .3632416 122 1 0 0    .
        "GB00062904" 0 2014             249471     563724 20 17  13.24232  .7337807 115 0 0 1    .
        "GB00062904" 0 2015             259978     545988 20 17 13.210352  .7301233 116 0 0 0    .
        "GB00062904" 0 2016             263663     512832 20 17 13.147703  .7051957 117 0 0 0    .
        "GB00062904" 0 2017             262495     544223 20 17 13.207114  .6686413 118 0 0 0    .
        "GB00062904" 0 2018             273589     585801 20 17 13.280735    .62845 119 0 0 0    .
        "GB00062904" 0 2019             244266     564079 20 17  13.24295  .6086602 120 0 0 0    .
        "GB00062904" 0 2020             253278     524316 20 17  13.16985  .6845877 121 1 0 0    .
        "GB00062904" 0 2021             218090     557707 20 17  13.23159  .5404879 122 1 0 0    .
        "GB00075614" 0 2014           7278.402  18670.275 73 19  9.834688   .614406 112 0 0 1    .
        "GB00075614" 0 2015          11545.413  21324.409 73 19  9.967607  .6872487 113 0 0 0    .
        "GB00075614" 0 2016          11201.199  21952.732 73 19  9.996647  .5975792 114 0 0 0    .
        "GB00075614" 0 2017          10878.801  21967.541 73 19  9.997321  .5278867 115 0 0 0    .
        "GB00075614" 0 2018          12528.706  24519.143 73 19  10.10721 .55363446 116 0 0 0    .
        "GB00075614" 0 2019              12193      25707 73 19  10.15452 .50020504 117 0 0 0    .
        "GB00075614" 0 2020              11185      25119 73 19  10.13138  .4033974 118 1 0 0    .
        "GB00075614" 0 2021          11843.284  21298.645 73 19  9.966399  .3688681 119 1 0 0    .
        "GB00077797" 0 2014             892388     332347 79 21 12.713935  .8196424 111 0 0 1    .
        "GB00077797" 0 2015             881646     318061 79 21 12.669998  .8671632 112 0 0 0    .
        "GB00077797" 0 2016             703779     369675 79 21  12.82038  .8268278 113 0 0 0    .
        "GB00077797" 0 2017             675270     351229 79 21 12.769194  .7834303 114 0 0 0    .
        "GB00077797" 0 2018             669715     375527 79 21 12.836085  .7878605 115 0 0 0    .
        "GB00077797" 0 2019             683851     467227 79 21  13.05457  .7669287 116 0 0 0    .
        "GB00077797" 0 2020             727168     335088 79 21  12.72215  .7653802 117 1 0 0    .
        "GB00077797" 0 2021             864349     443021 79 21 13.001372  .6572345 118 1 0 0    .
        "GB00083405" 0 2014              99844      65390 87 24 11.088124  .6913685 109 0 0 1    .
        "GB00083405" 0 2015             110874      73066 87 24  11.19912  .6873298 110 0 0 0    .
        "GB00083405" 0 2016             143980      78358 87 24 11.269043  .7193152 111 0 0 0    .
        "GB00083405" 0 2017             144651     111496 87 24 11.621744  .6833689 112 0 0 0    .
        "GB00083405" 0 2018             164349     232397 87 24 12.356202  .6946559 113 0 0 0    .
        "GB00083405" 0 2019             179926     242674 87 24 12.399474   .783322 114 0 0 0    .
        "GB00083405" 0 2020             159922     228069 87 24 12.337403  .6960518 115 1 0 0    .
        "GB00083405" 0 2021             176412     210339 87 24 12.256475  .6863989 116 1 0 0    .
        "GB00112626" 1 2014              14977      18642 34 30  9.833173  .5739467 104 0 0 1 2020
        "GB00112626" 1 2015              13305      22204 34 30 10.008028  .5155956 105 0 0 0 2020
        "GB00112626" 1 2016              12804      20098 34 30  9.908376 .56044984 106 0 0 0 2020
        "GB00112626" 1 2017              14281      14378 34 30  9.573455  .6233457 107 0 0 0 2020
        "GB00112626" 1 2018               9868      13336 34 30  9.498222   .796818 108 0 0 0 2020
        "GB00112626" 1 2019               7144      12157 34 30  9.405661  .8233483 109 0 0 0 2020
        "GB00112626" 1 2020               7524       5702 34 30  8.648572 1.1404837 110 1 1 0 2020
        "GB00112626" 1 2021               7705      14231 34 30  9.563178 1.0250486 111 1 1 0 2020
        "GB00123414" 0 2014          61064.878  98691.997 79 32  11.49976  .6707655 102 0 0 1    .
        "GB00123414" 0 2015          99213.051  103928.36 79 32 11.551457   .796724 103 0 0 0    .
        "GB00123414" 0 2016          92437.383  97151.029 79 32 11.484022  .9274216 104 0 0 0    .
        "GB00123414" 0 2017         130069.575 127761.106 79 32 11.757917  .8485079 105 0 0 0    .
        "GB00123414" 0 2018          116079.68 126830.558 79 32 11.750607  .8549927 106 0 0 0    .
        "GB00123414" 0 2019              79298      68185 79 32  11.12998  .8637923 107 0 0 0    .
        "GB00123414" 0 2020              50460      49966 79 32 10.819098  .7521799 108 1 0 0    .
        "GB00123414" 0 2021 47364.702000000005  27557.105 79 32 10.224015   .822553 109 1 0 0    .
        "GB00124503" 0 2014          12395.069  24814.731 20 33 10.119193  .4589001 102 0 0 1    .
        "GB00124503" 0 2015          13418.634  28082.411 20 33   10.2429  .4331882 103 0 0 0    .
        "GB00124503" 0 2016          17604.476  30089.589 20 33 10.311934  .4056296 104 0 0 0    .
        "GB00124503" 0 2017          13983.768  31417.855 20 33 10.355132  .4289629 105 0 0 0    .
        "GB00124503" 0 2018          15123.333  34087.981 20 33   10.4367  .4142084 106 0 0 0    .
        "GB00124503" 0 2019              18715      34334 20 33 10.443892  .4232968 107 0 0 0    .
        "GB00124503" 0 2020              18684      34277 20 33  10.44223  .4038214 108 1 0 0    .
        "GB00124503" 0 2021          19827.702  31617.321 20 33  10.36146  .3221354 109 1 0 0    .
        "GB00131237" 0 2014              48185      36477 41 35 10.504437  .9240012 101 0 0 1    .
        "GB00131237" 0 2015              42910      62320 41 35 11.040038  .7261478 102 0 0 0    .
        "GB00131237" 0 2016              44120      56838 41 35  10.94796   .668971 103 0 0 0    .
        "GB00131237" 0 2017              52259      62581 41 35 11.044217  .7233012 104 0 0 0    .
        end
        
        xtset id Year, y
        
        drop if id ==35
        
        cls
        
        
        
        set tr off
        allsynth logturnover logturnover(2016(1)2019) ///
            TotalAssets(2017(1)2019) lev(2017(1)2019) age sic2, bcorrect(merge) ///
            keep(allsynth-sales, replace) ///
            stacked(trunits(treat) ///
            trperiods(treatyear), ///
            clear ///
            figure(classic bcorrect, ///
            save(allsynth_turnover/ate, ///
            replace)))
        Last edited by Jared Greathouse; 28 Oct 2022, 06:49.

        Comment


        • #5
          Thanks Jared - it runs perfectly and I can see the estimated average gaps.

          I am also trying to generate the plot for the bias-corrected estimated ATE and 100 sampled placebo average gaps (trying to follow the code in Wiltshire 2021 for figure 15):

          Code:
          xtset id Year,y
          
          drop if id==35
          
          allsynth logturnover logturnover(2016(1)2019) TotalAssets(2017(1)2019) lev1_w(2017(1)2019) age sic2, bcorrect(merge) pvalues keep(allsynth-sales, replace) stacked(trunits(treat) trperiods(treatyear), clear sampleavgs(100) figure(bcorrect placebos), save(allsynth_turnover/ate2, replace)))
          I am getting an error:

          "-save- is not a valid option for the stacked() option of allsynth"

          I have tried to replicate the code in the Wiltshire paper, but something appears to be incorrect or missing. Would you know where I have gone wrong?

          nb. I am aware that the dataex sample is very small so the -sampleavgs- may be too high, but I get the same error when running in a much larger data set with around 200 treated units and 1000 control units.

          Thanks again for your help - it is much appreciated

          Paul

          Comment


          • #6
            You can do
            Code:
            dataex, count(1000)
            If you wanted.

            For this problem, I would just email Justin and ask him

            Comment


            • #7
              Will do. Thanks again Jared.

              Comment


              • #8
                Be sure to post the solution, since this seems like something others would find useful

                Comment

                Working...
                X