Learn R Programming

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 that implements the data application from the paper:

library(fetwfe)
library(bacondecomp)

set.seed(23451)

data(divorce)

res <- fetwfe(
    pdata=divorce[divorce$sex == 2, ],
    time_var="year",
    unit_var="st",
    treatment="changed",
    covs=c("murderrate", "lnpersinc", "afdcrolls"),
    response="suiciderate_elast_jag",
    q=0.5,
    verbose=TRUE)

summary(res)

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

References

Copy Link

Version

Install

install.packages('fetwfe')

Monthly Downloads

430

Version

1.5.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Gregory Faletto

Last Published

July 2nd, 2025

Functions in fetwfe (1.5.0)

twfeCovsWithSimulatedData

Run twfeCovs on Simulated Data
getTes

Compute True Treatment Effects
simulateData

Generate Random Panel Data for FETWFE Simulations
genCoefsCore

Generate Coefficient Vector for Data Generation
genCoefs

Generate Coefficient Vector for Data Generation
simulateDataCore

Generate Random Panel Data for FETWFE Simulations
twfeCovs

Two-way fixed effects with covariates and separate treatment effects for each cohort
etwfeToFetwfeDf

Convert data prepared for etwfe::etwfe() to the format required by fetwfe() and fetwfe::etwfe()
betwfe

Bridge-penalized extended two-way fixed effects
attgtToFetwfeDf

Convert data formatted for att_gt() to a dataframe suitable for fetwfe() / etwfe()
fetwfe

Fused extended two-way fixed effects
fetwfeWithSimulatedData

Run FETWFE on Simulated Data
etwfe

Extended two-way fixed effects
etwfeWithSimulatedData

Run ETWFE on Simulated Data
etwfe-class

Extended Two-Way Fixed Effects Output Class
betwfeWithSimulatedData

Run BETWFE on Simulated Data
fetwfe-class

Fused Extended Two-Way Fixed Effects Output Class