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

DID with a single control unit #84

Open ledainga opened 2 years ago

ledainga commented 2 years ago

Your DID model uses all available control units. Nevertheless, for the policy change I'm studying, it seems more intuitive to compare my treated unit to a single control unit (both share very similar characteristics that stand out from the others). Unfortunately, when I use the function did_estimate() using a subset of my data with only my treated unit and the single control unit I have chosen, I get the error: Error in apply(Y[1:N0, 1:T0], 1, diff) : dim(X) must have a positive length Is there a way to solve this issue? I am not using covariates. I am aware that I will not be able to use the placebo approach to estimate the standard error of my DID estimate. But I would still like to show a DID plot together with the SC and SDID plots (as you do in your paper) and the average DID treatment effect even its standard error is missing. Thanks a lot!

davidahirshberg commented 2 years ago

By default, did_estimate uses multiple control units to calculate the regularization parameter zeta used for estimating synthetic control weights, which it does not, of course, actually do.  Passing the argument noise.level=NA should fix your problem. Let me know if it doesn’t.

Best, David On Mar 15, 2022, 11:27 AM -0400, ledainga @.***>, wrote:

Your DID model uses all available control units. Nevertheless, for the policy change I'm studying, it seems more intuitive to compare my treated unit to a single control unit (both share very similar characteristics that stand out from the others). Unfortunately, when I use the function did_estimate() using a subset of my data with only my treated unit and the single control unit I have chosen, I get the error: Error in apply(Y[1:N0, 1:T0], 1, diff) : dim(X) must have a positive length Is there a way to solve this issue? I am not using covariates. I am aware that I will not be able to use the placebo approach to estimate the standard error of my DID estimate. But I would still like to show a DID plot together with the SC and SDID plots (as you do in your paper) and the average DID treatment effect even its standard error is missing. Thanks a lot! — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you are subscribed to this thread.Message ID: @.***>

ledainga commented 2 years ago

It worked, thanks a lot. Initially, I had thought to report a missing "placebo method" standard error for my DID estimate with a single control unit. The reason is that I had subset my data to contain only two units (my treated unit and the one control unit I have chosen). However, if I do not subset my data and manage to ask did_estimate to always set the weight of this control unit to one, then sqrt(vcov(did, method='placebo')) would still let me estimate a "placebo method" standard error, right? This standard error would be the standard deviation of all the DID estimates I would get if I compared my chosen control unit to every other available control unit. Would I be able to do this with did_estimate and vcov(did,method='placebo')? If so, how can I ask did_estimate to set the unit weight to 1 for my chosen control unit? Or, what would be the way to do it?

Thank you! Leda

davidahirshberg commented 2 years ago

There may be a way to do it by passing some strange options, but that’s very far from what the code is intended to do. If that’s what you’re looking for, I’d encourage you to write your own code for the sake of transparency. On Mar 17, 2022, 5:03 AM -0400, ledainga @.***>, wrote:

It worked, thanks a lot. Initially, I had thought to report a missing "placebo method" standard error for my DID estimate with a single control unit. The reason is that I had subset my data to contain only two units (my treated unit and the one control unit I have chosen). However, if I do not subset my data and manage to ask did_estimate to always set the weight of this control unit to one, then sqrt(vcov(did, method='placebo')) would still let me estimate a "placebo method" standard error, right? This standard error would be the standard deviation of all the DID estimates I would get if I compared my chosen control unit to every other available control unit. Would I be able to do this with did_estimate and vcov(did,method='placebo')? If so, how can I ask did_estimate to set the unit weight to 1 for my chosen control unit? Or, what would be the way to do it? Thank you! Leda — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>