Replication Materials

Difference-in-Differences
Designs: A Practitioner's
Guide

Data and code for the JEL article.

Andrew Baker, Brantly Callaway, Scott Cunningham,
Andrew Goodman-Bacon, and
Pedro H. C. Sant'Anna

Overview

Difference-in-differences (DiD) is arguably the most popular quasi-experimental research design. Its canonical form, with two groups and two periods, is well-understood. However, empirical practices can be ad hoc when researchers go beyond that simple case.

This replication package contains the data, R scripts, Stata do-files, generated figures, generated tables, and a self-contained interactive appendix for reproducing the empirical results in the article.

The main landing page is this URL: https://psantanna.com/JEL-DiD/. The interactive appendix remains available at markdown/R_Stata/Code_Appendix.html.

Replication

Users can reproduce the analysis in either R or Stata. Both workflows are organized around a master script that runs the complete analysis and writes outputs to the repository's figures/ and tables/ folders.

R

  1. Open DiD_JEL.Rproj in RStudio.
  2. Run scripts/R/00_master_did_jel.R.
  3. Check the generated files in figures/ and tables/.

Stata

  1. Open scripts/Stata/00_stata_master_did_jel.do.
  2. Set the rootdir path to this replication folder.
  3. Run the master do-file and compare the generated outputs.

Archive Structure

  • data/: public data sources and compiled analysis data.
  • scripts/R/: R code for data construction, analysis, figures, and tables.
  • scripts/Stata/: Stata do-files for the corresponding analysis workflow.
  • figures/: generated figure files from the R and Stata workflows.
  • tables/: generated table files from the R and Stata workflows.
  • markdown/R_Stata/: Quarto source and HTML for the interactive code appendix.

Data

The analysis uses public data from the CDC, Bureau of Labor Statistics, Kaiser Family Foundation, and the U.S. Census Bureau. The compiled county-level analysis data are provided in CSV format, with the replication scripts documenting the construction and analysis steps.

The official AEA/openICPSR data archive is available at openICPSR project 239070.