fastdid implements the Difference-in-Differences (DiD) estimators in Callaway and Sant’Anna’s (2021). fastdid is
- fast, reducing the computation time with millions of units from hours to seconds,
- flexible, allowing extensions such as time-varying covariates and multiple events.
Getting Started
fastdid can be installed from GitHub.
# install.packages("devtools")
devtools::install_github("TsaiLintung/fastdid")
To use fastdid
, you need to provide the dataset data
, the column name of time timevar
, cohort cohortvar
, unit unitvar
, and outcome(s) outcomevar
. Here is a simple call:
library(fastdid) #loading the package
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
that includes the estimates. Column att
is the point estimate, se
the standard error of the estimate, att_ciub
and att_cilb
the confidence interval. The other columns indexes the estimated parameter.
To create event study plots, use plot_did_dynamics(did_estimate)
.