Announcement

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

  • Parallel Trends Assumption in Difference-in-Difference Estimation

    Hi Guys,

    my name is Johannes and I'm currently writing my thesis about the effects of China's Belt and Road Initiative on Institutional frameworks in participating countries. Here, I use the average score of the World Governance Index (issued by the World Bank), ranging from -2.5 to 2.5 as the dependent variable (av_wgi) My main variable to describe its variance is a dummy-variable BRI_state.

    My prof. advised me to run a Difference-in-Difference estimation, even though he is not very keen on answering my questions about it... This seems okay to me, even though I already finished a FE-model, which would work just fine, in my opinion. However, in order to make sense of DID it is strongly advised to identify parallel paths between the control and treatment group. The control group in my example consists out of the states that do not take part in the Belt and Road. The treatment group, in contrast, is the group of countries who do take part.

    To do the regression, I created a time variable (time) that is 0 before the treatment and jumps to 1 in the treatment year and afterwards (in my case the year 2014). I also created a dummy variable for treatment which I called BRI_state. It is a dummy-variable as well. It is 0 for all non-participating states and 1 for all participating states. As a last step I created the interaction term (time*BRI_state), which I called did. The code for these three steps was straightforward.

    Now, however, I am running into a problem. The regression alone wouldn't be a big issue, as I can follow many online guides such as the on of Princeton university. The bigger problem is how to identify the trends, since it would be necessary for a holistic DD-Analysis to have parallel paths of treatment and control group before the treatment. Does anyone here has an idea for a command or any other way to do so? And how to illustrate this with a graph?

    I read something about the dpd and didq command that I already installed. I also read something about the ddid command, which could not be installed in my stata, I don't know why. The didq and ddid command should however also be a solution for non-parallel paths...

    At this point, I am kind of desperate and would be happy for any help or suggestion. I also created a simplified dataset with all necessary variables to do the testing (in my opinion) and paced it into this post via the dataex command (Note that it only displays 100 out of 1752 observations in this panel)

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int
    
    year  countryyear                   countryname             av_wgi                         D_avwgi                    time   BRI_state   did
    2010 "Afghanistan.2010"         "Afghanistan"          -1.7420540650685628   .029326656833291054 0 1 0
    2011 "Afghanistan.2011"         "Afghanistan"          -1.7171535690625508   .024900496006011963 0 1 0
    2012 "Afghanistan.2012"         "Afghanistan"          -1.5503835876782734    .16676998138427734 0 1 0
    2013 "Afghanistan.2013"         "Afghanistan"          -1.5619265635808308  -.011542975902557373 0 1 0
    2014 "Afghanistan.2014"         "Afghanistan"          -1.4660872220993042    .09583934396505356 1 1 1
    2015 "Afghanistan.2015"         "Afghanistan"          -1.4758503933747609  -.009763170965015888 1 1 1
    2016 "Afghanistan.2016"         "Afghanistan"          -1.5469506978988647   -.07110030204057694 1 1 1
    2017 "Afghanistan.2017"         "Afghanistan"            -1.58739373087883   -.04044303297996521 1 1 1
    2010 "Albania.2010"             "Albania"               -.1755655581752459  -.015180491842329502 0 1 0
    2011 "Albania.2011"             "Albania"               -.2222826952735583   -.04671713709831238 0 1 0
    2012 "Albania.2012"             "Albania"              -.23950260474036136    -.0172199085354805 0 1 0
    2013 "Albania.2013"             "Albania"              -.19716660616298518    .04233599826693535 0 1 0
    2014 "Albania.2014"             "Albania"              -.01998024806380272    .17718635499477386 1 1 1
    2015 "Albania.2015"             "Albania"              -.01781945489346981  .0021607931703329086 1 1 1
    2016 "Albania.2016"             "Albania"             -.004202986989791195   .013616467826068401 1 1 1
    2017 "Albania.2017"             "Albania"              .013104683409134546   .017307670786976814 1 1 1
    2010 "Algeria.2010"             "Algeria"               -.8736798961957296  .0035981934051960707 0 0 0
    2011 "Algeria.2011"             "Algeria"               -.9118536313374838   -.03817373514175415 0 0 0
    2012 "Algeria.2012"             "Algeria"               -.8859593669573466    .02589426375925541 0 0 0
    2013 "Algeria.2013"             "Algeria"               -.8264579027891159   .059501465409994125 0 0 0
    2014 "Algeria.2014"             "Algeria"               -.8565742274125417  -.030116325244307518 1 0 0
    2015 "Algeria.2015"             "Algeria"               -.8556728561719259  .0009013712406158447 1 0 0
    2016 "Algeria.2016"             "Algeria"                -.869491438070933  -.013818581588566303 1 0 0
    2017 "Algeria.2017"             "Algeria"                -.853789766629537   .015701672062277794 1 0 0
    2010 "American Samoa.2010"      "American Samoa"         .7077756424744924  -.008821715600788593 0 0 0
    2011 "American Samoa.2011"      "American Samoa"          .706112802028656 -.0016628404846414924 0 0 0
    2012 "American Samoa.2012"      "American Samoa"         .7061648070812225 .00005200505256652832 0 0 0
    2013 "American Samoa.2013"      "American Samoa"         .7014415760835012  -.004723230842500925 0 0 0
    2014 "American Samoa.2014"      "American Samoa"         .8676691323518753     .1662275493144989 1 0 0
    2015 "American Samoa.2015"      "American Samoa"         .8810259521007537   .013356819748878479 1 0 0
    2016 "American Samoa.2016"      "American Samoa"         .8861504524946213    .00512450048699975 1 0 0
    2017 "American Samoa.2017"      "American Samoa"         .9469823002815246    .06083184853196144 1 0 0
    2010 "Andorra.2010"             "Andorra"               1.3374883929888408  -.015464206226170063 0 0 0
    2011 "Andorra.2011"             "Andorra"               1.4120391011238098    .07455071061849594 0 0 0
    2012 "Andorra.2012"             "Andorra"               1.4167765577634175  .0047374567948281765 0 0 0
    2013 "Andorra.2013"             "Andorra"               1.4112175504366558  -.005559007171541452 0 0 0
    2014 "Andorra.2014"             "Andorra"                1.320518175760905   -.09069937467575073 1 0 0
    2015 "Andorra.2015"             "Andorra"               1.3467688858509064    .02625071071088314 1 0 0
    2016 "Andorra.2016"             "Andorra"               1.3548247317473094   .008055846206843853 1 0 0
    2017 "Andorra.2017"             "Andorra"               1.4330222407976787    .07819750905036926 1 0 0
    2010 "Angola.2010"              "Angola"                -1.015260676542918  .0015232762088999152 0 0 0
    2011 "Angola.2011"              "Angola"               -1.0592858642339706   -.04402518644928932 0 0 0
    2012 "Angola.2012"              "Angola"                -.9938524017731348    .06543346494436264 0 0 0
    2013 "Angola.2013"              "Angola"               -1.0600128024816513    -.0661604031920433 0 0 0
    2014 "Angola.2014"              "Angola"               -1.0254801213741302    .03453268110752106 1 0 0
    2015 "Angola.2015"              "Angola"               -1.0106753905614216   .014804731123149395 1 0 0
    2016 "Angola.2016"              "Angola"               -1.0044250190258026   .006250371690839529 1 0 0
    2017 "Angola.2017"              "Angola"                -.9970676600933075   .007357358932495117 1 0 0
    2010 "Anguilla.2010"            "Anguilla"                1.32699520389239    .07568130642175674 0 0 0
    2011 "Anguilla.2011"            "Anguilla"              1.3460992972056072   .019104093313217163 0 0 0
    2012 "Anguilla.2012"            "Anguilla"               1.332432508468628  -.013666789047420025 0 0 0
    2013 "Anguilla.2013"            "Anguilla"              1.3390166362126668   .006584127899259329 0 0 0
    2014 "Anguilla.2014"            "Anguilla"               .8491269286721945    -.4898897111415863 1 0 0
    2015 "Anguilla.2015"            "Anguilla"               .8697997152805328   .020672786980867386 1 0 0
    2016 "Anguilla.2016"            "Anguilla"               .9320305675268173   .062230851501226425 1 0 0
    2017 "Anguilla.2017"            "Anguilla"               .8357231542468071    -.0963074117898941 1 0 0
    2010 "Antigua and Barbuda.2010" "Antigua and Barbuda"    .8009439756472906   .005523895379155874 0 0 0
    2011 "Antigua and Barbuda.2011" "Antigua and Barbuda"    .8033551027377447  .0024111270904541016 0 0 0
    2012 "Antigua and Barbuda.2012" "Antigua and Barbuda"    .8210189044475555   .017663801088929176 0 0 0
    2013 "Antigua and Barbuda.2013" "Antigua and Barbuda"     .795589491724968  -.025429412722587585 0 0 0
    2014 "Antigua and Barbuda.2014" "Antigua and Barbuda"    .4116133699814479   -.38397613167762756 1 0 0
    2015 "Antigua and Barbuda.2015" "Antigua and Barbuda"    .5801443209250768    .16853095591068268 1 0 0
    2016 "Antigua and Barbuda.2016" "Antigua and Barbuda"    .5536672423283259   -.02647707797586918 1 0 0
    2017 "Antigua and Barbuda.2017" "Antigua and Barbuda"    .3856189971168836   -.16804824769496918 1 0 0
    2010 "Argentina.2010"           "Argentina"            -.26670753583312035    .10598119348287582 0 0 0
    2011 "Argentina.2011"           "Argentina"            -.21089698001742363   .055810555815696716 0 0 0
    2012 "Argentina.2012"           "Argentina"               -.31539386510849   -.10449688136577606 0 0 0
    2013 "Argentina.2013"           "Argentina"            -.33874431252479553  -.023350447416305542 0 0 0
    2014 "Argentina.2014"           "Argentina"             -.3868080103614678  -.048063699156045914 1 0 0
    2015 "Argentina.2015"           "Argentina"            -.31294399484371144    .07386401295661926 1 0 0
    2016 "Argentina.2016"           "Argentina"            -.04624137282371521     .2667026221752167 1 0 0
    2017 "Argentina.2017"           "Argentina"            .011730817457040152    .05797218903899193 1 0 0
    2010 "Armenia.2010"             "Armenia"              -.30583417788147926   -.05953597277402878 0 1 0
    2011 "Armenia.2011"             "Armenia"              -.28470878799756366   .021125389263033867 0 1 0
    2012 "Armenia.2012"             "Armenia"              -.18572189037998518    .09898689389228821 0 1 0
    2013 "Armenia.2013"             "Armenia"              -.17203107724587122   .013690813444554806 0 1 0
    2014 "Armenia.2014"             "Armenia"               -.2889581968386968    -.1169271171092987 1 1 1
    2015 "Armenia.2015"             "Armenia"               -.2715284898877144   .017429707571864128 1 1 1
    2016 "Armenia.2016"             "Armenia"              -.30548814808328945  -.033959656953811646 1 1 1
    2017 "Armenia.2017"             "Armenia"               -.2996722062428792  .0058159418404102325 1 1 1
    2010 "Aruba.2010"               "Aruba"                 1.2552866339683533   -.03081723116338253 0 0 0
    2011 "Aruba.2011"               "Aruba"                  1.260848085085551   .005561450961977243 0 0 0
    2012 "Aruba.2012"               "Aruba"                 1.2718956271807353   .011047542095184326 0 0 0
    2013 "Aruba.2013"               "Aruba"                 1.2788068056106567   .006911178585141897 0 0 0
    2014 "Aruba.2014"               "Aruba"                  1.106783886750539   -.17202292382717133 1 0 0
    2015 "Aruba.2015"               "Aruba"                 1.2196964919567108     .1129126027226448 1 0 0
    2016 "Aruba.2016"               "Aruba"                 1.2253518005212147   .005655308719724417 1 0 0
    2017 "Aruba.2017"               "Aruba"                 1.2242043515046437  -.001147449016571045 1 0 0
    2010 "Australia.2010"           "Australia"              1.595369577407837  .0024842917919158936 0 0 0
    2011 "Australia.2011"           "Australia"              1.621867795785268    .02649821899831295 0 0 0
    2012 "Australia.2012"           "Australia"             1.6096359193325043  -.012231876142323017 0 0 0
    2013 "Australia.2013"           "Australia"             1.5786974430084229   -.03093847632408142 0 0 0
    2014 "Australia.2014"           "Australia"             1.6068808436393738   .028183400630950928 1 0 0
    2015 "Australia.2015"           "Australia"              1.550214409828186  -.056666433811187744 1 0 0
    2016 "Australia.2016"           "Australia"             1.5727197925249736     .0225053820759058 1 0 0
    2017 "Australia.2017"           "Australia"              1.537142554918925  -.035577237606048584 1 0 0
    2010 "Austria.2010"             "Austria"               1.5438798467318218    .01212503481656313 0 0 0
    2011 "Austria.2011"             "Austria"               1.4716352423032124   -.07224460691213608 0 0 0
    2012 "Austria.2012"             "Austria"               1.5228851636250813   .051249921321868896 0 0 0
    2013 "Austria.2013"             "Austria"                1.550333559513092   .027448395267128944 0 0 0
    end
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 1752 observations
    Use the count() option to list more




    Thank you very much in advance,

    Johannes

  • #2

    This doesn't require anything fancy or particularly formal. You just restrict the data to the pre-intervention period and plot the data using some graphical form that distinguishes the treated and untreated groups. There are many variations on this theme, the choice among them relying primarily on what is most easily understandable.

    Here are three methods:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int year str32(countryyear countryname) float(av_wgi D_avwgi time BRI_state did)
    2010 "Afghanistan.2010"         "Afghanistan"           -1.742054   .029326657 0 1 0
    2011 "Afghanistan.2011"         "Afghanistan"          -1.7171535   .024900496 0 1 0
    2012 "Afghanistan.2012"         "Afghanistan"          -1.5503836       .16677 0 1 0
    2013 "Afghanistan.2013"         "Afghanistan"          -1.5619266  -.011542976 0 1 0
    2014 "Afghanistan.2014"         "Afghanistan"          -1.4660872    .09583934 1 1 1
    2015 "Afghanistan.2015"         "Afghanistan"          -1.4758503   -.00976317 1 1 1
    2016 "Afghanistan.2016"         "Afghanistan"          -1.5469507    -.0711003 1 1 1
    2017 "Afghanistan.2017"         "Afghanistan"          -1.5873938   -.04044303 1 1 1
    2010 "Albania.2010"             "Albania"              -.17556556  -.015180492 0 1 0
    2011 "Albania.2011"             "Albania"               -.2222827   -.04671714 0 1 0
    2012 "Albania.2012"             "Albania"               -.2395026  -.017219909 0 1 0
    2013 "Albania.2013"             "Albania"               -.1971666      .042336 0 1 0
    2014 "Albania.2014"             "Albania"              -.01998025    .17718635 1 1 1
    2015 "Albania.2015"             "Albania"             -.017819455  .0021607932 1 1 1
    2016 "Albania.2016"             "Albania"             -.004202987   .013616468 1 1 1
    2017 "Albania.2017"             "Albania"              .013104684    .01730767 1 1 1
    2010 "Algeria.2010"             "Algeria"               -.8736799  .0035981934 0 0 0
    2011 "Algeria.2011"             "Algeria"               -.9118536   -.03817374 0 0 0
    2012 "Algeria.2012"             "Algeria"               -.8859594   .025894264 0 0 0
    2013 "Algeria.2013"             "Algeria"               -.8264579    .05950147 0 0 0
    2014 "Algeria.2014"             "Algeria"               -.8565742  -.030116325 1 0 0
    2015 "Algeria.2015"             "Algeria"               -.8556728  .0009013712 1 0 0
    2016 "Algeria.2016"             "Algeria"               -.8694915  -.013818582 1 0 0
    2017 "Algeria.2017"             "Algeria"               -.8537897   .015701672 1 0 0
    2010 "American Samoa.2010"      "American Samoa"         .7077757  -.008821716 0 0 0
    2011 "American Samoa.2011"      "American Samoa"         .7061128 -.0016628405 0 0 0
    2012 "American Samoa.2012"      "American Samoa"         .7061648 .00005200505 0 0 0
    2013 "American Samoa.2013"      "American Samoa"         .7014416  -.004723231 0 0 0
    2014 "American Samoa.2014"      "American Samoa"         .8676691    .16622755 1 0 0
    2015 "American Samoa.2015"      "American Samoa"          .881026    .01335682 1 0 0
    2016 "American Samoa.2016"      "American Samoa"         .8861505     .0051245 1 0 0
    2017 "American Samoa.2017"      "American Samoa"         .9469823    .06083185 1 0 0
    2010 "Andorra.2010"             "Andorra"               1.3374884  -.015464206 0 0 0
    2011 "Andorra.2011"             "Andorra"                1.412039     .0745507 0 0 0
    2012 "Andorra.2012"             "Andorra"               1.4167765   .004737457 0 0 0
    2013 "Andorra.2013"             "Andorra"               1.4112176  -.005559007 0 0 0
    2014 "Andorra.2014"             "Andorra"                1.320518   -.09069937 1 0 0
    2015 "Andorra.2015"             "Andorra"                1.346769    .02625071 1 0 0
    2016 "Andorra.2016"             "Andorra"               1.3548248   .008055846 1 0 0
    2017 "Andorra.2017"             "Andorra"               1.4330223     .0781975 1 0 0
    2010 "Angola.2010"              "Angola"               -1.0152607  .0015232762 0 0 0
    2011 "Angola.2011"              "Angola"               -1.0592859   -.04402519 0 0 0
    2012 "Angola.2012"              "Angola"                -.9938524   .065433465 0 0 0
    2013 "Angola.2013"              "Angola"               -1.0600128    -.0661604 0 0 0
    2014 "Angola.2014"              "Angola"               -1.0254802    .03453268 1 0 0
    2015 "Angola.2015"              "Angola"               -1.0106754    .01480473 1 0 0
    2016 "Angola.2016"              "Angola"                -1.004425   .006250372 1 0 0
    2017 "Angola.2017"              "Angola"                -.9970677   .007357359 1 0 0
    2010 "Anguilla.2010"            "Anguilla"              1.3269953     .0756813 0 0 0
    2011 "Anguilla.2011"            "Anguilla"              1.3460993   .019104093 0 0 0
    2012 "Anguilla.2012"            "Anguilla"              1.3324325   -.01366679 0 0 0
    2013 "Anguilla.2013"            "Anguilla"              1.3390167   .006584128 0 0 0
    2014 "Anguilla.2014"            "Anguilla"               .8491269    -.4898897 1 0 0
    2015 "Anguilla.2015"            "Anguilla"               .8697997   .020672787 1 0 0
    2016 "Anguilla.2016"            "Anguilla"               .9320306    .06223085 1 0 0
    2017 "Anguilla.2017"            "Anguilla"               .8357232   -.09630741 1 0 0
    2010 "Antigua and Barbuda.2010" "Antigua and Barbuda"     .800944   .005523895 0 0 0
    2011 "Antigua and Barbuda.2011" "Antigua and Barbuda"    .8033551   .002411127 0 0 0
    2012 "Antigua and Barbuda.2012" "Antigua and Barbuda"    .8210189   .017663801 0 0 0
    2013 "Antigua and Barbuda.2013" "Antigua and Barbuda"    .7955895   -.02542941 0 0 0
    2014 "Antigua and Barbuda.2014" "Antigua and Barbuda"    .4116134    -.3839761 1 0 0
    2015 "Antigua and Barbuda.2015" "Antigua and Barbuda"   .58014435    .16853096 1 0 0
    2016 "Antigua and Barbuda.2016" "Antigua and Barbuda"   .55366725   -.02647708 1 0 0
    2017 "Antigua and Barbuda.2017" "Antigua and Barbuda"     .385619   -.16804825 1 0 0
    2010 "Argentina.2010"           "Argentina"            -.26670754     .1059812 0 0 0
    2011 "Argentina.2011"           "Argentina"              -.210897    .05581056 0 0 0
    2012 "Argentina.2012"           "Argentina"             -.3153939   -.10449688 0 0 0
    2013 "Argentina.2013"           "Argentina"             -.3387443   -.02335045 0 0 0
    2014 "Argentina.2014"           "Argentina"              -.386808    -.0480637 1 0 0
    2015 "Argentina.2015"           "Argentina"              -.312944    .07386401 1 0 0
    2016 "Argentina.2016"           "Argentina"            -.04624137    .26670262 1 0 0
    2017 "Argentina.2017"           "Argentina"            .011730817    .05797219 1 0 0
    2010 "Armenia.2010"             "Armenia"               -.3058342   -.05953597 0 1 0
    2011 "Armenia.2011"             "Armenia"               -.2847088    .02112539 0 1 0
    2012 "Armenia.2012"             "Armenia"               -.1857219     .0989869 0 1 0
    2013 "Armenia.2013"             "Armenia"              -.17203107   .013690813 0 1 0
    2014 "Armenia.2014"             "Armenia"               -.2889582   -.11692712 1 1 1
    2015 "Armenia.2015"             "Armenia"              -.27152848   .017429708 1 1 1
    2016 "Armenia.2016"             "Armenia"               -.3054881  -.033959657 1 1 1
    2017 "Armenia.2017"             "Armenia"               -.2996722   .005815942 1 1 1
    2010 "Aruba.2010"               "Aruba"                 1.2552867   -.03081723 0 0 0
    2011 "Aruba.2011"               "Aruba"                  1.260848   .005561451 0 0 0
    2012 "Aruba.2012"               "Aruba"                 1.2718956   .011047542 0 0 0
    2013 "Aruba.2013"               "Aruba"                 1.2788068   .006911179 0 0 0
    2014 "Aruba.2014"               "Aruba"                 1.1067839   -.17202292 1 0 0
    2015 "Aruba.2015"               "Aruba"                 1.2196965     .1129126 1 0 0
    2016 "Aruba.2016"               "Aruba"                 1.2253518   .005655309 1 0 0
    2017 "Aruba.2017"               "Aruba"                 1.2242043  -.001147449 1 0 0
    2010 "Australia.2010"           "Australia"             1.5953696   .002484292 0 0 0
    2011 "Australia.2011"           "Australia"             1.6218678    .02649822 0 0 0
    2012 "Australia.2012"           "Australia"              1.609636  -.012231876 0 0 0
    2013 "Australia.2013"           "Australia"             1.5786974  -.030938476 0 0 0
    2014 "Australia.2014"           "Australia"              1.606881     .0281834 1 0 0
    2015 "Australia.2015"           "Australia"             1.5502144   -.05666643 1 0 0
    2016 "Australia.2016"           "Australia"             1.5727198    .02250538 1 0 0
    2017 "Australia.2017"           "Australia"             1.5371425  -.035577238 1 0 0
    2010 "Austria.2010"             "Austria"                 1.54388   .012125035 0 0 0
    2011 "Austria.2011"             "Austria"               1.4716352   -.07224461 0 0 0
    2012 "Austria.2012"             "Austria"               1.5228852    .05124992 0 0 0
    2013 "Austria.2013"             "Austria"               1.5503335   .027448395 0 0 0
    end
    
    keep if time == 0
    
    //  FITTED TRENDS COMPARISON
    regress av_wgi i.BRI_state##c.year 
    margins BRI_state, at(year = (2010(1)2013))
    marginsplot, name(marginsplot, replace)
    
    //  SUBSETPLOT METHOD (-ssc install subsetplot-, by Nick Cox)
    keep countryname av_wgi year BRI_state
    subsetplot scatter av_wgi year, by(BRI_state)
    graph rename subsetplot, replace
    
    //  PLOT OF GROUP MEANS OVER YEARS
    collapse (mean) av_wgi, by(year BRI_state)
    reshape wide av_wgi, i(year) j(BRI_state)
    graph twoway connect av_wgi* year, sort name(group_means, replace)
    The first method is probably simplest, but can be somewhat misleading because it forces the data into linear time trends, and that might obscure differences between them. The second method requires the -subsetplot- command, written by Nick Cox and available from SSC. I'm very fond of this type of graphical display myself, but I admit that many people find them confusing, at least at first. It has the advantage of showing all of the data, not just means or fitted values, so that if there are differences in, say outliers or in variance that are inapparent in the first (and third) method you can see them here. The third method squashes the data into the annual means in each group and then plots each group's trend line separately. It's a bit like the first method but it does not impose a linear model on the changes in outcome over time.

    Note: Somehow your -dataex- output got mangled during posting and what you show is not usable as is. After some surgery I was able to coax Stata into accepting it. The -dataex- output shown in my response above is what yours ought to have looked like with this data. To all who are reading this, I cannot emphasize enough how important it is to copy/paste your -dataex- outputs exactly and make no edits to them whatsoever.

    Comment


    • #3
      Hi Clyde,

      first of all, I want to deeply thank you for taking the time! This is very much appreciated! Second, thank you so much for the three distinct methods. I will try them out.
      Third, I want to apologize for getting the -dataex- command wrong! I hope you didn't have to much work with fiddling around in the data.

      Have a nice day and thanks once again,
      Hannes

      Comment


      • #4
        Hi Clyde,

        thanks once again! The methods work! I have chosen the last version since it gives the smoothest and easiest-to-interpret graph.
        Unfortunately, it also tells me that there is not really a parallel trend, which makes my Diff-in-Diff a bit useless, I guess.

        I am very sorry to bother you again but which possibilities do I have now? What I did so far is the following two things:
        -I designed a full FE model with a vast set of explanatory variables additional to BRI_state. Here, I haven't chosen the same timing for the BRI to kick in as instead some member countries are coded 1 even before 2013 and some are coded 1 after 2014. All the rest, which isn't considered to be a member-state are coded 0. So this should definitely work and brings good results. I just don't know if a FE-Model can bring optimal results here. Articles in journal suggest they do, however, the theory on econometrics recommends the Diff-in-Dif for Policy Changes
        -I checked for parallel trends on a country base in Excel and found some trends between countries of the control and treatment group. However, no I have a different problem. If I do a Dif-in-Dif Regression with this data, all my control variables which are dummies (essentially the membership in other supranational bodies than the BRI, for instance EU, NATO, WTO...) are dropped because of collinearity. Except that, the methodology works.

        Again, I am very sorry to bother you and would appreciate your thoughts on this even more. I pasted the data for my second suggestion below. I think the data shall be readable this time.
        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input int year str7 countryname double new_avwgi byte(EU_candidate EU_member Intrastate_conflict NATO_candidate NATO_member WTO_member) double(new_exports new_FDI new_GDP new_inflation new_remittances) byte(time BRI_state) float did
        2010 "Estonia"    1.0663436849912007 0 1 0 0 1 1 75.07823021170658  13.302610404251492   2.259075893831181  2.97204512015696 1.8324759753382773 0 0 0
        2011 "Estonia"    1.0747986833254497 0 1 0 0 1 1 86.53972527282187   4.827558144959612   7.597300209245603   4.9819013145361 1.8919482862267252 0 0 0
        2012 "Estonia"    1.0621930360794067 0 1 0 0 1 1 85.98943858726155  7.7592920176217595   4.307258987653256  3.93339987296979 1.9998493379228786 0 0 0
        2013 "Estonia"     1.112437019745509 0 1 0 0 1 1 84.30308150402843   4.370606686465119  1.9365434443487857  2.78056658954996 2.2581279426120306 0 0 0
        2014 "Estonia"     1.220025469859441 0 1 0 0 1 1   81.802388001185   6.691461144936392  2.8885638447165007 -.106175146521716 2.0430252776096847 1 0 0
        2015 "Estonia"    1.1950828234354656 0 1 0 0 1 1 77.34500432713354 -3.1189166996698736  1.9002865897060275 -.492326006547338 1.9957658562540663 1 0 0
        2016 "Estonia"    1.1961500843365986 0 1 0 0 1 1 77.59978592650414   3.916098151538917  3.4890971114797082  .148684907627356  2.027937379229015 1 0 0
        2017 "Estonia"    1.1927852034568787 0 1 0 0 1 1 76.54409627801454   5.844004555823057   4.856686856443943  3.41723549488057  1.899560156901767 1 0 0
        2010 "Serbia"     -.1452512772132953 0 0 0 0 0 1 32.25560609728482   4.049632331111981   .7310464430853898  6.14255360247246  9.847691855465044 0 1 0
        2011 "Serbia"    -.10529540820668142 0 0 0 0 0 1 33.00182218001296  10.002289323791814  2.0362757259362922  11.1373976342129  8.036210678703773 0 1 0
        2012 "Serbia"     -.1449378045896689 0 0 0 0 0 1 35.84480697786771   2.946768361558177  -.6815421330412903  7.33038589596636   8.19178067430819 0 1 0
        2013 "Serbia"    -.09417816003163655 0 0 0 0 0 1 39.85150587567927  4.2555897728095555   2.892634162141732  7.69426362896666  8.317079992436222 0 1 0
        2014 "Serbia"     .04181295136610667 1 0 0 0 0 1 42.07752997177007  4.2476586388978035 -1.5895061837666447  2.08244793880151  7.851232973416203 1 1 1
        2015 "Serbia"    .058732101072867714 1 0 0 0 0 1 45.27361076131518   5.910584879417411  1.7763209728228588  1.39235822000187    8.5018044003722 1 1 1
        2016 "Serbia"  .00017994269728660583 1 0 0 0 0 1 48.61545929836844  5.7955002005828735  3.3403290685937606  1.12231397417765  7.887580830680063 1 1 1
        2017 "Serbia"    -.02473145102461179 1 0 0 0 0 1 50.54079107542444   6.556310285630537  2.0493105252801627  3.13106248590119  8.130079194227449 1 1 1
        end
        Once again, thank you and all the best,
        Hannes

        Comment


        • #5
          So, if I understand you correctly, your exploration of parallel trends prior to policy change showed non-parallel results. In response to that, you added more countries and more predictor variables and found that with these additional adjustments you could find parallel trends. The problem you now face is that there is no longer a classical DID design because not all of the countries adopted the policy at the same time.

          So for this you can do a generalized DID analysis. It is similar to DID in spirit, but different in detail. You now need to create a new variable, let's call it in_effect which takes on the value 1 for countries in the treatment group, but only in those observations where the policy has been adopted already, and 0 for all observations in the non-treatment group and for observations in the treatment group that precede policy adoption. This variable is actually very analogous to the interaction term in a DID model. You now do the following regression:

          Code:
          encode country, gen country_num
          xtset country_num year
          xtreg av_wgi in_effect i.year /* OTHER PREDICTORS HERE */, fe
          Note that in addition to the in_effect variable you must include year indicators (i.year) and country indicators (accomplished implicitly by the use of -xtreg, fe-.) The coefficient of in_effect is the generalized DID estimator of the policy effect. Be sure to include the other predictors that you found were necessary to obtain parallel (adjusted) trends prior to policy adoption. For a full explanation of this methodology, see https://www.annualreviews.org/doi/pd...-040617-013507.

          Comment


          • #6
            Thanks Clyde! I think that this is exactly what I need. I will try it out immediately.

            All the best,
            Hannes

            Comment


            • #7
              Thanks Clyde, it works perfect! Thank you for all your help during the last week!

              I would have two follow-up questions, that are both rather generic:

              -Since the regression output also includes the coefficients for the various years, would you include them in the results part of the thesis? I don't know if this is relevant, since it only shows the effect that the very years had on the Average WGI-Score...

              -Would you include all years for which I have data prior to when the treatment comes into play? I have WGI scores from 1996 on, and all other data is also available. However, the first treatment for a country starts no earlier then in 2002. Shall I include the values from 1996 on or rather from, let's say, 1999 on. I read that for a DD it is always suitable to choose 3 years prior to treatment (therefore: 2002-3=1999) as the pre-treatment period. In General, I would say "the more observations, the better". But in DD, or Generalized DD I am not so sure...

              All the Best,
              Hannes


              Comment


              • #8
                Oh and I forgot to mention: Would you recommend to include a Hausman-Taylor Test for a DD or a Generalized DD? As it is theoretically a Fixed Effects Model, I would definitely include such a test...

                Thanks again and all the best,
                Hannes

                Comment


                • #9
                  Since the regression output also includes the coefficients for the various years, would you include them in the results part of the thesis? I don't know if this is relevant, since it only shows the effect that the very years had on the Average WGI-Score...
                  I don't want to advise you either way on what to include in your thesis: there may well be applicable policies at your school, or your thesis advisor and committee may have their own views on this and you should follow those. That said, if I were writing this up for a journal article, I would not report the year coefficients: they are just nuisance parameters. Moreover, because they participate in a colinear relationship, their values are an artifact of how the colinearity is broken. So they are meaningless estimates of nuisance parameters. But, as I say, you should do what your school/advisor/committee requires of you.

                  Would you include all years for which I have data prior to when the treatment comes into play? I have WGI scores from 1996 on, and all other data is also available. However, the first treatment for a country starts no earlier then in 2002. Shall I include the values from 1996 on or rather from, let's say, 1999 on. I read that for a DD it is always suitable to choose 3 years prior to treatment (therefore: 2002-3=1999) as the pre-treatment period. In General, I would say "the more observations, the better". But in DD, or Generalized DD I am not so sure...
                  Another question on which I can't really advise you, but for a different reason. This is not a statistical question, it is a content-area question. I don't even know what the subject matter of your study is--I can't really guess it from the names of the variables. But given that it involves countries and years, it's a fair bet that it isn't my area, epidemiology. The 1996-1999 data should be included if it is relevant. I have no knowledge of whether that data is relevant in your setting or not. If events in the world, or underlying long-term trends are such that data from that interval are not reasonably related to the phenomenon you are studying in the later era, then you would just be adding, in effect, noise to the model. But if these variables exhibit the kind of stability of relationship over time that they would be informative, then they should be included. So this is a question you need to direct to somebody with expertise in your content area.

                  I will comment that I have never heard of any rule of thumb that 3 years data is ideal for DID, and, frankly, it makes no sense to me at all.

                  Would you recommend to include a Hausman-Taylor Test for a DD or a Generalized DD? As it is theoretically a Fixed Effects Model, I would definitely include such a test...
                  Another question that I would punt to your advisor/committee. In my field, we rarely use the Hausman test to select fixed vs random effects models. I personally would not use it here: for generalized DID models I always use the fixed-effects estimator because the causal effect we are trying to estimate is inherently a within-(country) effect, and fixed-effects regression gives within-(country) estimates, random effects regression does not. But I know that in some disciplines the Hausman test is considered mandatory for your analysis to have credibility. I don't agree with that, but you are not accountable to me here, nor are you currently in a position to challenge the prevailing culture of your field.

                  Comment


                  • #10
                    Thanks Clyde for your detailled answers and taking the time to reply to all of my questions!
                    This is very polite of you and very much appreciated!

                    Thank you once again and I wish you all the best!
                    Hannes

                    Comment


                    • #11
                      Hi!!

                      In the case that you have policies implemented at different times, how would you test for pre-intervention parallel trends?. following the example in the expanded DiD with the in_effect variable, would you just plot the in_effect==0 by(group) ? group being those that eventually get the policy=1 or =0 otherwise.

                      Thanks!
                      JC

                      Comment


                      • #12
                        Yes, that's precisely how you would do it.

                        Comment


                        • #13
                          Thank you Clyde!

                          Comment


                          • #14
                            Hi,
                            I´m trying to do an analysis using the generalized DD and check if the parallel trend assumption is fullfilled. The policies are adopted at different times ( 2014 and 2015). I have created in_effect variable as suggested by Clyde, but unfortunately I´m doing something wrong, because it doesn´t show the graphs in way that was expected by me. So basically it shows one graph (for the control group) over the full time period and the other one (for the treated group) starts at 2014. I´m not getting the point what I´m doing wrong.
                            I used following code to plot the graphs:

                            Code:
                            collapse (mean) RWATotalAssets , by ( in_effects PeriodType )
                            reshape wide RWATotalAssets , i( PeriodType ) j( in_effects )
                            graph twoway line RWATotalAssets0 RWATotalAssets1 PeriodType

                            I hope you can understand my issue.
                            Thanks in advance.

                            Code:
                            * Example generated by -dataex-. To install: ssc install dataex
                            clear
                            input str139 CompanyName long FitchID int PeriodType str3(Country StatementCurrency) double RWATotalAssets float(treated in_effects)
                            "Citibank, N.A."                                  856 2015 "USA" "USD"  76.86 0 0
                            "Citibank, N.A."                                  856 2012 "USA" "USD"  62.89 0 0
                            "Citibank, N.A."                                  856 2009 "USA" "USD"  63.37 0 0
                            "Citibank, N.A."                                  856 2017 "USA" "USD"  73.19 0 0
                            "Citibank, N.A."                                  856 2016 "USA" "USD"  74.16 0 0
                            "Citibank, N.A."                                  856 2008 "USA" "USD"  57.98 0 0
                            "Citibank, N.A."                                  856 2013 "USA" "USD"  67.26 0 0
                            "Citibank, N.A."                                  856 2011 "USA" "USD"  64.31 0 0
                            "Citibank, N.A."                                  856 2010 "USA" "USD"  59.75 0 0
                            "Citibank, N.A."                                  856 2014 "USA" "USD"  66.79 0 0
                            "Citibank, N.A."                                  856 2018 "USA" "USD"  73.26 0 0
                            "Wells Fargo Bank, N.A."                         1708 2013 "USA" "USD"  76.98 0 0
                            "Wells Fargo Bank, N.A."                         1708 2014 "USA" "USD"  74.54 0 0
                            "Wells Fargo Bank, N.A."                         1708 2011 "USA" "USD"  79.48 0 0
                            "Wells Fargo Bank, N.A."                         1708 2018 "USA" "USD"  68.32 0 0
                            "Wells Fargo Bank, N.A."                         1708 2009 "USA" "USD"  80.82 0 0
                            "Wells Fargo Bank, N.A."                         1708 2010 "USA" "USD"  81.21 0 0
                            "Wells Fargo Bank, N.A."                         1708 2016 "USA" "USD"   70.8 0 0
                            "Wells Fargo Bank, N.A."                         1708 2017 "USA" "USD"  66.95 0 0
                            "Wells Fargo Bank, N.A."                         1708 2015 "USA" "USD"  74.36 0 0
                            "Wells Fargo Bank, N.A."                         1708 2008 "USA" "USD"   84.5 0 0
                            "Wells Fargo Bank, N.A."                         1708 2012 "USA" "USD"  79.14 0 0
                            "Bankers Trust Company"                          1844 2010 "USA" "USD"   70.5 0 0
                            "Bankers Trust Company"                          1844 2014 "USA" "USD"  84.38 0 0
                            "Bankers Trust Company"                          1844 2017 "USA" "USD"  97.37 0 0
                            "Bankers Trust Company"                          1844 2018 "USA" "USD"  96.33 0 0
                            "Bankers Trust Company"                          1844 2009 "USA" "USD"   74.9 0 0
                            "Bankers Trust Company"                          1844 2016 "USA" "USD"  95.28 0 0
                            "Bankers Trust Company"                          1844 2015 "USA" "USD"   90.2 0 0
                            "Bankers Trust Company"                          1844 2008 "USA" "USD"   71.7 0 0
                            "Bankers Trust Company"                          1844 2012 "USA" "USD"  74.21 0 0
                            "Bankers Trust Company"                          1844 2013 "USA" "USD"  75.55 0 0
                            "Bankers Trust Company"                          1844 2011 "USA" "USD"   73.9 0 0
                            "The Bank of Nova Scotia"                        4303 2008 "CAN" "CAD"  49.37 0 0
                            "The Bank of Nova Scotia"                        4303 2011 "CAN" "CAD"  39.36 0 0
                            "The Bank of Nova Scotia"                        4303 2013 "CAN" "CAD"  38.76 0 0
                            "The Bank of Nova Scotia"                        4303 2015 "CAN" "CAD"  41.97 0 0
                            "The Bank of Nova Scotia"                        4303 2017 "CAN" "CAD"  41.12 0 0
                            "The Bank of Nova Scotia"                        4303 2010 "CAN" "CAD"  39.53 0 0
                            "The Bank of Nova Scotia"                        4303 2014 "CAN" "CAD"  39.03 0 0
                            "The Bank of Nova Scotia"                        4303 2016 "CAN" "CAD"  40.71 0 0
                            "The Bank of Nova Scotia"                        4303 2018 "CAN" "CAD"  40.11 0 0
                            "The Bank of Nova Scotia"                        4303 2009 "CAN" "CAD"  44.64 0 0
                            "The Bank of Nova Scotia"                        4303 2012 "CAN" "CAD"  37.92 0 0
                            "MUFG Union Bank, National Association"         11687 2015 "USA" "USD"  81.41 0 0
                            "MUFG Union Bank, National Association"         11687 2013 "USA" "USD"  82.75 0 0
                            "MUFG Union Bank, National Association"         11687 2008 "USA" "USD"  88.94 0 0
                            "MUFG Union Bank, National Association"         11687 2009 "USA" "USD"  74.27 0 0
                            "MUFG Union Bank, National Association"         11687 2017 "USA" "USD"  73.17 0 0
                            "MUFG Union Bank, National Association"         11687 2014 "USA" "USD"  81.65 0 0
                            "MUFG Union Bank, National Association"         11687 2010 "USA" "USD"  81.34 0 0
                            "MUFG Union Bank, National Association"         11687 2012 "USA" "USD"  81.68 0 0
                            "MUFG Union Bank, National Association"         11687 2018 "USA" "USD"  70.48 0 0
                            "MUFG Union Bank, National Association"         11687 2016 "USA" "USD"  77.35 0 0
                            "MUFG Union Bank, National Association"         11687 2011 "USA" "USD"  77.93 0 0
                            "HSBC Continental Europe S.A."                  12624 2009 "FRA" "EUR"  16.68 1 0
                            "HSBC Continental Europe S.A."                  12624 2015 "FRA" "EUR"  19.29 1 1
                            "HSBC Continental Europe S.A."                  12624 2016 "FRA" "EUR"  21.26 1 1
                            "HSBC Continental Europe S.A."                  12624 2010 "FRA" "EUR"  15.87 1 0
                            "HSBC Continental Europe S.A."                  12624 2018 "FRA" "EUR"  20.03 1 1
                            "HSBC Continental Europe S.A."                  12624 2013 "FRA" "EUR"  15.48 1 0
                            "HSBC Continental Europe S.A."                  12624 2012 "FRA" "EUR"  14.51 1 0
                            "HSBC Continental Europe S.A."                  12624 2011 "FRA" "EUR"  16.66 1 0
                            "HSBC Continental Europe S.A."                  12624 2017 "FRA" "EUR"  21.12 1 1
                            "HSBC Continental Europe S.A."                  12624 2014 "FRA" "EUR"  16.57 1 1
                            "HSBC Continental Europe S.A."                  12624 2008 "FRA" "EUR"  17.96 1 0
                            "NatWest Markets N.V."                          13097 2008 "NLD" "EUR"      . 1 0
                            "NatWest Markets N.V."                          13097 2015 "NLD" "EUR"  102.8 1 1
                            "NatWest Markets N.V."                          13097 2011 "NLD" "EUR"      . 1 0
                            "NatWest Markets N.V."                          13097 2017 "NLD" "EUR" 183.41 1 1
                            "NatWest Markets N.V."                          13097 2009 "NLD" "EUR"      . 1 0
                            "NatWest Markets N.V."                          13097 2018 "NLD" "EUR"  166.3 1 1
                            "NatWest Markets N.V."                          13097 2013 "NLD" "EUR"      . 1 0
                            "NatWest Markets N.V."                          13097 2010 "NLD" "EUR"      . 1 0
                            "NatWest Markets N.V."                          13097 2016 "NLD" "EUR" 160.79 1 1
                            "NatWest Markets N.V."                          13097 2014 "NLD" "EUR"      . 1 1
                            "NatWest Markets N.V."                          13097 2012 "NLD" "EUR"      . 1 0
                            "JPMorgan Chase & Co."                          14528 2008 "USA" "USD"      . 0 0
                            "JPMorgan Chase & Co."                          14528 2012 "USA" "USD"  53.85 0 0
                            "JPMorgan Chase & Co."                          14528 2009 "USA" "USD"  58.96 0 0
                            "JPMorgan Chase & Co."                          14528 2017 "USA" "USD"  59.18 0 0
                            "JPMorgan Chase & Co."                          14528 2018 "USA" "USD"   58.3 0 0
                            "JPMorgan Chase & Co."                          14528 2011 "USA" "USD"   53.9 0 0
                            "JPMorgan Chase & Co."                          14528 2016 "USA" "USD"  58.81 0 0
                            "JPMorgan Chase & Co."                          14528 2013 "USA" "USD"  57.45 0 0
                            "JPMorgan Chase & Co."                          14528 2010 "USA" "USD"  55.49 0 0
                            "JPMorgan Chase & Co."                          14528 2015 "USA" "USD"  62.31 0 0
                            "JPMorgan Chase & Co."                          14528 2014 "USA" "USD"  57.23 0 0
                            "Capital One Bank (USA), National Association" 100024 2013 "USA" "USD"  86.31 0 0
                            "Capital One Bank (USA), National Association" 100024 2009 "USA" "USD"  73.42 0 0
                            "Capital One Bank (USA), National Association" 100024 2016 "USA" "USD"  84.93 0 0
                            "Capital One Bank (USA), National Association" 100024 2008 "USA" "USD"  85.41 0 0
                            "Capital One Bank (USA), National Association" 100024 2011 "USA" "USD"  87.84 0 0
                            "Capital One Bank (USA), National Association" 100024 2017 "USA" "USD"  86.77 0 0
                            "Capital One Bank (USA), National Association" 100024 2012 "USA" "USD"  88.02 0 0
                            "Capital One Bank (USA), National Association" 100024 2014 "USA" "USD"  82.86 0 0
                            "Capital One Bank (USA), National Association" 100024 2010 "USA" "USD"  59.82 0 0
                            "Capital One Bank (USA), National Association" 100024 2018 "USA" "USD"  88.66 0 0
                            "Capital One Bank (USA), National Association" 100024 2015 "USA" "USD"  85.18 0 0
                            "Capital One Financial Corporation"            100042 2009 "USA" "USD"   68.7 0 0
                            end

                            Comment


                            • #15
                              Your data does not contain any pre-2014 observations for the in_effects = 1 group, so the graph for that group only starts at 2014. I presume that the in_effects variable is the DID variable you are using in your generalized DID analysis. What you have to do is separate the data into three groups based on no treatment, treatment starting 2014, treatment starting 2015. (In your example data, there are no observations of companies that begin effect in 2015, but I'll write the code as if there were.)

                              Code:
                              by CompanyName (PeriodType), sort: egen first_year_effect = ///
                                  min(cond(in_effect, PeriodType, .))
                                  
                              label define group  0   "Never Affected"    1   "Start 2014"    2   "Start 2015"
                              gen byte group:group = 0 if missing(first_year_effect)
                              replace group = 1 if first_year_effect == 2014
                              replace group = 2 if first_year_effect == 2015
                              
                              collapse (mean) RWATotalAssets , by ( group PeriodType )
                              reshape wide RWATotalAssets , i( PeriodType ) j( group )
                              graph twoway line RWATotalAssets* PeriodType

                              Comment

                              Working...
                              X