Announcement

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

  • Difference in Difference

    Hello everyone,
    I am writing my thesis on the impact of a law for external voting for emigrants on electoral outcomes in Italy.

    More specifically my empirical strategy is the following:
    Pol_outcomes {pt}= α + β12001{t}∗ Share emigrants{p} + γ{t} + γ{p} + e{pt}
    where my dependent variable is the shares to parties considered to be right or left and my coefficient of interest is the interaction between the policy change and the share of emigrants per every Italian province.

    My dataset is the following:

    input float year str21 provincia double(elettori votanti schedeb) float(votes_left votes_right share_left share_right) long Total_emigration byte _merge float(share_emigration post sum_share)
    1987 "AGRIGENTO" 411266 290568 6261 80977 186024 .3032835 .6967165 . 1 . 0 1
    1988 "AGRIGENTO" . . . . . . . 1174 2 . 0 .
    1989 "AGRIGENTO" . . . . . . . 2915 2 . 0 .
    1990 "AGRIGENTO" . . . . . . . 1278 2 . 0 .
    1991 "AGRIGENTO" . . . . . . . 1230 2 . 0 .
    1992 "AGRIGENTO" 434101 301283 7207 25440 253302 .0912672 .9087328 2502 3 .005763636 0 1
    1993 "AGRIGENTO" . . . . . . . 5376 2 . 0 .
    1994 "AGRIGENTO" 447296 288375 20677 32824 236207 .12200824 .8779917 4497 3 .010053745 0 1
    1995 "AGRIGENTO" . . . . . . . 1879 2 . 0 .
    1996 "AGRIGENTO" 457730 269192 17379 40821 182384 .1828857 .8171143 179 3 .0003910602 0 1
    1997 "AGRIGENTO" . . . . . . . 2091 2 . 0 .
    1998 "AGRIGENTO" . . . . . . . 2129 2 . 0 .
    1999 "AGRIGENTO" . . . . . . . 3193 2 . 0 .
    2000 "AGRIGENTO" . . . . . . . 2243 2 . 0 .
    2001 "AGRIGENTO" 454512 278465 16465 111648 132590 .4571279 .54287213 1766 3 .003885486 1 1
    2002 "AGRIGENTO" . . . . . . . 1334 2 . 1 .
    2003 "AGRIGENTO" . . . . . . . 1343 2 . 1 .
    2004 "AGRIGENTO" . . . . . . . 2270 2 . 1 .
    2005 "AGRIGENTO" . . . . . . . 2010 2 . 1 .
    2006 "AGRIGENTO" 363047 263417 5828 115973 131949 .4677802 .5322198 1411 3 .003886549 1 1
    2007 "AGRIGENTO" . . . . . . . 942 2 . 1 .
    2008 "AGRIGENTO" 362799 265220 11357 84849 154316 .3547718 .6452282 921 3 .002538596 1 1
    2009 "AGRIGENTO" . . . . . . . 774 2 . 1 .
    2010 "AGRIGENTO" . . . . . . . 805 2 . 1 .
    2011 "AGRIGENTO" . . . . . . . 841 2 . 1 .
    2012 "AGRIGENTO" . . . . . . . 1016 2 . 1 .
    2013 "AGRIGENTO" 360349 222530 3991 129599 80601 .6165509 .3834491 1137 3 .0031552745 1 1
    2014 "AGRIGENTO" . . . . . . . 1134 2 . 1 .
    2015 "AGRIGENTO" . . . . . . . 1283 2 . 1 .
    2016 "AGRIGENTO" . . . . . . . 1508 2 . 1 .
    2017 "AGRIGENTO" . . . . . . . 1423 2 . 1 .
    2018 "AGRIGENTO" 351545 207885 2684 141650 76455 .6494578 .3505422 1343 3 .003820279 1 1
    2019 "AGRIGENTO" . . . . . . . 1473 2 . 1 .
    2020 "AGRIGENTO" . . . . . . . 1139 2 . 1 .
    2021 "AGRIGENTO" . . . . . . . 919 2 . 1 .
    1987 "ALESSANDRIA" 384616 354953 9263 127490 207990 .38002264 .6199774 . 1 . 0 1
    1988 "ALESSANDRIA" . . . . . . . 165 2 . 0 .
    1989 "ALESSANDRIA" . . . . . . . 176 2 . 0 .
    1990 "ALESSANDRIA" . . . . . . . 189 2 . 0 .
    1991 "ALESSANDRIA" . . . . . . . 199 2 . 0 .
    1992 "ALESSANDRIA" 382267 344443 8274 29052 296950 .08911601 .910884 112 3 .0002929889 0 1
    1993 "ALESSANDRIA" . . . . . . . 283 2 . 0 .
    1994 "ALESSANDRIA" 384847 341536 10467 64415 380648 .14473231 .8552677 251 3 .0006522072 0 1
    1995 "ALESSANDRIA" . . . . . . . 179 2 . 0 .
    1996 "ALESSANDRIA" 381728 328182 10002 93074 385947 .19430046 .8056995 225 3 .000589425 0 1
    1997 "ALESSANDRIA" . . . . . . . 171 2 . 0 .
    1998 "ALESSANDRIA" . . . . . . . 176 2 . 0 .
    1999 "ALESSANDRIA" . . . . . . . 229 2 . 0 .
    2000 "ALESSANDRIA" . . . . . . . 212 2 . 0 .
    2001 "ALESSANDRIA" 374814 314385 12804 138689 153506 .47464535 .5253546 139 3 .0003708506 1 1
    2002 "ALESSANDRIA" . . . . . . . 98 2 . 1 .
    2003 "ALESSANDRIA" . . . . . . . 74 2 . 1 .
    2004 "ALESSANDRIA" . . . . . . . 70 2 . 1 .
    2005 "ALESSANDRIA" . . . . . . . 129 2 . 1 .
    2006 "ALESSANDRIA" 356605 299847 3343 135512 155122 .4662634 .5337366 145 3 .00040661235 1 1
    2007 "ALESSANDRIA" . . . . . . . 132 2 . 1 .
    2008 "ALESSANDRIA" 352974 283546 2780 110688 162918 .4045525 .5954475 211 3 .0005977777 1 1
    2009 "ALESSANDRIA" . . . . . . . 232 2 . 1 .
    2010 "ALESSANDRIA" . . . . . . . 238 2 . 1 .
    2011 "ALESSANDRIA" . . . . . . . 250 2 . 1 .
    2012 "ALESSANDRIA" . . . . . . . 340 2 . 1 .
    2013 "ALESSANDRIA" 343160 260073 2294 144063 107470 .57273996 .42726 437 3 .0012734585 1 1
    2014 "ALESSANDRIA" . . . . . . . 484 2 . 1 .
    2015 "ALESSANDRIA" . . . . . . . 629 2 . 1 .
    2016 "ALESSANDRIA" . . . . . . . 629 2 . 1 .
    2017 "ALESSANDRIA" . . . . . . . 977 2 . 1 .
    2018 "ALESSANDRIA" 330000 240825 2492 122358 128945 .4868943 .5131057 959 3 .0029060605 1 1
    2019 "ALESSANDRIA" . . . . . . . 706 2 . 1 .
    2020 "ALESSANDRIA" . . . . . . . 803 2 . 1 .
    2021 "ALESSANDRIA" . . . . . . . 629 2 . 1 .
    1987 "ANCONA" 357909 331928 6720 130813 186692 .41200295 .587997 . 1 . 0 1
    1988 "ANCONA" . . . . . . . 226 2 . 0 .
    1989 "ANCONA" . . . . . . . 248 2 . 0 .
    1990 "ANCONA" . . . . . . . 217 2 . 0 .
    1991 "ANCONA" . . . . . . . 458 2 . 0 .
    1992 "ANCONA" 370056 335692 9253 28057 288335 .08867797 .9113221 332 3 .0008971615 0 1
    1993 "ANCONA" . . . . . . . 462 2 . 0 .
    1994 "ANCONA" 381023 335467 11249 97968 478980 .16980386 .8301961 268 3 .0007033696 0 1
    1995 "ANCONA" . . . . . . . 186 2 . 0 .
    1996 "ANCONA" 382159 330165 10775 89124 347250 .20423765 .7957624 227 3 .0005939936 0 1
    1997 "ANCONA" . . . . . . . 282 2 . 0 .
    1998 "ANCONA" . . . . . . . 164 2 . 0 .
    1999 "ANCONA" . . . . . . . 194 2 . 0 .
    2000 "ANCONA" . . . . . . . 261 2 . 0 .
    2001 "ANCONA" 384405 323418 12864 181551 120980 .6001071 .3998929 214 3 .00055670453 1 1
    2002 "ANCONA" . . . . . . . 92 2 . 1 .
    2003 "ANCONA" . . . . . . . 186 2 . 1 .
    2004 "ANCONA" . . . . . . . 213 2 . 1 .
    2005 "ANCONA" . . . . . . . 234 2 . 1 .
    2006 "ANCONA" 372306 320104 3734 186362 125340 .5978851 .4021148 232 3 .0006231433 1 1
    2007 "ANCONA" . . . . . . . 250 2 . 1 .
    2008 "ANCONA" 371545 304801 3207 162428 133383 .54909384 .4509062 279 3 .0007509185 1 1
    2009 "ANCONA" . . . . . . . 254 2 . 1 .
    2010 "ANCONA" . . . . . . . 243 2 . 1 .
    2011 "ANCONA" . . . . . . . 345 2 . 1 .
    2012 "ANCONA" . . . . . . . 383 2 . 1 .
    2013 "ANCONA" 368790 296007 2672 197239 91342 .6834788 .3165212 706 3 .0019143686 1 1
    2014 "ANCONA" . . . . . . . 714 2 . 1 .
    2015 "ANCONA" . . . . . . . 733 2 . 1 .
    2016 "ANCONA" . . . . . . . 872 2 . 1 .
    end


    how do I check for parallel trends?
    also, any idea of how to do an event study?


    Thank you very much in advance,
    Best,

  • #2
    Hey Margherita,

    in such a situation I like to use the command reghdfe which is available from SSC. It is not specific to Diff-in-Diff but can be used for regression which include fixed effects in general.

    A basic two-way-fixed-effects (TWFE) type Diff-in-Diff approach would look somewhat like this:

    Code:
    gen interaction = share_emigration*post
    reghdfe share_right share_emigration interaction, absorb(year provincia) cluster(provincia)
    Double check whether you stated your equation correctly, since share_emigration is timevariant it is not eaten up by the fixed effects I believe.

    If you want to check for pre-trends and want to have an event study-type of graph you can do this:

    Code:
    * First generate the interaction terms using a loop and levelsof (from SSC)
    levelsof year
    local years = r(levels)
    foreach year of local years  {
        gen ind_`year' = (year ==`year')
        gen inter_`year' = ind_`year'*share_emigration
    }
    
    * Then run the regression
    reghdfe share_right share_emigration inter_1992 inter_1994 inter_2001 inter_2006 inter_2008 inter_2013 inter_2018 , absorb(year provincia) cluster(provincia)
    est store m1
    
    * Now plot the coefficients using coefplot (from SSC)
    coefplot m1, drop(share_emigration _cons) vertical yline(0)
    Note, that you need to exclude one interaction term. I chose inter_1998 since that is the last period before the treatment.

    I think there are also packages out there that make it even easier (e.g. xtevent) but I have not worked with them, yet.


    I do not know how deep you want to go, but there is a large and very recent literature on the shortcomings of doing Diff-in-Diff using TWFE. For the continuous case you might want to take a look at these two papers:

    https://psantanna.com/files/Callaway...tAnna_2021.pdf

    https://papers.ssrn.com/sol3/papers....act_id=4011782


    Good luck with the thesis
    Sebastian

    Comment


    • #3
      Could you please tell me how many treated units you have? And, when did the law pass?

      Comment


      • #4
        Thank you very much sebastian schirner!! it was very helpful. I did it...even thought it is not significant for all the years after the law...
        Thank you,
        best,
        margheita

        Comment


        • #5
          Jared Greathouse thank you for your answer! So, the units are my provinces (around 110) and they are treated based on "high shares of emigrants" and "low shares of emigrants". The law was passed in 2001.

          Comment


          • #6
            Okay, so how many are treated?

            Comment

            Working...
            X