mcaceresb / stata-honestdid

Robust inference in difference-in-differences and event study designs (Stata version of the R package of the same name)
79 stars 18 forks source link

Sensitivity Analysis for Other Periods #4

Closed wenddymacro closed 1 year ago

wenddymacro commented 1 year ago

hi guys, we are interested in the effect for the fourth period after treatment. our twfe event study plot:

image

our code of honestdid :

`matrix l_vec=(0\0\0\0\1\0\0\0\0\0\0\0\0)

honestdid, l_vec(l_vec) pre(1/12) post(13/25) mvec(0(0.025)0.25)

local plotopts xtitle(Mbar) ytitle(95% Robust CI) honestdid, cached coefplot plotopts'

the results:

image

why the original effect/CI(red line) is different from the effect in TWFE ?

any insights?

thanks in advanced.

mcaceresb commented 1 year ago

@wenddymacro What is

matrix list e(b)

?

wenddymacro commented 1 year ago
image
mcaceresb commented 1 year ago

@wenddymacro Can you copy/paste the output of

matrix list e(b)
mata rows(st_matrix("e(V)")), cols(st_matrix("e(V)"))
matrix l_vec=(0\0\0\0\1\0\0\0\0\0\0\0\0)
honestdid, l_vec(l_vec) pre(1/12) post(13/25) mvec(0 0.025)
mata `s(HonestEventStudy)'.CI
mata `s(HonestEventStudy)'.betahat
mata `s(HonestEventStudy)'.numPrePeriods
mata `s(HonestEventStudy)'.numPostPeriods
mata `s(HonestEventStudy)'.options.alpha
mata `s(HonestEventStudy)'.options.l_vec
mata `s(HonestEventStudy)'.options.Mvec
mata `s(HonestEventStudy)'.options.grid_lb
mata `s(HonestEventStudy)'.options.grid_ub

?

wenddymacro commented 1 year ago
image image image image image image
mcaceresb commented 1 year ago

@wenddymacro That output looks correct to me; you ran

local plotopts xtitle(Mbar) ytitle(95% Robust CI)
honestdid, cached coefplot `plotopts'

after this and got the plot in your original comment?

wenddymacro commented 1 year ago

image

the plot is ok, but why?

mcaceresb commented 1 year ago

@wenddymacro I am a bit confused about what you mean by "why"? I haven't been able to reproduce the original issue. It's possible there were mis-aligned runs of honestdid is the only thing that comes to mind, but can't say for sure.

In any case, it seems that re-running fixed whatever issue there was?

wenddymacro commented 1 year ago

sorry to confusing u. i am interested in the reason on the difference between the rerun result and the original plot

mcaceresb commented 1 year ago

@wenddymacro Right; I don't know the reason. In your original comment you said you ran

matrix l_vec=(0\0\0\0\1\0\0\0\0\0\0\0\0)
honestdid, l_vec(l_vec) pre(1/12) post(13/25) mvec(0 0.025)
local plotopts xtitle(Mbar) ytitle(95% Robust CI)
honestdid, cached coefplot `plotopts'

right? But right now as I was asking for debug info, you re-run that and got a different result. I don't know why running the same code twice would give you different results; it should always give you the same thing. Did you run the above code all at once to get the original plot?

mcaceresb commented 1 year ago

@wenddymacro From a new Stata session, can you run

matrix l_vec=(0\0\0\0\1\0\0\0\0\0\0\0\0)
honestdid, l_vec(l_vec) pre(1/12) post(13/25) mvec(0(0.025)0.25)
local plotopts xtitle(Mbar) ytitle(95% Robust CI)
honestdid, cached coefplot `plotopts'

matrix l_vec=(0\0\0\0\1\0\0\0\0\0\0\0\0)
honestdid, l_vec(l_vec) pre(1/12) post(13/25) mvec(0 0.25)
local plotopts xtitle(Mbar) ytitle(95% Robust CI)
honestdid, cached coefplot `plotopts'

and report the output? All your plots look different, which doesn't really make sense, and while your latest note does look like a bug, it also seems unrelated to your original post.

PS: Please include the estimates from the first honestdid command as well.

wenddymacro commented 1 year ago

sorry to mislead u. i ran other code.

i reran the code in my original post to the right plot:

image
wenddymacro commented 1 year ago

it seems that re-running fixed the issue. thanks very much