synth-inference / synthdid

Synthetic difference in differences
https://synth-inference.github.io/synthdid
BSD 3-Clause "New" or "Revised" License
262 stars 98 forks source link

Extracting outcomes of synthetic controls in synthdid #87

Open dannyredel opened 2 years ago

dannyredel commented 2 years ago

Is there a way of extracting the outcome variable generated by the synthetic control (ideally, in a data.frame format)? I'm interested in using it to plot the gap between the treatment and the synthetic (like this)

thanks!

davidahirshberg commented 2 years ago

What do you mean by outcome variable? On Apr 19, 2022, 9:39 AM -0400, Daniel Redel @.***>, wrote:

Is there a way of extracting the outcome variable generated by the synthetic control (ideally, in a data.frame format)? I'm interested in using it to plot the gap between the treatment and the synthetic (like this) thanks! — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

dannyredel commented 2 years ago

sorry, I mean the *outcome Y (or trend) of the synthetic control in each time unit t. For example:

##    time_unit real_y synth_y
##        <dbl>  <dbl>   <dbl>
##  1      1970   123     116.
##  2      1971   121     118.
##  3      1972   124.    123.
##  4      1973   124.    124.
##  5      1974   127.    126.
##  6      1975   127.    127.
##  7      1976   128     127.
##  8      1977   126.    125.
##  9      1978   126.    125.
## 10      1979   122.    122.
dannyredel commented 2 years ago

Hi! just wanted to ask again If you can help me with my initial question, would really appreciate it! thanks

davidahirshberg commented 2 years ago

if you are interested in the curve that we plot in our analogous diagrams, see here: https://github.com/synth-inference/synthdid/blob/b839f2cc1685c8fddcf274b882f82e2f6eab3894/R/plot.R#L104.  However, keep in mind that the synthetic diff in diff estimator does not just compare this curve with the trajectory of the treated unit(s) to estimate a treatment effect. On Apr 27, 2022, 1:40 PM -0400, Daniel Redel @.***>, wrote:

Hi! just wanted to ask again If you can help me with my initial question, would really appreciate it! thanks — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

kgriffith99 commented 7 months ago

If you save the plot as p1, try

layer_data(p1)

works like a charm for me!