chaisemartinPackages / did_multiplegt_dyn

|| Stata | R || Estimation of event-study Difference-in-Difference (DID) estimators in designs with multiple groups and periods, and with a potentially non-binary treatment that may increase or decrease multiple times.
23 stars 6 forks source link

Question regarding the "weight" option in did_multiplegt_dyn #44

Closed qy-han closed 3 weeks ago

qy-han commented 4 weeks ago

Recently we were trying to use the “weight” option but we encountered some technical issues.

The weighting variable, named “cem_weight”, of each unit in our data were calculated using the “coarsened exact matching” method to facilitate a matched DID design. We subsequently used the following command:

did_multiplegt_dyn outcome nstate_c year treat, weight(cem_weight) effects($Ndyneffect) placebo($Nplacebo) only_never_switchers

but Stata aborts with an error message that the variable “cem_weight” cannot be found. We did check that this variable is in our dataset, so we would like to seek your advice on what might be wrong in our code.

Thank you very much for your help!

chaisemartinPackages commented 4 weeks ago

Dear Han, This is Diego from Clément de Chaisemartin's RA team. Thanks for your interest in did_multiplegt_dyn! I have tried running cem and did_multiplegt_dyn in a very basic scenario and I found no error:

qui bcuse wagepan
cem black hours married, treatment(union)
did_multiplegt_dyn lwage nr year union, weight(cem_weight) only_never_switchers

To this end, I fear that this may be related to something in your data or in the code before the command. It would be great if you could send us a reproducible example where this error shows up. Here's out team mail account: chaisemartin.packages@gmail.com Best, Diego

qy-han commented 3 weeks ago

Hi Diego,

Thank you very much for your explanation! This is super helpful. I have made a few tests on my dataset. Comparing with structures between my data and your sample data, I found that the error message "cem_weight not found" pops out because our CEM weight varies within each (state, year) cell, as we are using a individual-level data. But in using did_multiplegt_dyn, we use state as the group indicator. Once I changed to state-level data, this error message disappears.

May I ask if there is a function with the command that deals with this kind of situation? i.e. treatment may happen at a more aggregated level, but the data and the weight is at individual level.

Thank you!!

DiegoCiccia commented 3 weeks ago

Dear Han, Glad that you found a fix! As for the observation level, the command automatically adjusts to cases where the data is more disaggregated than the group level. In that case, i.e., if your data is at the period-group-id level, all the relevant variables for the estimation are collapsed at the period-group level by weighted mean (with weights specified in the weight option, if it is used), except for the weights themselves that are collapsed by sum at the period-group level. I hope this helps! Best, Diego