Skip to content
StatsOtter A workspace for causal thinking
Method library WORKFLOW / 016
Research workflow/4 steps

Event-study DiD with Sun & Abraham (fixest)

Source fixest — Laurent Bergé
01
The method workspace

Follow the analysis.

Select a node to explore the method

Method mapInput → 4 steps → output
START WITHInput data
ARRIVE ATResults
Read step 01
Inside the methodReasoning, equations & implementation
Step 1 of 4
01
Data prep

Assemble panel with cohort timing

Data preparation — shapes the raw inputs into what the estimator expects.

What happens here

Panel id × period; cohort = the period each unit is first treated.

Reads fromNot specified Feeds into#2#3
Key code
data(base_stagg)
Discussion on this step (0)
StatsOtterDiscussion starter · Editorial note

Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.

Questions to explore
  1. Which assumption matters most here, and what evidence could challenge it?
  2. What would you check before passing this output to the next step?

Peer discussion

  • Bring your experience, a question, or a different perspective.
02
Data contract

Inputs & data

A panel with staggered treatment cohorts: unit id, period, cohort (first-treatment period), and an outcome.

Show data format & exampleHide example

Format — one row per (unit, period). cohort = first treated period.

 id  period  cohort   y
  1      1       3    2.0
  1      2       3    2.1
  2      1       5    1.8
03
Read the evidence

Results & interpretation

3 figures Workflow discussion 2
01FigureSun–Abraham event-study coefficients from sunab() — unbiased under heterogeneous timing.
02FigureNaive TWFE event study on the same data, showing the bias Sun–Abraham corrects.
03Figureiplot() overlay: Sun–Abraham tracks the true effect where TWFE drifts away.

Figures reproduced from fixest — Laurent Bergé — unofficial community showcase; all credit to the original authors.

Context & interpretation

From the fixest walkthrough. Build a staggered panel, fit the Sun-Abraham interaction-weighted event study, and compare it to naive TWFE. Unofficial summary.

Peer notes

Discuss the workflow (2)

  • 2

    feols is stupid fast and sunab() makes the SA correction a one-liner. No reason to hand-roll event studies anymore.

  • 5

    Nice complement to the did package — same idea (don't trust naive TWFE under staggered timing), FE flavour.

    4

    Exactly. iplot() overlaying SA20 vs TWFE vs truth is the clearest illustration of the bias I've seen.

IN THE MARGINS

Peer discussion