Skip to contents

R-CMD-check CRANd

fastdid implements the difference-in-differences estimators of Callaway and Sant’Anna (2021). fastdid is:

Getting started

Install fastdid from CRAN:

install.packages("fastdid")

Or install the development version from GitHub:

# install.packages("devtools")
devtools::install_github("TsaiLintung/fastdid")

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).

More

  • did — staggered difference-in-differences, by Callaway and Sant’Anna
  • fastdid — the full list of arguments and features
  • double — an introduction to DiD with multiple events. For M >= 2 confounding events, pass a vector to cohortvar2, for example cohortvar2 = c("G2", "G3") for M = 3.
  • misc — the comparison with did, the benchmark, the tests, and the experimental features

Acknowledgments

Lin-Tung Tsai created and maintains fastdid. Many thanks to Maxwell Kellogg and Kuan-Ju Tseng for their contribution.