Announcement

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

  • Using Random Donor Units (for in-space placebo tests) in Synthetic Control Methods (SCM)

    Greetings!
    I am using SCM for my Project. And for robustness checks, apart from the classic in-space placebo tests advocated by Abadie et al (2010, 2015, 2021), a number of recent papers adapt the placebo exercise whereby they randomly resample the donor units and re-estimate the placebos multiple times. I have attached example fugures of what am looking for.


    Click image for larger version

Name:	Screenshot 2022-08-08 at 01.34.43.png
Views:	1
Size:	321.4 KB
ID:	1676811




    Click image for larger version

Name:	Screenshot 2022-08-08 at 01.33.34.png
Views:	1
Size:	109.4 KB
ID:	1676812



    I would therefore like to borrow such tests but I cannot figure out how to implement it.

    For demonstration, please kindly use the following (Proposition 99) data. Please assist if you can.
    webuse prop99_example.dta, clear

  • #2
    See allsynth by my colleague Justin Wiltshire

    Comment


    • #3
      My command scul has basic syntax to do this, but I haven't finished it yet and it'll be updated to do this exact task soon

      Comment


      • #4
        Jared Greathouse thank you very much for your suggestions. Checked out "allsynth" command, but it implements the bias-corrected version of the classic placebo tests. Indeed, I do know how to get those. But what am looking for is how to randomly resample the data and do say 1000 replications of the placebos as can be seen in the figures attached.

        Comment


        • #5
          Daniel PV could you come to my rescue on this?

          Comment


          • #6
            Hi Joe Zonda, following A. Abadie, A. Diamond and J. Hainmueller. 2010. We can run a placebo procedure using a few steps as in the following code. In conclusion, it can be done by generating a random value and then assigning the treatment keeping the number of treaties that we have initially.

            Code:
            webuse set www.damianclarke.net/stata/
            webuse prop99_example.dta, clear
            
            set seed 2022
            local reps=25                  //define repeats
            matrix Placebos=J(31,`reps',.) //create matrix to contain the series of placebos
            
            forval p=1(1)`reps' {
                preserve
                qui {
                gen r1=runiform() in 1/38   //38 controls units
                bys state: egen r2=sum(r1)  //assign value to states
                drop if state=="California" //drop treated unit
                egen newID=group(r2)        //generate a new ID for sort and define treated unit
                replace treated=1 if newID==38 & year>=1989 //define placebo treated
            
                sdid packspercapita state year treated, vce(noinference) seed(1213) graph method(sc)
                matrix diff=e(series)[1..31,3]-e(series)[1..31,2] //calculate the difference
                
                *store values in placebo matrix
                forval row=1(1)31 {
                    matrix Placebos[`row',`p']=diff[`row',1]
                }
                local ++p
                restore
                }
            }
            
            *matlist Placebos
            svmat Placebos
            gen time=_n+1969
            
            *run original SC
            sdid packspercapita state year treated, vce(noinference) seed(1213) graph method(sc)
            matrix original=e(series)[1..31,3]-e(series)[1..31,2]
            svmat original
            
            set scheme gg_tableau
            #delimit ;
            tw line Placebos1 time if time<=2000, lc(gray)  || line Placebos2 time if time<=2000, lc(gray)  ||
               line Placebos3 time if time<=2000, lc(gray)  || line Placebos4 time if time<=2000, lc(gray)  ||
               line Placebos5 time if time<=2000, lc(gray)  || line Placebos6 time if time<=2000, lc(gray)  ||
               line Placebos7 time if time<=2000, lc(gray)  || line Placebos8 time if time<=2000, lc(gray)  ||
               line Placebos9 time if time<=2000, lc(gray)  || line Placebos10 time if time<=2000, lc(gray) ||
               line Placebos11 time if time<=2000, lc(gray) || line Placebos12 time if time<=2000, lc(gray) ||
               line Placebos13 time if time<=2000, lc(gray) || line Placebos14 time if time<=2000, lc(gray) ||
               line Placebos15 time if time<=2000, lc(gray) || line Placebos16 time if time<=2000, lc(gray) ||
               line Placebos17 time if time<=2000, lc(gray) || line Placebos18 time if time<=2000 & time>=1984, lc(gray) ||
               line Placebos19 time if time<=2000, lc(gray) || line Placebos20 time if time<=2000, lc(gray) ||
               line Placebos21 time if time<=2000, lc(gray) || line Placebos22 time if time<=2000, lc(gray) ||
               line Placebos23 time if time<=2000, lc(gray) || line Placebos24 time if time<=2000, lc(gray) ||
               line Placebos25 time if time<=2000, lc(gray) || line original time if time<=2000, lc(black) lw(1pt) ||
               , legend(off) xline(1988, lc(red)) ylabel(-30(10)30) yline(0, lc(red) lp(dash))
               ;
            #delimit cr
            sorry for the unoptimized code, but that was my first thought. By the way, the sdid version what I am using here, is the github version (options noinference and method(sc) are not avaible in ssc version). The code replicate the figure 4 in A. Abadie et al 2010.
            Click image for larger version

Name:	prop99_placebo.png
Views:	1
Size:	104.7 KB
ID:	1676829

            Comment


            • #7
              Trust me, I've read the allsynth paper in detail. It allows you to do the random sampling placebo draws you're talking about.

              Look at the sampleavgs option of allsynth, it allows you to randomly reshuffle the placebo draws to your heart's content, so long as it's over 30 draws and you're good. Precisely, look at page 14 of the PDF in the link Joe Zonda

              Comment


              • #8
                Hi Daniel PV, thank you so much for your help. However, if I try to run the code, I encounter the following error as seen in the screenshot attached.

                Click image for larger version

Name:	Screenshot 2022-08-08 at 10.47.42.png
Views:	1
Size:	138.1 KB
ID:	1676846



                Can you suggest what could be the solution?


                Comment


                • #9
                  Jared Greathouse thank you so much, I will revisit the allsynth paper carefully.

                  Comment


                  • #10
                    Joe Zonda do you have the github version? If not reinstall using
                    Code:
                      
                     net install sdid, from("https://raw.githubusercontent.com/daniel-pailanir/sdid/master") replace

                    Comment


                    • #11
                      Hi Daniel PV I do have the github version. Indeed, I also tried to uninstall and reinstall using the github link you have just provided, but the problem is persistent. Am using STATA 15 on a Mac: could that be pertinent to my machine?

                      Comment


                      • #12
                        How did you try to uninstall it? Did you check to see this un-installing worked?

                        Comment


                        • #13
                          Hi Jared Greathouse. I used the following command lines:

                          ado dir
                          Then (See screenshot attached)

                          ado uninstall [81]

                          Click image for larger version

Name:	Screenshot 2022-08-08 at 17.54.16.png
Views:	1
Size:	60.1 KB
ID:	1676878

                          Comment


                          • #14
                            To really know what the issue is, use set tr on to debug the loop Daniel coded, it'll show where the error occurs. Either that or use allsynth and you'll not need to go through the trouble

                            Comment


                            • #15
                              Perfect, will give it a try. Thank you so much Jared Greathouse

                              Comment

                              Working...
                              X