kylebutts / did2s

Two-stage Difference-in-Differences package following Gardner (2021)
http://kylebutts.github.io/did2s
Other
96 stars 22 forks source link

`event_study()`: error for Borusyak, Jaravel, Spiess (2021) #24

Closed etiennebacher closed 1 year ago

etiennebacher commented 1 year ago

Hello, I have an error when I run the example in the docs of event_study():

suppressPackageStartupMessages(library(did2s))

x <- event_study(
    data = df_het, yname = "dep_var", idname = "unit",
    tname = "year", gname = "g", estimator = "all"
)
#> Note these estimators rely on different underlying assumptions. See Table 2 of `https://arxiv.org/abs/2109.05913` for an overview.
#> Estimating TWFE Model
#> Estimating using Gardner (2021)
#> Estimating using Callaway and Sant'Anna (2020)
#> Estimating using Sun and Abraham (2020)
#> Estimating using Borusyak, Jaravel, Spiess (2021)
#> Error in `[.data.table`(data, , `:=`(paste0("zz000wtr", e), ifelse(is.na(zz000event_time),  : 
#>   unused argument (env = list(e = e))
#> Warning in event_study(data = df_het, yname = "dep_var", idname = "unit", :
#> Borusyak, Jaravel, Spiess (2021) Failed
#> Estimating using Roth and Sant'Anna (2021)

This fails both for the CRAN and Github versions.

etiennebacher commented 1 year ago

Actually I just noticed that the code above works with the CRAN version of didimputation but not with its development version. Maybe it's better to open this issue on the repo of didimputation?

kylebutts commented 1 year ago

Hi @etiennebacher, update to the dev version of data.table and that error will go away. I started using the new env argument expecting the data.table update to be on CRAN soon and it's been a year 😅

etiennebacher commented 1 year ago

Indeed, thank you. Maybe you should put this version requirement in DESCRIPTION? Or display a message if the version of data.table is too low?