asjadnaqvi / DiD

Keeping track of what is going on with the latest DiD innovations.
https://asjadnaqvi.github.io/DiD
MIT License
423 stars 151 forks source link

I have two issues. One is that after adding control variables(did_multiplegt_dyn), the results don't appear, even though I've installed the suggested packages. The second is that I encountered the following prompt. #19

Open kikiwong333 opened 3 months ago

kikiwong333 commented 3 months ago

did_multiplegt lnwwe groupid year wec1 if _weight!=.,robust_dynamic dynamic(5) placebo(3) controls( $firmlist $industriallist $citylist $policy) breps(10) cluster( double_cluster ) // wec1 is a dummy I do not know why and how to solve it? The command was not able to estimate the treatment effect 5 periods after groups' treatment changes for the first time. If your treatment is continuous or takes a large number of values, you may need to use the threshold_stable_treatment option to ensure you have groups whose treatment does not change over time. You may also need to use the recat_treatment option to discretize your treatment variable. You may also be trying to estimate more dynamic effects than it is possible to do in your data.

The command was not able to run till the end, presumably because it could not estimate all placebos and dynamic effects requested. Estimates are stored in e(), so you can type ereturn list to see which placebos and dynamic effects the command could estimate. To solve this problem, you will probably have to diminish the number of placebos or dynamic effects requested. See the help file for more information on the maximum number of dynamic effects and placebos the command can compute.

Thank you so much

asjadnaqvi commented 1 month ago

@DiegoCiccia a question for did_multiplegt

DiegoCiccia commented 1 month ago

Dear all, I am Diego from Clément de Chaisemartin's RA Team. Thanks for your interest in did_multiplegt! From the second error line, it seems that the command was not able to compute all the effects and/or placebos requested. From the first error line, it seems that the command failed to estimate the fifth dynamic effect. In did_multiplegt, when there is no group with an n-th period after the first switch, the command halts and gives the error above. We changed this feature in did_multiplegt_dyn, whereby the program estimates all the effects that can be estimated, while leaving a message about the effects that could not be estimated. Here's an example:

clear
set obs 36
gen group = mod(_n-1, 6) + 1
bys group: gen time = _n
sort group time
gen D = time >= group + 1 & group > 2
gen Y = uniform() * (D + 1)

In this DGP, group 3 has the highest amount of post-switch periods (3). If we try to estimate more effects than that, did_multiplegt gives the same error as the one reported in the original post:

did_multiplegt Y group time D, robust_dynamic dynamic(4) breps(10)

Notice that the effects that could have been computed (Effect_0 to Effect_2 in did_multiplegt notation) are still retrievable from ereturn, even though the table is not displayed.

Instead, in did_multiplegt_dyn the estimation routine does not halt, even though a message is displayed in the console:

did_multiplegt_dyn Y group time D, effects(4)

To this end, it should be enough to install did_multiplegt_dyn and run your model with it. If there are any further issues, please refer to the did_multiplegt_dyn GitHub page and/or contact us via email. Best, Diego