synth-inference / synthdid

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

Tidy-friendly wrapper for synthdid_estimate #90

Open bberger94 opened 2 years ago

bberger94 commented 2 years ago

Added synthdid() function, a wrapper for synthdid_estimate() that allows direct use of tidy syntax including formulas and data.frames/tibbles, eschewing the need to use panel.matrices(). See documentation for examples. Also allows for estimating models of multiple outcomes with one command.

bberger94 commented 2 years ago

Failing check is a warning that synthdid function has same name as synthdid package. Trivial to fix.

MatthieuStigler commented 1 year ago

this looks great @bberger94, would love to see this function, the matrix approach was a bit less intuitive, and this wrapper is a bit more in line with R's formula-based practice :-)

@davidahirshberg did you get a chance to review it and accept/reject?

bberger94 commented 1 year ago

Thanks Matthieu. I have used this in my own work and it seems to work nicely, but I would definitely double-check how my code works with covariates as I was noticing some issues with that when I last played with that. Until then I wouldn't use the formula syntax with covariates.

davidahirshberg commented 1 year ago

Ben, thanks for contributing.  This looks very cool.  Because it’ll probably be the primary way people use the package after it’s integrated, I want to be very careful to have everything working as users would expect and clearly documented.  That means I may not be able to review and merge until I have time off from teaching in a few months. It’d help me out if, in the mean time, you could figure out what’s going on with the formula syntax with covariates. On Sep 13, 2022, 4:10 PM -0400, Ben Berger @.***>, wrote:

Thanks Matthieu. I have used this in my own work and it seems to work nicely, but I would definitely double-check how my code works with covariates as I was noticing some issues with that when I last played with that. Until then I wouldn't use the formula syntax with covariates. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

bberger94 commented 1 year ago

Sure I'll check it out @davidahirshberg

bberger94 commented 1 year ago

Looks like controls are working just fine. I was surprised how little they affect the results, but the estimates appear to be the same using the new synthdid function or synthdid_estimate with an NxTxC array of controls.

I also added a method argument that allows you to choose which estimator is implemented by synthdid (argument should be a function name, default is synthdid_estimate).