Announcement

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

  • SDID Graphing Issues

    Hi all,

    I am running the following on a strongly balanced panel:

    sdid depvar state year_quarter treat, vce(placebo) reps(50) seed(123) graph

    Stata runs the estimation and produces a set of results in table form in the output, but will not produce a graph and throws the following error: "variable year_quarter not found".

    The variable year_quarter is clearly in the datatset and is being used to produce the results in table form. Running the same code without "graph" at the end throws no error at all.

    Any thoughts on what's causing the graphing error?


  • #2
    Damian Clarke and Daniel PV are the authors, so they will likely have the most prescient advice.

    Erstwhile, rename your time variable year_quarter​​​​​​​ to date and see if the issue persists.

    Comment


    • #3
      Thank you, Jared! Unfortunately, no luck after changing the var name.

      Comment


      • #4
        Okay well now you gotta start with showing the complete syntax that you ran as well as a short data example. Use dataex to show me the dataset in question

        Comment


        • #5
          use "quarterlyDataLong.dta", clear
          renvars State / state
          gen yq = yq(Year, Quarter)
          encode state, gen(state_num)
          keep state_num state Year Quarter depvar yq
          drop if state == "Tennessee" | state == "North Carolina" | (state == "Arizona" & Year <= 2011)

          // CA as only treated unit
          drop if state == "New York" | state == "Hawaii"
          drop if depvar== .

          keep if inrange(yq, 200, 209)
          bys state_num: gen N_yq = _N
          sum N_yq if state == "California"
          local N_yq_CA = r(mean)
          drop if N_yq < `N_yq_CA' // leaves 25 candidate control states
          xtset state_num yq // confirm now strongly balanced

          gen treat = (state == "California" & yq >= 206)
          sdid depvar state_num yq treat, vce(placebo) reps(50) seed(123)






          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input str20 State double(Year Quarter depvar)
          "Alabama"  2010 1                  .
          "Alabama"  2010 2                  .
          "Alabama"  2010 3                  .
          "Alabama"  2010 4                  .
          "Alabama"  2011 1                  .
          "Alabama"  2011 2                  .
          "Alabama"  2011 3                  .
          "Alabama"  2011 4                  .
          "Alabama"  2012 1                  .
          "Alabama"  2012 2 .27841463685035706
          "Alabama"  2012 3                  .
          "Alabama"  2012 4                  .
          "Alabama"  2013 1                  .
          "Alabama"  2013 2                  .
          "Alabama"  2013 3                  .
          "Alabama"  2013 4                  .
          "Alabama"  2014 1                  .
          "Alabama"  2014 2                  .
          "Alabama"  2014 3                  .
          "Alabama"  2014 4                  .
          "Alabama"  2015 1                  .
          "Alabama"  2015 2                  .
          "Alabama"  2015 3                  .
          "Alabama"  2015 4                  .
          "Alabama"  2016 1                  .
          "Alabama"  2016 2                  .
          "Alabama"  2016 3                  .
          "Alabama"  2016 4                  .
          "Alaska"   2010 1  .5450325012207031
          "Alaska"   2010 2  .5312930345535278
          "Alaska"   2010 3  .5498286485671997
          "Alaska"   2010 4  .5301960706710815
          "Alaska"   2011 1  .5668399333953857
          "Alaska"   2011 2  .5419167876243591
          "Alaska"   2011 3  .5378895998001099
          "Alaska"   2011 4  .5340507626533508
          "Alaska"   2012 1     .5534628033638
          "Alaska"   2012 2  .5348360538482666
          "Alaska"   2012 3  .5437197685241699
          "Alaska"   2012 4  .5396924018859863
          "Alaska"   2013 1  .5430094003677368
          "Alaska"   2013 2  .5362475514411926
          "Alaska"   2013 3  .5376101732254028
          "Alaska"   2013 4  .5424380898475647
          "Alaska"   2014 1  .5256970524787903
          "Alaska"   2014 2  .5260843634605408
          "Alaska"   2014 3  .5256621837615967
          "Alaska"   2014 4  .5363888740539551
          "Alaska"   2015 1  .5194871425628662
          "Alaska"   2015 2  .5227141976356506
          "Alaska"   2015 3   .535301923751831
          "Alaska"   2015 4  .5113282799720764
          "Alaska"   2016 1  .5384600162506104
          "Alaska"   2016 2  .5268908739089966
          "Alaska"   2016 3  .5517807006835938
          "Alaska"   2016 4  .5316419005393982
          "Arizona"  2010 1 .21455109119415283
          "Arizona"  2010 2   .233852818608284
          "Arizona"  2010 3  .2384597361087799
          "Arizona"  2010 4 .26335614919662476
          "Arizona"  2011 1 .20916606485843658
          "Arizona"  2011 2 .22605398297309875
          "Arizona"  2011 3 .25033214688301086
          "Arizona"  2011 4 .23507902026176453
          "Arizona"  2012 1 .25873738527297974
          "Arizona"  2012 2 .26185721158981323
          "Arizona"  2012 3                  .
          "Arizona"  2012 4                  .
          "Arizona"  2013 1                  .
          "Arizona"  2013 2                  .
          "Arizona"  2013 3                  .
          "Arizona"  2013 4                  .
          "Arizona"  2014 1                  .
          "Arizona"  2014 2                  .
          "Arizona"  2014 3 .31600382924079895
          "Arizona"  2014 4   .337756872177124
          "Arizona"  2015 1  .3373795747756958
          "Arizona"  2015 2  .3129178583621979
          "Arizona"  2015 3  .3256182372570038
          "Arizona"  2015 4  .3538859784603119
          "Arizona"  2016 1 .36041513085365295
          "Arizona"  2016 2   .268401175737381
          "Arizona"  2016 3  .3683546483516693
          "Arizona"  2016 4  .3555634617805481
          "Arkansas" 2010 1                  .
          "Arkansas" 2010 2                  .
          "Arkansas" 2010 3                  .
          "Arkansas" 2010 4                  .
          "Arkansas" 2011 1                  .
          "Arkansas" 2011 2                  .
          "Arkansas" 2011 3                  .
          "Arkansas" 2011 4                  .
          "Arkansas" 2012 1                  .
          "Arkansas" 2012 2                  .
          "Arkansas" 2012 3                  .
          "Arkansas" 2012 4                  .
          "Arkansas" 2013 1                  .
          "Arkansas" 2013 2                  .
          "Arkansas" 2013 3                  .
          "Arkansas" 2013 4                  .
          end

          Comment


          • #6
            Hi both!
            And thanks Jared Greathouse for notifying us!
            The problem is in our function (ssc version). This issue was resolved in the github ado file, so please reinstall using
            Code:
            net install sdid, from ("https://raw.githubusercontent.com/daniel-pailanir/sdid/master") replace
            and let me know if it helped. Soon we will push to the stata ssc with all these changes.
            You can see another issues in our repo https://github.com/Daniel-Pailanir/sdid

            Comment


            • #7
              Awesome, that fixed it. Thank you so much.

              Comment


              • #8
                Hi Daniel PV , does sdid allow for the treated unit to be treated in the first period of the data window and have treatment subsequently turned off?

                When I run this I get the following error: Certain units are treated in the first period of the panel. Any units which are treated the entire panel should not be included in the synthetic DID procedure.

                The unit is not treated the entire panel, but just in the first x periods.

                Comment


                • #9
                  In principle, you can't have a unit treated in period 1 because no preintervention trends = no counterfactual. Implicitly, SDID presumes that once you're treated, you're always treated. SCM hasn;t come that far yet to allow treatments to turn on and off,

                  Comment


                  • #10
                    Hi Daniel PV

                    I also have an issue when using the graph option in my sdid model which I'm hoping you can please help me understand.

                    The sdid model runs, but when I add the graph option it gives the error message: invalid '('. This happens with the ssc version and the master version from your github repo. It even happens when I use the simple examples from [2301.11859] Synthetic Difference In Differences Estimation (arxiv.org), e.g.:

                    Code:
                    . webuse set www.damianclarke.net/stata/
                    (prefix now "http://www.damianclarke.net/stata")
                    
                    . webuse prop99_example.dta, clear
                    
                    . sdid packspercapita state year treated, vce(placebo) seed(1213) 
                    Placebo replications (50). This may take some time.
                    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
                    ..................................................     50
                    
                    
                    Synthetic Difference-in-Differences Estimator
                    
                    -----------------------------------------------------------------------------
                    packsperca~a |     ATT     Std. Err.     t      P>|t|    [95% Conf. Interval]
                    -------------+---------------------------------------------------------------
                         treated | -15.60383    9.00803    -1.73    0.083   -33.25924     2.05158
                    -----------------------------------------------------------------------------
                    95% CIs and p-values are based on Large-Sample approximations.
                    Refer to Arkhangelsky et al., (2020) for theoretical derivations.
                    
                    . sdid packspercapita state year treated, vce(placebo) seed(1213) graph
                    invalid '(' 
                    r(198);
                    I am using Stata MP 17.0, last updated 08 Mar 2023.

                    Is there any way I can get the graph option working on my system?

                    Thanks

                    Andrew














                    Comment


                    • #11
                      Is there any way of getting the sdid outcome trends graph without the Time-Specific Weights? I did not see any option that would let me do that.

                      Comment


                      • #12
                        By that I mean, I want the weights for the estimates, I just don't want the weights shown in the graph.

                        Comment

                        Working...
                        X