I am using Sun and Abraham's (2021) Stata package eventstudyinteract 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. See the subheading "Compare event study estimates for subsamples" in the help file.
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
forvalues k = 9(-1)2 {
gen ggroupzero_`k' = time_to_treat == -`k' & groupvariable == 0
}
forvalues k = 0/5 {
gen ggroupzero`k' = time_to_treat == `k' & groupvariable == 0
}
forvalues k = 9(-1)2 {
gen ggroupone_`k' = time_to_treat == -`k' & groupvariable == 1
}
forvalues k = 0/5 {
gen ggroupone`k' = time_to_treat == `k' & groupvariable == 1
}
replace ggroupzero0 = 0 if missing(first_treatment_year)
replace ggroupone0 = 0 if missing(first_treatment_year)
* first subsample
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)
ereturn post bgroupzero Vgroupzero
* second subsample
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)
ereturn post bgroupone Vgroupone
* 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?
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. See the subheading "Compare event study estimates for subsamples" in the help file.
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
forvalues k = 9(-1)2 {
gen ggroupzero_`k' = time_to_treat == -`k' & groupvariable == 0
}
forvalues k = 0/5 {
gen ggroupzero`k' = time_to_treat == `k' & groupvariable == 0
}
forvalues k = 9(-1)2 {
gen ggroupone_`k' = time_to_treat == -`k' & groupvariable == 1
}
forvalues k = 0/5 {
gen ggroupone`k' = time_to_treat == `k' & groupvariable == 1
}
replace ggroupzero0 = 0 if missing(first_treatment_year)
replace ggroupone0 = 0 if missing(first_treatment_year)
* first subsample
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)
ereturn post bgroupzero Vgroupzero
* second subsample
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)
ereturn post bgroupone Vgroupone
* 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?