+ - 0:00:00
Notes for current slide
Notes for next slide

4.2 — Difference-in-Difference Models

ECON 480 • Econometrics • Fall 2021

Ryan Safner
Assistant Professor of Economics
safner@hood.edu
ryansafner/metricsF21
metricsF21.classes.ryansafner.com

Clever Research Designs Identify Causality

Again, this toolkit of research designs to identify causal effects is the economist’s comparative advantage that firms and governments want!

Difference-in-Difference Models

Natural Experiments

Difference-in-Difference Models I

  • Often, we want to examine the consequences of a change, such as a law or policy intervention

Difference-in-Difference Models I

  • Often, we want to examine the consequences of a change, such as a law or policy intervention

  • Example: how do States that implement policy X see changes in Y

    • Treatment: States that implement X
    • Control: States that did not implement X

Difference-in-Difference Models I

  • Often, we want to examine the consequences of a change, such as a law or policy intervention

  • Example: how do States that implement policy X see changes in Y

    • Treatment: States that implement X
    • Control: States that did not implement X
  • If we have panel data with observations for all states before and after the change...

  • Find the difference between treatment & control groups in their differences before and after the treatment period

Difference-in-Difference Models I

  • Often, we want to examine the consequences of a change, such as a law or policy intervention

  • Example: how do States that implement policy X see changes in Y

    • Treatment: States that implement X
    • Control: States that did not implement X
  • If we have panel data with observations for all states before and after the change...

  • Find the difference between treatment & control groups in their differences before and after the treatment period

Difference-in-Difference Models I

  • Often, we want to examine the consequences of a change, such as a law or policy intervention

  • Example: how do States that implement policy X see changes in Y

    • Treatment: States that implement X
    • Control: States that did not implement X
  • If we have panel data with observations for all states before and after the change...

  • Find the difference between treatment & control groups in their differences before and after the treatment period

Difference-in-Difference Models II

  • The difference-in-difference model (aka “diff-in-diff” or “DND”) identifies treatment effect by differencing the difference pre- and post-treatment values of Y between treatment and control groups

Difference-in-Difference Models II

  • The difference-in-difference model (aka “diff-in-diff” or “DND”) identifies treatment effect by differencing the difference pre- and post-treatment values of Y between treatment and control groups

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

Difference-in-Difference Models II

  • The difference-in-difference model (aka “diff-in-diff” or “DND”) identifies treatment effect by differencing the difference pre- and post-treatment values of Y between treatment and control groups

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • Treatedi={1 if i is in treatment group0 if i is not in treatment groupAftert={1 if t is after treatment period0 if t is before treatment period

Difference-in-Difference Models II

  • The difference-in-difference model (aka “diff-in-diff” or “DND”) identifies treatment effect by differencing the difference pre- and post-treatment values of Y between treatment and control groups

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • Treatedi={1 if i is in treatment group0 if i is not in treatment groupAftert={1 if t is after treatment period0 if t is before treatment period
Control Treatment Group Diff (ΔYi)
Before β0 β0+β1 β1
After β0+β2 β0+β1+β2+β3 β1+β3
Time Diff (ΔYt) β2 β2+β3 Diff-in-diff ΔiΔt:β3

Silly Example: Hot Dogs

Is there a discount when you get cheese and chili?

ABCDEFGHIJ0123456789
price
<dbl>
cheese
<dbl>
chili
<dbl>
2.0000
2.3510
2.3501
2.7011

Silly Example: Hot Dogs

Is there a discount when you get cheese and chili?

ABCDEFGHIJ0123456789
price
<dbl>
cheese
<dbl>
chili
<dbl>
2.0000
2.3510
2.3501
2.7011
lm(price ~ cheese + chili + cheese*chili,
data = hotdogs) %>%
tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
(Intercept)2.00
cheese0.35
chili0.35
cheese:chili0.00

Silly Example: Hot Dogs

Is there a discount when you get cheese and chili?

No Cheese Cheese Cheese Diff
No Chili $2.00 $2.35 $0.35
Chili $2.35 $2.70 $0.35
Chili Diff $0.35 $0.35 $0.00 (Diff-in-diff)
lm(price ~ cheese + chili + cheese*chili,
data = hotdogs) %>%
tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
(Intercept)2.00
cheese0.35
chili0.35
cheese:chili0.00

Silly Example: Hot Dogs

Is there a discount when you get cheese and chili?

No Cheese Cheese Cheese Diff
No Chili $2.00 $2.35 $0.35
Chili $2.35 $2.70 $0.35
Chili Diff $0.35 $0.35 $0.00 (Diff-in-diff)
lm(price ~ cheese + chili + cheese*chili,
data = hotdogs) %>%
tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
(Intercept)2.00
cheese0.35
chili0.35
cheese:chili0.00
  • Diff-n-diff is just a model with an interaction term between two dummies!

Visualizing Diff-in-Diff

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • Control group (Treated_i=0)

  • ^β0: value of Y for control group before treatment

  • ^β2: time difference (for control group)

Visualizing Diff-in-Diff

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • Control group (Treated_i=0)
  • ^β0: value of Y for control group before treatment

  • ^β2: time difference (for control group)

  • Treatment group (Treatedi=1)

Visualizing Diff-in-Diff

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • Control group (Treated_i=0)
  • ^β0: value of Y for control group before treatment

  • ^β2: time difference (for control group)

  • Treatment group (Treatedi=1)

  • ^β1: difference between groups before treatment

Visualizing Diff-in-Diff

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • Control group (Treated_i=0)
  • ^β0: value of Y for control group before treatment

  • ^β2: time difference (for control group)

  • Treatment group (Treatedi=1)

  • ^β1: difference between groups before treatment

  • ^β3: difference-in-difference (treatment effect)

Visualizing Diff-in-Diff II

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • ¯Yi for Control group before: ^β0

Visualizing Diff-in-Diff II

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • ¯Yi for Control group before: ^β0

  • ¯Yi for Control group after: ^β0+^β2

Visualizing Diff-in-Diff II

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • ¯Yi for Control group before: ^β0

  • ¯Yi for Control group after: ^β0+^β2

  • ¯Yi for Treatment group before: ^β0+^β1

Visualizing Diff-in-Diff II

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • ¯Yi for Control group before: ^β0

  • ¯Yi for Control group after: ^β0+^β2

  • ¯Yi for Treatment group before: ^β0+^β1

  • ¯Yi for Treatment group after: ^β0+^β1+^β2+^β3

Visualizing Diff-in-Diff II

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • ¯Yi for Control group before: ^β0

  • ¯Yi for Control group after: ^β0+^β2

  • ¯Yi for Treatment group before: ^β0+^β1

  • ¯Yi for Treatment group after: ^β0+^β1+^β2+^β3

  • Group Difference (before): ^β1

Visualizing Diff-in-Diff II

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • ¯Yi for Control group before: ^β0

  • ¯Yi for Control group after: ^β0+^β2

  • ¯Yi for Treatment group before: ^β0+^β1

  • ¯Yi for Treatment group after: ^β0+^β1+^β2+^β3

  • Group Difference (before): ^β1

  • Time Difference: ^β2

Visualizing Diff-in-Diff II

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • ¯Yi for Control group before: ^β0

  • ¯Yi for Control group after: ^β0+^β2

  • ¯Yi for Treatment group before: ^β0+^β1

  • ¯Yi for Treatment group after: ^β0+^β1+^β2+^β3

  • Group Difference (before): ^β1

  • Time Difference: ^β2

  • Difference-in-difference: ^β3 (treatment effect)

Comparing Group Means (Again)

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

Control Treatment Group Diff (ΔYi)
Before β0 β0+β1 β1
After β0+β2 β0+β1+β2+β3 β1+β3
Time Diff (ΔYt) β2 β2+β3 Diff-in-diff ΔiΔt:β3

Key Assumption: Counterfactual

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • Key assumption for DND: time trends (for treatment and control) are parallel

  • Treatment and control groups assumed to be identical over time on average, except for treatment

  • Counterfactual: if the treatment group had not recieved treatment, it would have changed identically over time as the control group (^β2)

Key Assumption: Counterfactual

^Yit=β0+β1Treatedi+β2Aftert+β3(Treatedi×Aftert)+uit

  • If the time-trends would have been different, a biased measure of the treatment effect (^β3)!

Example I: HOPE in Georgia

Diff-in-Diff Example I

Example: In 1993 Georgia initiated a HOPE scholarship program to let state residents with at least a B average in high school attend public college in Georgia for free. Did it increase college enrollment?

  • Micro-level data on 4,291 young individuals

Diff-in-Diff Example I

Example: In 1993 Georgia initiated a HOPE scholarship program to let state residents with at least a B average in high school attend public college in Georgia for free. Did it increase college enrollment?

  • Micro-level data on 4,291 young individuals
  • InCollegeit={1 if i is in college during year t0 if i is not in college during year t

Diff-in-Diff Example I

Example: In 1993 Georgia initiated a HOPE scholarship program to let state residents with at least a B average in high school attend public college in Georgia for free. Did it increase college enrollment?

  • Micro-level data on 4,291 young individuals
  • InCollegeit={1 if i is in college during year t0 if i is not in college during year t
  • Georgiai={1 if i is a Georgia resident0 if i is not a Georgia resident

Diff-in-Diff Example I

Example: In 1993 Georgia initiated a HOPE scholarship program to let state residents with at least a B average in high school attend public college in Georgia for free. Did it increase college enrollment?

  • Micro-level data on 4,291 young individuals
  • InCollegeit={1 if i is in college during year t0 if i is not in college during year t
  • Georgiai={1 if i is a Georgia resident0 if i is not a Georgia resident
  • Aftert={1 if t is after 19920 if t is after 1992

Dynarski, Susan, 1999, “Hope for Whom? Financial Aid for the Middle Class and its Impact on College Attendance,” National Tax Journal 53(3): 629-661

Note: With a dummy dependent (Y) variable, coefficients estimate the probability Y=1, i.e. the probability a person is enrolled in college

Diff-in-Diff Example II

  • We can use a DND model to measure the effect of HOPE scholarship on enrollments

  • Georgia and nearby States, if not for HOPE, changes should be the same over time

Diff-in-Diff Example II

  • We can use a DND model to measure the effect of HOPE scholarship on enrollments

  • Georgia and nearby States, if not for HOPE, changes should be the same over time

  • Treatment period: after 1992

Diff-in-Diff Example II

  • We can use a DND model to measure the effect of HOPE scholarship on enrollments

  • Georgia and nearby States, if not for HOPE, changes should be the same over time

  • Treatment period: after 1992

  • Treatment: Georgia

Diff-in-Diff Example II

  • We can use a DND model to measure the effect of HOPE scholarship on enrollments

  • Georgia and nearby States, if not for HOPE, changes should be the same over time

  • Treatment period: after 1992

  • Treatment: Georgia

  • Differences-in-differences: ΔiΔtEnrolled=(GAafterGAbefore)(neighborsafterneighborsbefore)

Diff-in-Diff Example II

  • We can use a DND model to measure the effect of HOPE scholarship on enrollments

  • Georgia and nearby States, if not for HOPE, changes should be the same over time

  • Treatment period: after 1992

  • Treatment: Georgia

  • Differences-in-differences: ΔiΔtEnrolled=(GAafterGAbefore)(neighborsafterneighborsbefore)

  • Regression equation: ^Enrolledit=β0+β1Georgiai+β2Aftert+β3(Georgiai×Aftert)

Example: Data

ABCDEFGHIJ0123456789
StateCode
<fct>
Age
<dbl>
Year
<fct>
Weight
<dbl>
Age18
<dbl>
LowIncome
<dbl>
InCollege
<dbl>
After
<dbl>
Georgia
<dbl>
561989139601100
56198910800NA100
56188992411100
56198989100100
56198913950NA000
561889110611100
5619899650NA000
5618899581NA000
56198910060NA000
561989118301100

Example: Data

Dynarski, Susan, 1999, “Hope for Whom? Financial Aid for the Middle Class and its Impact on College Attendance,” National Tax Journal 53(3): 629-661

Example: Regression

DND_reg <- lm(InCollege ~ Georgia + After + Georgia*After, data = hope)
DND_reg %>% tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
std.error
<dbl>
statistic
<dbl>
p.value
<dbl>
(Intercept)0.4057826520.0109239037.14631824.221545e-262
Georgia-0.1052362040.03778114-2.78541655.369384e-03
After-0.0044596090.01585224-0.28132357.784758e-01
Georgia:After0.0893298280.048893291.82703646.776378e-02

Example: Regression

DND_reg <- lm(InCollege ~ Georgia + After + Georgia*After, data = hope)
DND_reg %>% tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
std.error
<dbl>
statistic
<dbl>
p.value
<dbl>
(Intercept)0.4057826520.0109239037.14631824.221545e-262
Georgia-0.1052362040.03778114-2.78541655.369384e-03
After-0.0044596090.01585224-0.28132357.784758e-01
Georgia:After0.0893298280.048893291.82703646.776378e-02

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

Example: Interpretting the Regression

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

Example: Interpretting the Regression

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • β0:

Example: Interpretting the Regression

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • β0: A non-Georgian before 1992 was 40.6% likely to be a college student

Example: Interpretting the Regression

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • β0: A non-Georgian before 1992 was 40.6% likely to be a college student

  • β1:

Example: Interpretting the Regression

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • β0: A non-Georgian before 1992 was 40.6% likely to be a college student

  • β1: Georgians before 1992 were 10.5% less likely to be college students than neighboring states

Example: Interpretting the Regression

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • β0: A non-Georgian before 1992 was 40.6% likely to be a college student

  • β1: Georgians before 1992 were 10.5% less likely to be college students than neighboring states

  • β2:

Example: Interpretting the Regression

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • β0: A non-Georgian before 1992 was 40.6% likely to be a college student

  • β1: Georgians before 1992 were 10.5% less likely to be college students than neighboring states

  • β2: After 1992, non-Georgians are 0.4% less likely to be college students

Example: Interpretting the Regression

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • β0: A non-Georgian before 1992 was 40.6% likely to be a college student

  • β1: Georgians before 1992 were 10.5% less likely to be college students than neighboring states

  • β2: After 1992, non-Georgians are 0.4% less likely to be college students

  • β3:

Example: Interpretting the Regression

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • β0: A non-Georgian before 1992 was 40.6% likely to be a college student

  • β1: Georgians before 1992 were 10.5% less likely to be college students than neighboring states

  • β2: After 1992, non-Georgians are 0.4% less likely to be college students

  • β3: After 1992, Georgians are 8.9% more likely to enroll in colleges than neighboring states

Example: Interpretting the Regression

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • β0: A non-Georgian before 1992 was 40.6% likely to be a college student

  • β1: Georgians before 1992 were 10.5% less likely to be college students than neighboring states

  • β2: After 1992, non-Georgians are 0.4% less likely to be college students

  • β3: After 1992, Georgians are 8.9% more likely to enroll in colleges than neighboring states

  • Treatment effect: HOPE increased enrollment likelihood by 8.9%

Example: Comparing Group Means

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • A group mean for a dummy Y is E[Y=1], i.e. the probability a student is enrolled:

  • Non-Georgian enrollment probability pre-1992:

Example: Comparing Group Means

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • A group mean for a dummy Y is E[Y=1], i.e. the probability a student is enrolled:

  • Non-Georgian enrollment probability pre-1992: β0=0.406

Example: Comparing Group Means

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • A group mean for a dummy Y is E[Y=1], i.e. the probability a student is enrolled:

  • Non-Georgian enrollment probability pre-1992: β0=0.406

  • Georgian enrollment probability pre-1992:

Example: Comparing Group Means

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • A group mean for a dummy Y is E[Y=1], i.e. the probability a student is enrolled:

  • Non-Georgian enrollment probability pre-1992: β0=0.406

  • Georgian enrollment probability pre-1992: β0+β1=0.4060.105=0.301

Example: Comparing Group Means

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • A group mean for a dummy Y is E[Y=1], i.e. the probability a student is enrolled:

  • Non-Georgian enrollment probability pre-1992: β0=0.406

  • Georgian enrollment probability pre-1992: β0+β1=0.4060.105=0.301

  • Non-Georgian enrollment probability post-1992:

Example: Comparing Group Means

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • A group mean for a dummy Y is E[Y=1], i.e. the probability a student is enrolled:

  • Non-Georgian enrollment probability pre-1992: β0=0.406

  • Georgian enrollment probability pre-1992: β0+β1=0.4060.105=0.301

  • Non-Georgian enrollment probability post-1992: β0+β2=0.4060.004=0.402

Example: Comparing Group Means

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • A group mean for a dummy Y is E[Y=1], i.e. the probability a student is enrolled:

  • Non-Georgian enrollment probability pre-1992: β0=0.406

  • Georgian enrollment probability pre-1992: β0+β1=0.4060.105=0.301

  • Non-Georgian enrollment probability post-1992: β0+β2=0.4060.004=0.402

  • Georgian enrollment probability post-1992:

Example: Comparing Group Means

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

  • A group mean for a dummy Y is E[Y=1], i.e. the probability a student is enrolled:

  • Non-Georgian enrollment probability pre-1992: β0=0.406

  • Georgian enrollment probability pre-1992: β0+β1=0.4060.105=0.301

  • Non-Georgian enrollment probability post-1992: β0+β2=0.4060.004=0.402

  • Georgian enrollment probability post-1992: β0+β1+β2+β3=0.4060.1050.004+0.089=0.386

Example: Comparing Group Means in R

# group mean for non-Georgian before 1992
hope %>%
filter(Georgia == 0,
After == 0) %>%
summarize(prob = mean(InCollege))
ABCDEFGHIJ0123456789
prob
<dbl>
0.4057827

Example: Comparing Group Means in R

# group mean for non-Georgian before 1992
hope %>%
filter(Georgia == 0,
After == 0) %>%
summarize(prob = mean(InCollege))
ABCDEFGHIJ0123456789
prob
<dbl>
0.4057827
# group mean for non-Georgian AFTER 1992
hope %>%
filter(Georgia == 0,
After == 1) %>%
summarize(prob = mean(InCollege))
ABCDEFGHIJ0123456789
prob
<dbl>
0.401323

Example: Comparing Group Means in R II

# group mean for Georgian before 1992
hope %>%
filter(Georgia == 1,
After == 0) %>%
summarize(prob = mean(InCollege))
ABCDEFGHIJ0123456789
prob
<dbl>
0.3005464

Example: Comparing Group Means in R II

# group mean for Georgian before 1992
hope %>%
filter(Georgia == 1,
After == 0) %>%
summarize(prob = mean(InCollege))
ABCDEFGHIJ0123456789
prob
<dbl>
0.3005464
# group mean for Georgian AFTER 1992
hope %>%
filter(Georgia == 1,
After == 1) %>%
summarize(prob = mean(InCollege))
ABCDEFGHIJ0123456789
prob
<dbl>
0.3854167

Example: Diff-in-Diff Summary

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

Neighbors Georgia Group Diff (ΔYi)
Before 0.406 0.301 0.105
After 0.402 0.386 0.016
Time Diff (ΔYt) 0.004 0.085 Diff-in-diff: 0.089

Example: Diff-in-Diff Summary

^Enrolledit=0.4060.105Georgiai0.004Aftert+0.089(Georgiai×Aftert)

Neighbors Georgia Group Diff (ΔYi)
Before 0.406 0.301 0.105
After 0.402 0.386 0.016
Time Diff (ΔYt) 0.004 0.085 Diff-in-diff: 0.089

ΔiΔtEnrolled=(GAafterGAbefore)(neighborsafterneighborsbefore)=(0.3860.301)(0.4020.406)=(0.085)(0.004)=0.089

Diff-in-Diff Summary & Data

Dynarski, Susan, 1999, “Hope for Whom? Financial Aid for the Middle Class and its Impact on College Attendance,” National Tax Journal 53(3): 629-661

Example: Diff-in-Diff Graph

Example: Diff-in-Diff Graph (& Counterfactual)

Generalizing DND Models

Generalizing DND Models

  • DND can be generalized with a two-way fixed effects model:
    ^Yit=β1(Treatedi×Aftert)+αi+θt++νit
    • αi: group fixed effects (treatments/control groups)
    • θt: time fixed effects (pre/post treatment)
    • β1: diff-in-diff (interaction effect, β3 from before)

Generalizing DND Models

  • DND can be generalized with a two-way fixed effects model:
    ^Yit=β1(Treatedi×Aftert)+αi+θt++νit
    • αi: group fixed effects (treatments/control groups)
    • θt: time fixed effects (pre/post treatment)
    • β1: diff-in-diff (interaction effect, β3 from before)
  • Flexibility: many periods (not just before/after), many different treatment(s)/groups, and treatment(s) can occur at different times to different units (so long as some do not get treated)

Generalizing DND Models

  • DND can be generalized with a two-way fixed effects model:
    ^Yit=β1(Treatedi×Aftert)+αi+θt++νit
    • αi: group fixed effects (treatments/control groups)
    • θt: time fixed effects (pre/post treatment)
    • β1: diff-in-diff (interaction effect, β3 from before)
  • Flexibility: many periods (not just before/after), many different treatment(s)/groups, and treatment(s) can occur at different times to different units (so long as some do not get treated)

  • Can also add control variables that vary within units and over time ^Yit=β1(Treatedi×Aftert)+β2Xit++αi+θt+νit

Our Example, Generalized I

^Enrolledit=β1(Georgiai×Aftert)+αi+θt+

  • StateCode is a variable for the State create State fixed effect

  • Year is a variable for the year create year fixed effect

Our Example, Generalized II

  • Using LSDV method...
DND_fe <- lm(InCollege ~ Georgia*After + factor(StateCode) + factor(Year),
data = hope)
DND_fe %>% tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
std.error
<dbl>
(Intercept)0.4180574780.02261133
Georgia-0.1415012550.03936119
After0.0753405940.03128021
factor(StateCode)57-0.0141811120.02739708
factor(StateCode)58NANA
factor(StateCode)59-0.0623785400.01954266
factor(StateCode)62-0.1326502710.02806143
factor(StateCode)63-0.0051038680.02627780
factor(Year)900.0466088450.02833625
factor(Year)910.0322757890.02856877

Our Example, Generalized II

  • Using LSDV method...
DND_fe <- lm(InCollege ~ Georgia*After + factor(StateCode) + factor(Year),
data = hope)
DND_fe %>% tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
std.error
<dbl>
(Intercept)0.4180574780.02261133
Georgia-0.1415012550.03936119
After0.0753405940.03128021
factor(StateCode)57-0.0141811120.02739708
factor(StateCode)58NANA
factor(StateCode)59-0.0623785400.01954266
factor(StateCode)62-0.1326502710.02806143
factor(StateCode)63-0.0051038680.02627780
factor(Year)900.0466088450.02833625
factor(Year)910.0322757890.02856877
  • By de-meaning data, using fixest
library(fixest)
DND_fe_2 <- feols(InCollege ~ Georgia*After | factor(StateCode) + factor(Year),
data = hope)
DND_fe_2 %>% tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
std.error
<dbl>
statistic
<dbl>
Georgia:After0.09142020.00564329816.19978

Our Example, Generalized II

  • Using LSDV method...
DND_fe <- lm(InCollege ~ Georgia*After + factor(StateCode) + factor(Year),
data = hope)
DND_fe %>% tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
std.error
<dbl>
(Intercept)0.4180574780.02261133
Georgia-0.1415012550.03936119
After0.0753405940.03128021
factor(StateCode)57-0.0141811120.02739708
factor(StateCode)58NANA
factor(StateCode)59-0.0623785400.01954266
factor(StateCode)62-0.1326502710.02806143
factor(StateCode)63-0.0051038680.02627780
factor(Year)900.0466088450.02833625
factor(Year)910.0322757890.02856877
  • By de-meaning data, using fixest
library(fixest)
DND_fe_2 <- feols(InCollege ~ Georgia*After | factor(StateCode) + factor(Year),
data = hope)
DND_fe_2 %>% tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
std.error
<dbl>
statistic
<dbl>
Georgia:After0.09142020.00564329816.19978

^InCollegeit=0.091(Georgiai×Afterit)+αi+θt

Our Example, Generalized, with Controls II

  • Using LSDV method...
DND_fe_controls <- lm(InCollege ~ Georgia*After + factor(StateCode) + factor(Year) + Black + LowIncome,
data = hope)
DND_fe_controls %>% tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
std.error
<dbl>
(Intercept)0.7355742220.02990710
Georgia-0.1089402760.04765262
After-0.0057535530.03737027
factor(StateCode)57-0.0434060730.03047696
factor(StateCode)58NANA
factor(StateCode)59-0.0531756450.02306160
factor(StateCode)62-0.1161046150.03283310
factor(StateCode)630.0073898660.03056444
factor(Year)900.0393643150.03326291
factor(Year)910.0292279690.03347850

Our Example, Generalized, with Controls II

  • Using LSDV method...
DND_fe_controls <- lm(InCollege ~ Georgia*After + factor(StateCode) + factor(Year) + Black + LowIncome,
data = hope)
DND_fe_controls %>% tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
std.error
<dbl>
(Intercept)0.7355742220.02990710
Georgia-0.1089402760.04765262
After-0.0057535530.03737027
factor(StateCode)57-0.0434060730.03047696
factor(StateCode)58NANA
factor(StateCode)59-0.0531756450.02306160
factor(StateCode)62-0.1161046150.03283310
factor(StateCode)630.0073898660.03056444
factor(Year)900.0393643150.03326291
factor(Year)910.0292279690.03347850
  • By de-meaning data, using fixest
library(fixest)
DND_fe_controls_2 <- feols(InCollege ~ Georgia*After + Black + LowIncome | factor(StateCode) + factor(Year),
data = hope)
DND_fe_controls_2 %>% tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
std.error
<dbl>
statistic
<dbl>
Black-0.093987150.01273233-7.381769
LowIncome-0.301724260.03066188-9.840369
Georgia:After0.023436790.012818381.828374

Our Example, Generalized, with Controls II

  • Using LSDV method...
DND_fe_controls <- lm(InCollege ~ Georgia*After + factor(StateCode) + factor(Year) + Black + LowIncome,
data = hope)
DND_fe_controls %>% tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
std.error
<dbl>
(Intercept)0.7355742220.02990710
Georgia-0.1089402760.04765262
After-0.0057535530.03737027
factor(StateCode)57-0.0434060730.03047696
factor(StateCode)58NANA
factor(StateCode)59-0.0531756450.02306160
factor(StateCode)62-0.1161046150.03283310
factor(StateCode)630.0073898660.03056444
factor(Year)900.0393643150.03326291
factor(Year)910.0292279690.03347850
  • By de-meaning data, using fixest
library(fixest)
DND_fe_controls_2 <- feols(InCollege ~ Georgia*After + Black + LowIncome | factor(StateCode) + factor(Year),
data = hope)
DND_fe_controls_2 %>% tidy()
ABCDEFGHIJ0123456789
term
<chr>
estimate
<dbl>
std.error
<dbl>
statistic
<dbl>
Black-0.093987150.01273233-7.381769
LowIncome-0.301724260.03066188-9.840369
Georgia:After0.023436790.012818381.828374

^InCollegeit=0.023(Georgiai×Afterit)0.094Blackit0.302LowIncomeit

Our Example, Generalized, with Controls II

(1)(2)(3)
Intercept0.4058 ***                  
(0.0109)                     
Georgia-0.1052 **                   
(0.0378)                     
After-0.0045                      
(0.0159)                     
Georgia x After0.0893    0.0914 ***0.0234    
(0.0489)   (0.0056)   (0.0128)   
Low Income                  -0.3017 ***
                  (0.0307)   
Black                  -0.0940 ***
                  (0.0127)   
Fixed EffectsNone         State & Year         State & Year         
N4291         4291         2967         
R-Squared0.0019    0.0115    0.1036    
SER0.4893    0.4875    0.4731    
*** p < 0.001; ** p < 0.01; * p < 0.05.

Our Example, Generalized, with Controls II

Dynarski, Susan, 1999, “Hope for Whom? Financial Aid for the Middle Class and its Impact on College Attendance,” National Tax Journal 53(3): 629-661

Intuition behind DND

  • Diff-in-diff models are the quintessential example of exploiting natural experiments

  • A major change at a point in time (change in law, a natural disaster, political crisis) separates groups where one is affected and another is not---identifies the effect of the change (treatment)

  • One of the cleanest and clearest causal identification strategies

Example II: “The” Card-Kreuger Minimum Wage Study

Example: ”The” Card-Kreuger Minimum Wage Study I

Example: The controversial minimum wage study, Card & Kreuger (1994) is a quintessential (and clever) diff-in-diff.

Card, David, Krueger, Alan B, (1994), "Minimum Wages and Employment: A Case Study of the Fast-Food Industry in New Jersey and Pennsylvania," American Economic Review 84 (4): 772–793

Card & Kreuger (1994): Background I

  • Card & Kreuger (1994) compare employment in fast food restaurants on New Jersey and Pennsylvania sides of border between February and November 1992.

  • Pennsylvania & New Jersey both had a minimum wage of $4.25 before February 1992

  • In February 1992, New Jersey raised minimum wage from $4.25 to $5.05

Card & Kreuger (1994): Background II

  • If we look only at New Jersey before & after change:

    • Omitted variable bias: macroeconomic variables (there's a recession!), weather, etc.
    • Including PA as a control will control for these time-varying effects if they are national trends
  • Surveyed 400 fast food restaurants on each side of the border, before & after min wage increase

    • Key assumption: Pennsylvania and New Jersey follow parallel trends,
    • Counterfactual: if not for the minimum wage increase, NJ employment would have changed similar to PA employment

Card & Kreuger (1994): Comparisons

Card & Kreuger (1994): Summary I

Card & Kreuger (1994): Summary II

Card & Kreuger (1994): Model

^Employmentit=β0+β1NJi+β2Aftert+β3(NJi×Aftert)

  • PA Before: β0

  • PA After: β0+β2

  • NJ Before: β0+β1

  • NJ After: β0+β1+β2+β3

  • Diff-in-diff: (NJafterNJbefore)(PAafterPAbefore)

Card & Kreuger (1994): Model

^Employmentit=β0+β1NJi+β2Aftert+β3(NJi×Aftert)

  • PA Before: β0

  • PA After: β0+β2

  • NJ Before: β0+β1

  • NJ After: β0+β1+β2+β3

  • Diff-in-diff: (NJafterNJbefore)(PAafterPAbefore)

PA NJ Group Diff (ΔYi)
Before β0 β0+β1 β1
After β0+β2 β0+β1+β2+β3 β1+β3
Time Diff (ΔYt) β2 β2+β3 Diff-in-diff ΔiΔt:β3

Card & Kreuger (1994): Results

Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
oTile View: Overview of Slides
Esc Back to slideshow