bcallaway11 / did

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

tidy for `AGGTEobj` objects and confidence intervals #191

Open tkeskinturk opened 5 months ago

tkeskinturk commented 5 months ago

Hello!

I am using the aggte function to aggregate a model, and I would like to grab the output through tidy.

That said, there seems to be a mismatch between the tidy output and actual results: the confidence intervals coming in tibbles from tidy are different than the confidence intervals from aggte.

There seems to be no issue for the estimates and SEs (and using the 1.96 cutoff produces the same CIs as that of summary).

Here is a reproducible example. I am assuming that there is a bug somewhere that might cause problems.

Big fan of the package!

library(tidyverse)
library(did)

d <- mpdta
m <- att_gt(
  yname = 'lemp',
  tname = 'year',
  idname = 'countyreal',
  gname = 'first.treat',
  data = d,
  allow_unbalanced_panel = TRUE,
  control_group = "notyettreated"
)

m_agg <- aggte(m, type = "simple")

summary(m_agg)
#> 
#> Call:
#> aggte(MP = m, type = "simple")
#> 
#> Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
#> 
#> 
#>      ATT    Std. Error     [ 95%  Conf. Int.]  
#>  -0.0398        0.0123    -0.0638     -0.0158 *
#> 
#> 
#> ---
#> Signif. codes: `*' confidence band does not cover 0
#> 
#> Control Group:  Not Yet Treated,  Anticipation Periods:  0
#> Estimation Method:  Doubly Robust
tidy(m_agg)
#>     type    estimate  std.error    conf.low  conf.high point.conf.low
#> 1 simple -0.03976363 0.01225156 -0.01176106 0.03626419    -0.01176106
#>   point.conf.high
#> 1      0.03626419

Created on 2024-02-07 with reprex v2.1.0