Announcement

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

  • Synthetic DID in Stata as in Arkhangelsky-Athey-Hirshberg-Imbens-Wager (2021)

    Dear all,

    Would it be possible to implement the methodology of the recently published synthetic DID paper? They have released some R codes here, but I am unsure how I could replicate these in Stata.

    If there is some resource that could be useful in helping with the same, please guide me towards it.

    Thank you,
    Aaradhya

  • #2
    I think you'd have to program it yourself ;-)

    Or you can call R from within Stata, here for example
    http://www.haghish.com/resources/pdf/Haghish_Rcall.pdf
    Last edited by Henry Strawforrd; 04 Apr 2022, 05:55.

    Comment


    • #3
      See: https://github.com/Daniel-Pailanir/sdid

      Comment


      • #4
        Fascinating. I'm a SCM researcher and I hadn't seen this before. How might we install this, short of just manually putting it into our command directories? Scott Merryman

        Comment


        • #5
          Jared Greathouse I don't think the site is set up to install directly from within Stata, so one will need to download the files manually.

          Comment


          • #6
            These are both extremely useful! Thank you, Scott Merryman and Henry Strawforrd!

            Comment


            • #7
              Hi everyone, the first version of sdid command is available in ssc. My recommendation is to install from github using the github command, to install type net install github, from("https://haghish.github.io/github/") and then github install Daniel-Pailanir/sdid because the latest version has better performance!

              Comment


              • #8
                Hi Professor, Daniel PV, I am trying to practise the sdid in stata using the original data. But this gives me an error:



                . sdid packspercapita state year treated, vce(placebo) seed(1213) graph g1_opt(xtitle("")) g2_opt(ylabel(0(50)150, axis(2)))
                type mismatch: exp.exp: transmorphic found where struct expected
                r(3000);

                Comment


                • #9
                  Hi, are you using the ssc version of sdid or the github version?
                  Please try using the second ado file (github) and let me know if the error persists!
                  Note: With the second ado file is not necessary using axis(2).

                  Code:
                  sdid packspercapita state year treated, vce(placebo) seed(1213) graph g1_opt(xtitle("")) g2_opt(ylabel(0(50)150))

                  Comment


                  • #10
                    Thanks Muhammad Ibrahim Shah !!
                    We found a bug in the current version that only appear in Stata 13-14 (the problem is related with Mata). We are working on it to update a better version.
                    If you can access a more current version of Stata, it can help you with the estimate.

                    Comment


                    • #11
                      Thank you, professor. I have a few other queries but more related to the theoretical development of synthetic DID. Can SDID take account of the following issues?:



                      1. take account of dynamic effects (present outcome depends on past as well as present treatment)
                      2. treatment is binary
                      3. design is staggered (multiple units take the treatment at different periods)
                      4. treatment switches on and off/treatment reversal (say a country implemented a policy in 1990 but then again in 2012, they opted out of that policy)
                      4. accommodates violation of the parallel trend assumption

                      Comment


                      • #12
                        Hi Muhammad Ibrahim Shah
                        1. take account of dynamic effects (present outcome depends on past as well as present treatment) In general, I think the best response to all of these quieres is in the Arkhangelsky et al. (2021) paper in the American Economic Review, as there they lay out the full assumptions as well as interpretation. So it is probably best to read this to be sure. Nevertheless, I provide some responses below. This takes dynamic into accounts in the sense that it is based on a single treatment adoption or staggered adoption of treatment, so once a state is treated, it does not become untreated. As the estimator proposes counterfactual outcomes over each post-treatment time period, in this sense you can see the dynamics of treatment, and indeed, this is what you observe if requesting graphical output in the second "outcome trend" graph. Much more detail on this point, as well as the exact formula for calculating each aggregate average treatment effect on the treated is available in Arkhangelsky et al. (2021)'s AER paper.
                        2. treatment is binary - Yes, actually the treatment needs to be a binary variable.
                        3. design is staggered (multiple units take the treatment at different periods) - Yes, in the Stata implementation we add the staggered design.
                        4. treatment switches on and off/treatment reversal (say a country implemented a policy in 1990 but then again in 2012, they opted out of that policy) - No, when the treated unit are in the treatment period, always will be a treated unit, it will never be a control unit after starting the adoption.
                        5. accommodates violation of the parallel trend assumption - The estimate creates a control that holds implies parallel trends in the pre-treatment period. As Arkhangelsky et al. note in their paper, this is more robust to violations of parallel trends than standard difference-in-difference models.

                        Comment


                        • #13
                          Thank you so much, I can live with the no 4 not being satisfied! I will go through the article as well.

                          Comment


                          • #14
                            Thanks Daniel to porting sdid to Stata.

                            One question:

                            The synth command ( ssc install synth ) demands a list of predictor variable(s) in order to execute and sdid, does not. Any special reason for that ?

                            Comment


                            • #15
                              No that's not true.
                              Code:
                              synth fert /// classic SCM- Justin Wiltshire's command
                                  fert(1960) ///
                                  fert(1955) ///
                                  fert(1965) ///
                                  fert(1955/1965), ///
                                  trunit(30) ///
                                  trperiod(`int_time') ///
                                  allopt nested fig keep(`adhromania')
                              Is a line of code from my current project, as is
                              Code:
                              sdid fert countryid year treat, vce(placebos)
                              SCM doesn't demand covariate predictors. My command doesn't need them, although they can be used. The issue is the syntax of specifying them, as in
                              Code:
                              loc x 1961(1)1969
                              
                              loc y 1960(1)1969
                              
                              loc z 1964(1)1969
                              
                              
                              
                              tempfile scmbasque
                              
                              synth gdpcap /// classic SCM- Justin Wiltshire's command
                                  gdpcap(`y') ///
                                  pop(1969) ///
                                      sec_agriculture(`x') ///
                                      sec_energy(`x') ///
                                      sec_industry(`x') ///
                                      sec_construction(`x') ///
                                      sec_svc_venta(`x') ///
                                      sec_svc_nonventa(`x') ///
                                  school_illit(`z') ///
                                  school_prim(`z') ///
                                  school_med(`z') ///
                                  school_high(`z') ///
                                  invest(`z'), ///
                                  trunit(15) ///
                                  trperiod(`int_time') ///
                                  allopt nested fig

                              Comment

                              Working...
                              X