fastdid implements the difference-in-differences estimators of Callaway and Sant'Anna (2021). fastdid is:
Install fastdid from CRAN:
install.packages("fastdid")
Or install the development version from GitHub:
# install.packages("devtools")
# devtools::install_github("TsaiLintung/fastdid")
install.packages("fastdid", repos = c('https://tsailintung.r-universe.dev', 'https://cloud.r-project.org'))
A call needs five things: the dataset data, and the column names for time
(timevar), cohort (cohortvar), unit (unitvar), and the outcome or
outcomes (outcomevar).
library(fastdid)
did_sim <- sim_did(1e+03, 10) # simulate some data
did_estimate <- fastdid(data = did_sim$dt, timevar = "time",
cohortvar = "G", unitvar = "unit", outcomevar = "y")
The function returns a data.table of estimates. Column att is the point
estimate. Column se is its standard error. Columns att_cilb and att_ciub
give the confidence interval. The remaining columns index the estimated
parameter.
To draw an event-study plot, call plot_did_dynamics(did_estimate).
cohortvar2, for example cohortvar2 = c("G2", "G3") for
M = 3.Lin-Tung Tsai created and maintains fastdid. Many thanks to Maxwell Kellogg and Kuan-Ju Tseng for their contribution.