bcallaway11 / did

Difference in Differences with Multiple Periods, website: https://bcallaway11.github.io/did
287 stars 91 forks source link

Warning: Not returning pre-test Wald statistic due to singular covariance matrix #145

Closed cjing1 closed 1 year ago

cjing1 commented 1 year ago

Thank you to the authors for developing this amazing method for Staggered DiD and providing the R package.

When I applied the method, I got the following warning: Not returning pre-test Wald statistic due to singular covariance matrix. My understanding of a singular covariance matrix is that if some variable is an exact linear combination of the other variables, with constant term allowed, the correlation and covariance matrices of the variables will be singular.

However, I am not using any covariates in my code with xformla = ~1, and I checked for correlation and linear model, there are no perfect predictions or collinearity existing among yname, gname, idname, tname variables.

mw.attgt <- att_gt(yname = "e_perc_neg", gname = "firsttreat", idname = "id", tname = "Event days", xformla = ~1, data = final_data, est_method = "reg" )

Also, the att_gt method is still functional with regular output. May I ask if there are other situations that might trigger the warning? And is there another way I can test for the parallel trend?

Thank you so much for your time. Looking forward to hearing your reply.

cjing1 commented 1 year ago

I also tried the conditional_did_pretest function, it works and reports a p-value around .8

bcallaway11 commented 1 year ago

You are right that it is about a covariance matrix not being invertible, but here it is the covariance matrix of the estimated ATT(g,t)'s. Here are a couple of alternative ideas for you. First, you can use ggdid(mw.attgt) which will plot all of the estimated ATT(g,t)'s. The confidence bands that did provides are uniform, so that you can just check if the confidence intervals cover 0 in all pre-treatment periods. Second, I think a lot of people that use this package just report an event study (e.g., aggte(mw.attgt, type="dynamic"), plot the results, and then check if pre-treatment estimates are different from 0.

Brant

cjing1 commented 1 year ago

Thank you Prof. Callaway for your prompt reply, it is super helpful.

cjing1 commented 1 year ago

Just want to double check on whether my interpretation for conditional_did_pretest function result is correct or not.

Since the null hypothesis is: H0 : E[Yt − Yt−1|X, Gg = 1] − E[Yt − Yt−1|X, C = 1] = 0 a.s. for all 2 ≤ t < g ≤ T .

If the conditional_did_pretest result p-value is larger than 0.05, we failed to reject H0, so the Augmented Conditional Parallel Trends is hold.

Is my understanding correct?

pedrohcgs commented 1 year ago

Hi, Yes, I would say that you do not have enough evidence to reject the augmented conditional parallel trends. Here, I would avoid saying that it holds because the tests may not be powerful to detect some violations (for a given sample size).

Thanks Pedro

On Fri, Sep 23, 2022 at 10:47 AM ChenJ @.***> wrote:

Just want to double check on whether my interpretation for conditional_did_pretest function result is correct or not.

Since the null hypothesis is: H0 : E[Yt − Yt−1|X, Gg = 1] − E[Yt − Yt−1|X, C = 1] = 0 a.s. for all 2 ≤ t < g ≤ T .

If the conditional_did_pretest result p-value is larger than 0.05, we failed to reject H0, so the Augmented Conditional Parallel Trends is hold.

Is my understanding correct?

— Reply to this email directly, view it on GitHub https://github.com/bcallaway11/did/issues/145#issuecomment-1256379168, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABE7344ANC5AERIPJP35KYDV7XGIDANCNFSM6AAAAAAQPWAZUI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

cjing1 commented 1 year ago

Thank you Prof. Sant'Anna for the clarification. I appreciate it.