bcallaway11 / did

Difference in Differences with Multiple Periods, website: https://bcallaway11.github.io/did
287 stars 91 forks source link

Only Significant ATE #152

Closed Nico1997121 closed 1 year ago

Nico1997121 commented 1 year ago

Hi,

has someone an idea how to show only the signifacant ATE effetcs after using att(....)

Nico1997121 commented 1 year ago
Screenshot 2022-11-04 202307
bcallaway11 commented 1 year ago

Hi Nico,

Thanks for the message. What about something like the following code:

library(did)

out <- att_gt(yname = "lemp",
              gname = "first.treat",
              idname = "countyreal",
              tname = "year",
              xformla = ~1,
              data = mpdta,
              est_method = "reg"
)

tidy_attgt <- tidy(out)
keepers <- abs(tidy_attgt$estimate / tidy_attgt$std.error) > 1.96
only_significant_results <- tidy_attgt[keepers,]
only_significant_results
#>             term group time    estimate  std.error     conf.low    conf.high
#> 2 ATT(2004,2005)  2004 2005 -0.07042316 0.03396954 -0.159912509  0.019066193
#> 3 ATT(2004,2006)  2004 2006 -0.13725874 0.04039405 -0.243672840 -0.030844637
#> 4 ATT(2004,2007)  2004 2007 -0.10081136 0.03768321 -0.200084017 -0.001538709
#> 8 ATT(2006,2007)  2006 2007 -0.04122447 0.02004654 -0.094035073  0.011586130
#> 9 ATT(2007,2004)  2007 2004  0.03050666 0.01530419 -0.009810717  0.070824028
#>   point.conf.low point.conf.high
#> 2  -0.1370022261    -0.003844090
#> 3  -0.2164296306    -0.058087847
#> 4  -0.1746690984    -0.026953628
#> 8  -0.0805149636    -0.001933979
#> 9   0.0005109853     0.060502326
Nico1997121 commented 1 year ago

Thanks,in the end i used a similar Code; was just wondering whether its possible too target the CI's directly (and check for 0's)

bcallaway11 commented 1 year ago

Glad to hear this. To target the confidence interval, I think you could slightly modify the above code:

keepers <- sign(tidy_attgt$conf.low) == sign(tidy_attgt$conf.high)