LibraryDifference-in-Differences

Difference-in-Differences

Learn about Difference-in-Differences as part of Behavioral Economics and Experimental Design

Difference-in-Differences (DiD) for Behavioral Research

Difference-in-Differences (DiD) is a powerful quasi-experimental method widely used in economics and other social sciences to estimate the causal effect of a specific intervention or treatment. It's particularly valuable in behavioral research when randomized controlled trials (RCTs) are not feasible or ethical, allowing us to approximate experimental conditions using observational data.

The Core Idea of DiD

DiD compares the change in outcomes over time between a group that received a treatment and a group that did not.

Imagine you want to study the impact of a new public health campaign on people's smoking habits. You can't randomly assign people to see the campaign. Instead, you identify a region where the campaign was implemented (treatment group) and a similar region where it wasn't (control group). You then measure smoking rates in both regions before the campaign and after the campaign.

The fundamental principle of DiD is to isolate the effect of the treatment by accounting for both time trends that affect everyone and pre-existing differences between groups. It achieves this by calculating the difference in the outcome variable for the treatment group before and after the intervention, and then subtracting the difference in the outcome variable for the control group over the same period. This 'difference of differences' aims to capture the causal impact of the treatment.

How DiD Works: The Calculation

Let's denote:

  • code
    Y_it
    as the outcome for individual
    code
    i
    at time
    code
    t
    .
  • code
    T_i
    as an indicator variable, where
    code
    T_i = 1
    if individual
    code
    i
    is in the treatment group, and
    code
    T_i = 0
    if in the control group.
  • code
    D_t
    as an indicator variable, where
    code
    D_t = 1
    if time
    code
    t
    is after the intervention, and
    code
    D_t = 0
    if before.

The standard DiD estimator can be represented by the coefficient on the interaction term

code
T_i * D_t
in a regression model:

code
Y_it = β_0 + β_1 T_i + β_2 D_t + β_3 (T_i * D_t) + ε_it

Here,

code
β_3
is the DiD estimator, representing the average causal effect of the treatment.

What does the coefficient β3 in the DiD regression model represent?

The average causal effect of the treatment.

The validity of the DiD estimator hinges on a critical assumption: the parallel trends assumption. This means that, in the absence of the treatment, the average outcome in the treatment group would have followed the same trend over time as the average outcome in the control group.

Visualizing the Parallel Trends Assumption: Imagine two lines on a graph, one for the treatment group's outcome and one for the control group's outcome, plotted over time. Before the intervention (time period 0), these lines might be at different levels, but their slopes (trends) should be parallel. If the intervention occurs at time 1, the DiD method assumes that if the intervention hadn't happened, the treatment group's line would have continued to move parallel to the control group's line. The observed divergence after the intervention is attributed to the treatment's effect. If the trends were not parallel before the intervention, the estimated 'difference of differences' would be biased.

📚

Text-based content

Library pages focus on text content

The parallel trends assumption is untestable directly because we can never observe what would have happened to the treatment group without the intervention. Therefore, it's crucial to select a control group that is as similar as possible to the treatment group and to examine pre-intervention trends visually or statistically.

Applications in Behavioral Economics

DiD is invaluable for studying behavioral interventions where randomization is difficult. Examples include:

  • Nudge Interventions: Evaluating the impact of changes in default options (e.g., opt-out vs. opt-in for retirement savings) on savings behavior.
  • Policy Changes: Assessing how a new tax on sugary drinks affects consumption patterns in a specific city compared to a similar city without the tax.
  • Information Campaigns: Measuring the effect of a financial literacy program rolled out in one community on financial decision-making compared to a control community.
  • Behavioral Pricing: Analyzing how a change in pricing structure (e.g., dynamic pricing) affects consumer purchasing decisions in one market versus another.

Strengthening DiD: Variations and Considerations

Several extensions and considerations can improve DiD analysis:

  • Multiple Time Periods: Using more than two time periods (before and after) allows for better testing of the parallel trends assumption.
  • Staggered Adoption: When different units receive the treatment at different times, more advanced DiD methods (e.g., two-way fixed effects, event study designs) are needed to avoid confounding effects.
  • Covariate Adjustment: Including control variables in the regression can increase precision and help address potential unobserved confounders, provided these covariates do not violate the parallel trends assumption themselves.
  • Heterogeneous Treatment Effects: DiD can be extended to explore how the treatment effect varies across different subgroups.
What is a key challenge in using DiD, and how can it be partially addressed?

The parallel trends assumption, which can be partially addressed by selecting similar control groups and examining pre-intervention trends.

Learning Resources

Difference-in-Differences: A Practical Guide(paper)

A comprehensive and accessible overview of the DiD method, its assumptions, and extensions, written by leading economists.

Econometric Analysis of Difference-in-Differences(video)

A clear video explanation of the DiD method, including its intuition, assumptions, and regression framework.

Difference-in-Differences Estimation(wikipedia)

Wikipedia provides a foundational understanding of the DiD method, its history, and basic applications.

Applied Econometrics: Difference-in-Differences(video)

This video delves into the practical application of DiD using statistical software, illustrating the regression setup.

Causal Inference: The Mixtape - Chapter 6: Difference-in-Differences(blog)

A chapter from a popular online book on causal inference, offering an intuitive and practical explanation of DiD.

Stata Blog: Difference-in-Differences(documentation)

A technical guide on how to implement DiD analysis using Stata, including commands and interpretation.

The Effect of Minimum Wage Increases on Employment: A Difference-in-Differences Analysis(paper)

A seminal paper by Card and Krueger that famously used DiD to study the impact of minimum wage hikes on fast-food employment.

Introduction to Difference-in-Differences(video)

A concise video explaining the core logic and assumptions of DiD, suitable for beginners.

R Package for Difference-in-Differences(documentation)

Documentation for the 'did' package in R, which provides tools for estimating DiD with staggered adoption and other advanced features.

Understanding Difference-in-Differences(video)

This video offers a clear, step-by-step walkthrough of the DiD concept and its application in research.