Fused Extended Two-Way Fixed Effects

Calculates the fused extended two-way fixed effects (FETWFE) estimator for unbiased and efficient estimation of difference-in-differences in panel data with staggered treatment adoption. This estimator eliminates bias inherent in conventional two-way fixed effects estimators, while also employing a novel bridge regression regularization approach to improve efficiency and yield valid standard errors. Also implements extended TWFE (etwfe) and bridge-penalized ETWFE (betwfe). Provides S3 classes for streamlined workflow and supports flexible tuning (ridge and rank-condition guarantees), automatic covariate centering/scaling, and detailed overall and cohort-specific effect estimates with valid standard errors. Includes simulation and formatting utilities, extensive diagnostic tools, vignettes, and examples. See Faletto (2025) ().


Fused Extended Two-Way Fixed Effects

The {fetwfe} package implements fused extended two-way fixed effects (FETWFE), a methodology for estimating treatment effects in difference-in-differences with staggered adoptions.

  • For a brief introduction to the methodology, as well as background on difference-in-differences with staggered adoptions and motivation for FETWFE, see this blog post.
  • For more detailed slides on the methodology (but less detailed than the paper), see here.
  • Check out the most recent draft of the full paper here.
  • This blog post explains a little more about what the package does under the hood, if you're interested.

fetwfePackage

To install the {fetwfe} package, simply use

install.packages("fetwfe")

You can also install the latest development version by using

# install.packages("remotes")  # if needed
remotes::install_github("gregfaletto/fetwfePackage")

The primary function in the {fetwfe} is fetwfe(), which implements fused extended two-way fixed effects. Here's some example code applying fetwfe() to the castle data set from the bacondecomp package:

library(fetwfe)
library(bacondecomp)

data(castle)

# Response: the log homicide rate. Treatment: `cdl` records the share of
# the year the castle-doctrine law was in effect, so `cdl > 0` gives the
# absorbing 0/1 treatment indicator `fetwfe()` requires.
castle$l_homicide <- log(castle$homicide)
castle$treated <- as.integer(castle$cdl > 0)

res <- fetwfe(
    pdata = castle,
    time_var = "year",
    unit_var = "state",
    treatment = "treated",
    response = "l_homicide",
    verbose = TRUE)

summary(res)

For vignettes and full documentation, check out the page for the {fetwfe} package on CRAN.

References

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("fetwfe")

1.10.0 by Gregory Faletto, 5 months ago


https://github.com/gregfaletto/fetwfePackage


Report a bug at https://github.com/gregfaletto/fetwfePackage/issues


Browse source code at https://github.com/cran/fetwfe


Authors: Gregory Faletto [aut, cre] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports generics, glmnet, grpreg, Matrix

Suggests bacondecomp, knitr, rmarkdown, dplyr, did, expm, ggplot2, broom, lme4, testthat, tibble


See at CRAN