Open RubyDoeleman opened 10 months ago
Sorry for the delay @RubyDoeleman as I just saw this! Thank you for typing up the example so clearly! If you would like to run separate regressions, I think you can "trick" Stata's `lincom' by concatenating the matrices yourself.
eventstudyinteract Y ggroupzero_* ggroupzero0-ggroupzero5 if groupvariable == 0, cohort(first_treatment_year) control_cohort(never_treated) absorb(i.id i.year) vce(cluster clustervariable)
matrix bgroupzero = e(b_iw)
matrix Vgroupzero = e(V_iw)
eventstudyinteract Y ggroupone_* ggroupone0-ggroupone5 if groupvariable == 1, cohort(first_treatment_year) control_cohort(never_treated) absorb(i.id i.year) vce(cluster clustervariable)
matrix bgroupzero = e(b_iw)
matrix Vgroupzero = e(V_iw)
// use mata to concatenate the variance covariance matrices
matrix b = bgroupzero, bgroupone
mata
Vzero=st_matrix("Vgroupzero")'
Vone=st_matrix("Vgroupone")'
V = blockdiag(Vzero, Vone)
st_matrix("V",V)
end
mat coln V = `: coln Vgroupzero ' `: coln Vgroupone'
mat li V
mat rown V = `: rown Vgroupzero ' `: rown Vgroupone'
// lincom to test difference (which relies on estimates stored in b and V
ereturn post b V
lincom (ggroupzero0 + ggroupzero1 + ggroupzero2 + ggroupzero3 + ggroupzero4 + ggroupzero5)/6 - (ggroupone0 + ggroupone1 + ggroupone2 + ggroupone3 + ggroupone4 + ggroupone5)/6
I tested the above and hopefully this solves your issue. Let me know if you have any questioins.
Thanks so much for getting back to me, Liyang! This solved the issue. :-)
Dear Liyang,
Thank you for your great Stata package eventstudyinteract! I am using the command to separately estimate ATTs for two subsamples in my panel data.
I want to compare the estimated coefficients for the two different subsamples to see whether they differ significantly. The Stata help file provides a way to do this by interacting the treatment dummy with the different subgroups and estimate one regression.
However, I want to separately estimate the two regressions. The Statahelp file mentions that "Alternatively, we can use eventstudyinteract separately on the two subsamples [...]", but does not provide example code to achieve this.
I have tried separately storing the result in matrices, but I cannot recall them simultaneously and use the lincom command to compare them. See stylized code below:
// generating interaction variables for sub-groups
// first subsample
// second subsample
// lincom to test difference
lincom (ggroupzero0 + ggroupzero1 + ggroupzero2 + ggroupzero3 + ggroupzero4 + ggroupzero5)/6 - (ggroupone0 + ggroupone1 + ggroupone2 + ggroupone3 + ggroupone4 + ggroupone5)/6
If I run this, Stata tells me "ggroupzero0 not found".
Is there a way to store the estimates from eventstudyinteract and compare the ATTs from separate regressions?
Thanks a lot in advance!
Best regards, Ruby