Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute Post_avg-Pre_avg #192

Open
Wenzhi-Ding opened this issue Feb 26, 2024 · 1 comment
Open

Compute Post_avg-Pre_avg #192

Wenzhi-Ding opened this issue Feb 26, 2024 · 1 comment

Comments

@Wenzhi-Ding
Copy link

Hi,

Thanks for this great package for implementing CS DID. When I try to use it in my project, I found after estimating ATT, there is no command to calculate post_avg_att - pre_avg_att.

For example, if the allocation of treatment group and control is not random, and such factor affects dependent variable (as the following generated data shows)

image

The estimated results will be

image

I may overlook something, but is it possible to generate a line using the pre-treatment ATT as benchmark, so that it will be clearer that whether the treatment effects are significantly different from zero. Same problem also applies to the results in table.

image

Attached are code and data I used:

data.csv

library("did")
library("tidyverse")

df = read.csv("data.csv")

out = att_gt(
  yname = "y1",
  gname = "treat",
  idname = "id",
  tname = "year",
  xformla = ~x,
  data = df,
  est_method = "dr"
)

dyn = aggte(out, type = "dynamic")
summary(dyn)
ggdid(dyn)

Thank you so much!

Best regards,
Dave

@Wenzhi-Ding
Copy link
Author

I cross check with Sun and Abraham (2021)'s command in Stata (eventstudyinteract), it can produce correct event study plot and obtain ATT unaffected by the non-random treatment allocation.

image

Using the same data I uploaded above.

gen control = treat == 0
gen T = year - treat
replace T = . if control == 1
tab T

forvalues l = 0/6 {
	gen L`l'event = T == `l'
}

forvalues l = 1/7 {
	gen F`l'event = T == -`l'
}

eventstudyinteract y1 L*event F*event, absorb(id year) cohort(treat) control_cohort(control) covariates(x)

event_plot e(b_iw)#e(V_iw), default_look stub_lag(L#event) stub_lead(F#event) together

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant