Dear StataList-ers!
Help! I need somebody!
I am applying a DID in multiple treatment groups and multiple time periods. I examine the before-after effect of prostitution liberalization and prohibition on sexual crime in treatment countries compared to controls. I look at 2 subsamples – one consists of the countries that liberalized and the controls; the other one includes the countries that implemented a ban and the controls.
For the sake of simplicity, I’ll focus on the “liberalizing” sample. The key independent variable “Liberalization” is an indicator variable, which takes the value of one beginning in the year when a country liberalizes its policy, and zero otherwise. The dependent variable, “Rape Rate” measures the number of rape cases per 100,000 population recorded at the national level. Country and years fixed effects are included and standard errors are clustered by country. "Treated" equals one if a country liberalized prostitution during the sample period, and zero otherwise. The baseline regression is:
The editor noted that I had implemented a standard DID even though I had heterogeneity in timing of treatment (although as a robustness check, I performed a Bacon decomposition) and suggested I implement “something like the Callaway and Sant’Anna 2021 DD method that allows for treatment at different time periods.” How do I do this? I already read the drdid help but I am still struggling.
Here is a simple data example:
Thank You in advance!
Help! I need somebody!
I am applying a DID in multiple treatment groups and multiple time periods. I examine the before-after effect of prostitution liberalization and prohibition on sexual crime in treatment countries compared to controls. I look at 2 subsamples – one consists of the countries that liberalized and the controls; the other one includes the countries that implemented a ban and the controls.
For the sake of simplicity, I’ll focus on the “liberalizing” sample. The key independent variable “Liberalization” is an indicator variable, which takes the value of one beginning in the year when a country liberalizes its policy, and zero otherwise. The dependent variable, “Rape Rate” measures the number of rape cases per 100,000 population recorded at the national level. Country and years fixed effects are included and standard errors are clustered by country. "Treated" equals one if a country liberalized prostitution during the sample period, and zero otherwise. The baseline regression is:
Code:
reg rape_rate prositution_liberalization controls i.year i.country, robust cluster (country)
Code:
drdid re rape_rate prostitution_liberalization controls ivar(country) time(year)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long country int year byte prostitution_liberalization double raperate_2 float treated double(ln_gdp unemploymentrate ln_population) 5 2006 0 0 0 10.209868431091309 4.533 13.519813537597656 5 2007 0 2.475989777 0 10.354137420654297 3.9 13.538328170776367 5 2008 0 0 0 10.474204063415527 3.642 13.562336921691895 5 2009 0 0 0 10.376792907714844 5.417 13.588521957397461 5 2010 0 3.3 0 10.335868835449219 6.292 13.616010665893555 5 2011 0 3.4 0 10.38077163696289 7.908 13.640860557556152 5 2012 0 2.2 0 10.274530410766602 11.883 13.667023658752441 5 2013 0 1.6 0 10.237897872924805 15.917 13.671499252319336 5 2014 0 1.2 0 10.218327522277832 16.17 13.662359237670898 5 2015 0 1.7 0 10.052433967590332 14.9 13.649465560913086 5 2016 0 2.59 0 10.0718355178833 12.7 13.651012420654297 5 2017 0 2.3399999141693115 0 10.135930061340332 10.4 13.658625602722168 6 1990 0 8.6 0 8.27312183380127 2.3 16.15366554260254 6 1991 0 7.4 0 7.9651007652282715 2.3 16.148101806640625 6 1992 0 6.9 0 8.11732292175293 3.3 16.14887237548828 6 1993 0 7.4 0 8.276838302612305 4.3 16.150146484375 6 1994 0 7.1 0 8.434235572814941 4.3 16.150951385498047 6 1995 0 7.03 0 8.663568496704102 4 16.150869369506836 6 1996 0 6.57 0 8.778613090515137 3.9 16.14972496032715 6 1997 0 6.36 0 8.698987007141113 4.8 16.148540496826172 6 1998 0 6.553398058252427 0 8.773215293884277 6.479 16.14756965637207 6 1999 0 6.155339805825243 0 8.749526023864746 8.756 16.14664649963379 6 2000 0 4.8543689320388355 0 8.701448440551758 8.824 16.145524978637695 6 2001 0 5.496870109546166 0 8.796218872070313 8.166 16.141033172607422 6 2002 0 6.401333202627194 0 8.991300582885742 7.313 16.13801383972168 6 2003 0 6.333751237 0 9.187390327453613 7.812 16.137176513671875 6 2004 0 6.734194859 0 9.366137504577637 8.321 16.137441635131836 6 2005 0 5.831338513 0 9.498985290527344 7.927 16.137786865234375 6 2006 0 5.166298267 0 9.627973556518555 7.148 16.140207290649414 6 2007 0 6.176355805 0 9.818673133850098 5.32 16.14320182800293 6 2008 0 5.097636113 0 10.030069351196289 4.392 16.1518611907959 6 2009 0 4.597817856 0 9.890482902526856 6.662 16.159791946411133 6 2010 0 5.3 0 9.893844604492188 7.279 16.16326904296875 6 2011 0 6.09 0 9.985871315002441 6.711 16.165620803833008 6 2012 0 6.06 0 9.889888763427734 6.978 16.167404174804687 6 2013 0 5.67 0 9.899279594421387 6.953 16.168420791625977 6 2014 0 6.43 0 9.890633583068848 6.1 16.168067932128906 6 2015 0 5.56 0 9.782201766967773 5 16.17052459716797 6 2016 0 6.15 0 9.82464599609375 3.5 16.1716365814209 6 2017 0 5.650000095367432 0 9.921727180480957 2.4 16.174476623535156 7 1990 0 9.5 1 10.199563026428223 7.167 15.451669692993164 7 1991 0 10.3 1 10.20401382446289 7.867 15.453821182250977 7 1992 0 10.8 1 10.294504165649414 8.608 15.45685863494873 7 1993 0 9.6 1 10.225497245788574 9.533 15.460433959960938 7 1994 0 9.2 1 10.308804512023926 7.733 15.463522911071777 7 1995 0 8.42 1 10.473093032836914 6.758 15.46718692779541 7 1996 0 7.37 1 10.481524467468262 6.317 15.473934173583984 7 1997 0 8.23 1 10.39927864074707 5.242 15.478511810302734 7 1998 0 7.885304659498208 1 10.41535758972168 4.883 15.482247352600098 7 1999 1 8.967851099830796 1 10.417531967163086 5.108 15.4857759475708 7 2000 1 9.31409295352324 1 10.333436012268066 4.317 15.488865852355957 7 2001 1 9.199477514461654 1 10.333699226379395 4.508 15.492460250854492 7 2002 1 9.304056568663938 1 10.411169052124023 4.642 15.496031761169434 7 2003 1 8.76592329 1 10.608038902282715 5.433 15.49885082244873 7 2004 1 10.40686779 1 10.747457504272461 5.517 15.501472473144531 7 2005 1 8.764736752 1 10.79548168182373 4.8 15.504019737243652 7 2006 1 9.682793877 1 10.859518051147461 3.9 15.50698184967041 7 2007 1 8.995946339 1 10.976560592651367 3.767 15.510590553283691 7 2008 1 7.203520557 1 11.07165813446045 3.458 15.515847206115723 7 2009 1 6.371186022 1 10.971010208129883 5.992 15.5223388671875 7 2010 1 16.37 1 10.968912124633789 7.475 15.526555061340332 7 2011 1 15.09 1 11.030908584594727 7.567 15.531221389770508 7 2012 1 14.64 1 10.976910591125488 7.542 15.534791946411133 7 2013 1 14.05 1 11.021758079528809 7.008 15.538745880126953 7 2014 1 13.99 1 11.043704986572266 6.533 15.543128967285156 7 2015 1 16.54 1 10.878292083740234 6.2 15.548884391784668 7 2016 1 29.42 1 10.888908386230469 6.1 15.557204246520996 7 2017 1 31.360000610351563 1 10.938583374023438 5.3 15.564536094665527 8 1990 0 3.4 0 8.141772270202637 .6 14.2669677734375 8 1991 0 3.9 0 8.184234619140625 1.5 14.265151023864746 8 1992 0 4.7 0 8.82204818725586 3.7 14.25690746307373 8 1993 0 6.9 0 8.849539756774902 6.5 14.228483200073242 8 1994 0 8.3 0 8.911251068115234 7.6 14.205491065979004 8 1995 0 6.87 0 8.021053314208984 9.7 14.185745239257812 8 1996 0 6.41 0 8.117531776428223 10 14.169816970825195 8 1997 0 6.65 0 8.1942138671875 9.6 14.156256675720215 8 1998 0 3.76947860287476 0 8.307038307189941 9.8 14.14702320098877 8 1999 0 4.2547974644291715 0 8.323450088500977 12.2 14.137041091918945 8 2000 0 5.332359386413441 0 8.311406135559082 14.602 14.152874946594238 8 2001 0 5.5 0 8.411601066589356 13.009 14.146769523620605 8 2002 0 6.56 0 8.577035903930664 11.227 14.14013385772705 8 2003 0 7.914464609 0 8.878252029418945 10.342 14.134102821350098 8 2004 0 8.973272256 0 9.088225364685059 10.14 14.127580642700195 8 2005 0 13.30007571 0 9.243612289428711 8.031 14.122149467468262 8 2006 0 11.38360671 0 9.44108772277832 5.912 14.116133689880371 8 2007 0 9.084999103 0 9.716339111328125 4.592 14.110357284545898 8 2008 0 11.92121567 0 9.803365707397461 5.455 14.107015609741211 8 2009 0 9.242495504 0 9.597391128540039 13.549 14.104995727539063 8 2010 0 6.03963792 0 9.59141731262207 16.707 14.10315990447998 8 2011 0 6.9 0 9.767372131347656 12.325 14.100434303283691 8 2012 0 10.8 0 9.765482902526856 10.023 14.097086906433105 8 2013 0 10.2 0 9.855989456176758 8.628 14.093274116516113 8 2014 0 11.2 0 9.90096378326416 7.013 14.089969635009766 8 2015 0 12.3 0 9.750096321105957 6.2 14.089248657226563 8 2016 0 11.55 0 9.78339672088623 6.4 14.090106964111328 8 2017 0 11.399999618530273 0 9.88861083984375 5.7 14.090106964111328 9 1990 0 7.6 0 10.253458976745605 3.2 15.419812202453613 9 1991 0 7.5 0 10.146559715270996 6.606 15.424644470214844 9 1992 0 7.3 0 10.014021873474121 11.725 15.430731773376465 9 1993 0 7.2 0 9.77662181854248 16.357 15.435884475708008 end label values country country label def country 5 "Cyprus", modify label def country 6 "CzechRepublic", modify label def country 7 "Denmark", modify label def country 8 "Estonia", modify label def country 9 "Finland", modify
Comment