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

Incorrect effect names in e(b) -- and consequently esttab, etc. #63

Closed parobo closed 6 days ago

parobo commented 6 days ago

Dear did_multiplegt_dyn team. First of all thanks for the great command!

I think I discovered an issue with the naming of effects in e(b) in Stata. Description below.

The did_multiplegt_dyn command in Stata is currently naming all estimated effects in e(b) "Av_tot_effect". This of course leads to wrong names in esttab, etc. To reproduce:

clear
set seed 123
scalar TT = 20
scalar GG = 1000
set obs `= TT * GG'
gen G = mod(_n-1,GG) + 1
gen T = floor((_n-1)/GG)
sort G T
gen D = uniform() > 0.5
gen X = uniform() * T
gen Y = uniform() * (1 + D + X)

did_multiplegt_dyn Y G T D, effects(2) placebo(2) graph_off

mat list e(b)

Output:

e(b)[1,5]
    Av_tot_eff  Av_tot_eff  Av_tot_eff  Av_tot_eff  Av_tot_eff
y1   .52691324   .33026221   .08062557   .26340992   .57002694

Expected output:

e(b)[1,5]
    Effect_1  Effect_2  Placebo_1  Placebo_2  Av_tot_eff
y1   .52691324   .33026221   .08062557   .26340992   .57002694

I tried to trace back the issue in the ado file. My best guess is that in line 2820, the column names are defined as mat coln b = `rownames_alt' Av_tot_eff However as far as I can tell rownames_alt is not defined before and hence empty. The renaming of the columns then simply uses Av_tot_eff for all columns.


Issue on: Mac OS 11.7 Stata 17.0 did_multiplegt_dyn version from: March 21st, 2024

chaisemartinPackages commented 6 days ago

Hi Paul,

Thanks for reporting that, there was some error in the naming (in exactly that section you pointed out) I accidentally introduced in yesterday's update on SSC. I uploaded a fixed ado in our repo here on GitHub and we will of course also fix this with our next update on SSC. Please feel free to let me know if the updated version solves your Issue!

Again thanks for pointing that out so quickly and best, Felix

parobo commented 6 days ago

Hi Felix, thanks for the super quick reply and fix. Works now. Best, Paul