经济学 · 第 5 册 · 本科三年级

University Economics — Year 3

本书暂未推出简体中文版。现有版本:English。

University Economics — Year 3 · 本科三年级

3Difference-in-Differences

On 1 April 1992 New Jersey raised its minimum wage from $4.254.25 to $5.055.05 an hour. Its neighbour, Pennsylvania, did not. In February and again in November of that year, two economists telephoned 410 fast-food restaurants on both sides of the state line and asked how many people they employed. Employment per restaurant fell in Pennsylvania and rose slightly in New Jersey. Neither change on its own says anything about the minimum wage: the season, the regional economy and a hundred other things moved between February and November. But those things moved on both sides of the line. The change in Pennsylvania estimates what would have happened in New Jersey without the rise, and the difference between the two changes estimates the effect of the rise. This chapter is about that subtraction: when it works, how to look for the cases where it does not, and what to do when the policy reaches different places at different times, or only one place.

Mean full-time-equivalent employment per fast-food restaurant, February and November 1992 (part-time workers count as one half). Dashed: New Jersey’s February level moved by Pennsylvania’s change, the path New Jersey would have followed under parallel trends.
Mean full-time-equivalent employment per fast-food restaurant, February and November 1992 (part-time workers count as one half). Dashed: New Jersey’s February level moved by Pennsylvania’s change, the path New Jersey would have followed under parallel trends. Source: Card and Krueger (1994), Table 3; the dashed line is our arithmetic on the printed means

Read the chart from the right. In November, New Jersey’s restaurants employed 21.03 people on average. Had New Jersey followed Pennsylvania’s path, which fell by 2.16, it would have employed 20.44−2.16=18.2820.44 - 2.16 = 18.28. The difference, 2.75 workers per restaurant, is the estimate: more employment, not less, after the rise. (The paper prints 2.76, with a standard error of 1.36, computed from unrounded means.) The whole estimate rests on the dashed line, which nobody observed. The chapter’s tools are ways of making that line believable, or of showing that it is not. What the minimum wage does to employment is a question for the chapter on the labour market; here the study serves only as the cleanest picture of the design.

You already know

The Year 2 volume wrote causal questions with potential outcomes: Yi(1)Y_i(1) and Yi(0)Y_i(0) are unit ii’s outcome with and without treatment, only one of which is observed, and the average treatment effect on the treated (ATT) is E[Yi(1)−Yi(0)∣Di=1]\E[Y_i(1) - Y_i(0) \mid D_i = 1]. Chapter 2 introduced unit and period fixed effects and showed why standard errors must be clustered when errors and treatment both persist within a unit.

Notation 3.1 (Symbols of this chapter)

Di=1D_i = 1 marks the treated group and Di=0D_i = 0 the comparison group; t=0t = 0 is before the treatment and t=1t = 1 after. Yit(1)Y_{it}(1) and Yit(0)Y_{it}(0) are potential outcomes in period tt, and τ\tau is the ATT in period 1 (not a tax rate). Event time, the number of periods since a unit was first treated, is kk.

3.1 Two groups, two periods

Definition 3.2 (Difference-in-differences estimator)

With a treated group observed before and after a treatment and a comparison group observed at the same dates, the difference-in-differences estimator is

τ^DiD=(Yˉ1,after−Yˉ1,before)−(Yˉ0,after−Yˉ0,before),\hat\tau_{\mathrm{DiD}} = \bigl(\bar Y_{1,\mathrm{after}} - \bar Y_{1,\mathrm{before}}\bigr) - \bigl(\bar Y_{0,\mathrm{after}} - \bar Y_{0,\mathrm{before}}\bigr),

where Yˉg,s\bar Y_{g,s} is the mean outcome of group gg in period ss.

The assumption allows the two groups to differ in level — Pennsylvania’s restaurants were larger than New Jersey’s in February — but not in the change they would have had. It is weaker than random assignment, and it is untestable for the period that matters, which lies after the treatment.

Proposition 3.4 (Difference-in-differences identifies the ATT)

Suppose the treated group is untreated in period 0 and treated in period 1, the comparison group is untreated in both, and parallel trends hold. Then the population difference in differences equals τ=E[Yi1(1)−Yi1(0)∣Di=1]\tau = \E[Y_{i1}(1) - Y_{i1}(0) \mid D_i = 1].

Proof. Observed outcomes are Yi1(1)Y_{i1}(1) for the treated in period 1 and Yit(0)Y_{it}(0) in every other cell. The population difference in differences is therefore

E[Yi1(1)−Yi0(0)∣Di=1]−E[Yi1(0)−Yi0(0)∣Di=0].\E[Y_{i1}(1) - Y_{i0}(0) \mid D_i = 1] - \E[Y_{i1}(0) - Y_{i0}(0) \mid D_i = 0].

Add and subtract E[Yi1(0)∣Di=1]\E[Y_{i1}(0) \mid D_i = 1] in the first term: it becomes τ+E[Yi1(0)−Yi0(0)∣Di=1]\tau + \E[Y_{i1}(0) - Y_{i0}(0) \mid D_i = 1]. By parallel trends the second part equals the comparison group’s change, which cancels. ∎

The proof shows what the estimator delivers when the assumption fails: τ\tau plus the difference between the two groups’ untreated trends. Every threat to a difference-in-differences design is a reason why that difference might not be zero.

Listing 3.1 applies the estimator to a job-training programme of the 1970s, the National Supported Work demonstration, whose trainees are compared with a large sample of the population survey. The programme ran in 1976–1977, so 1975 is before and 1978 after.

"""Difference-in-differences on the NSW job-training data: the trainees against
a survey sample, earnings in 1975 (before) and 1978 (after), in dollars."""
import numpy as np
import pandas as pd
import statsmodels.formula.api as smf
from econdata import nsw

trainees = nsw("nsw_dw").query("treat == 1")
survey = nsw("cps_controls").assign(treat=0)
d = pd.concat([trainees, survey], ignore_index=True)
d["person"] = np.arange(len(d))

means = d.groupby("treat")[["re75", "re78"]].mean()
print("                       1975      1978")
for g, label in ((1, "trainees"), (0, "survey")):
    print(f"{label:16s}{means.re75[g]:10.0f}{means.re78[g]:10.0f}")
change = means.re78 - means.re75
print(f"change, trainees   {change[1]:9.0f}")
print(f"change, survey     {change[0]:9.0f}")
print(f"DiD                {change[1] - change[0]:9.0f}")

# the same number by OLS: stack the two years, interact group and period
long = pd.concat([d.assign(after=0, earn=d.re75), d.assign(after=1, earn=d.re78)])
fit = smf.ols("earn ~ treat * after", long).fit(
    cov_type="cluster", cov_kwds={"groups": long.person})
print(f"OLS interaction    {fit.params['treat:after']:9.0f}"
      f"   (clustered s.e. {fit.bse['treat:after']:.0f})")
Listing 3.1. The difference in differences of mean earnings, then the same number as an OLS interaction. code/bachelor-3/03-difference-in-differences/listings/did_nsw.py
$ python did_nsw.py
                       1975      1978
trainees              1532      6349
survey               13651     14847
change, trainees        4817
change, survey          1196
DiD                     3621
OLS interaction         3621   (clustered s.e. 610)
Output 3.1. Mean earnings in dollars of the year.

The trainees’ earnings rose by $48174817, the survey’s by $11961196, and the estimate is $36213621. The survey sample earned nine times as much as the trainees in 1975; parallel trends allow that, but it already suggests the two groups were on different paths. The survey’s earnings are also top-coded: incomes above a ceiling (about $25 00025\,000 in these years) are recorded at the ceiling, which holds down the survey’s measured rise and so inflates the estimate.

twice the experimental answer; Listing 3.2 repeats the comparison with the second survey, whose earnings are not top-coded.

3.2 Parallel trends, and how to look at them

Two kinds of evidence bear on the assumption. The first is the period before the treatment: if the two groups moved in parallel for several years before, it is more plausible that they would have done so after. The second is a comparison where the answer is known to be zero.

Definition 3.5 (Placebo test)

A placebo test applies an estimator to a period, a group or an outcome that the treatment cannot have affected; an estimate far from zero reveals a failure of the design’s assumptions.

The NSW data allow a direct test of the estimator, because the programme was a randomised experiment: applicants were assigned by lottery to the programme or to a control group, and the difference in 1978 earnings between the two estimates the effect without any assumption about trends.

On the record — LaLonde’s test of non-experimental estimators

LaLonde (1986) discarded the experiment’s control group and replaced it with samples from two large surveys, as an evaluator without an experiment would. He then asked whether the estimators of the day — regression with controls, differences in differences, selection models — recovered the experimental answer. Most did not, and the estimates varied widely with the comparison sample and the specification. Dehejia and Wahba (1999) showed that on a subset of his sample, with two years of earlier earnings, careful matching came close to the benchmark; Smith and Todd (2005) showed that this success depended on the subset. The lesson has held: an estimator that works in one data set can fail in the next, and the experimental benchmark is the only way to know.

"""LaLonde's test: the experiment's answer against non-experimental estimators
that replace the randomised controls with a survey sample (earnings in 1978, $)."""
import pandas as pd
import statsmodels.formula.api as smf
from econdata import nsw

exp = nsw("nsw_dw")
trainees = exp.query("treat == 1")
bench = smf.ols("re78 ~ treat", exp).fit(cov_type="HC1")
print(f"experiment                  {bench.params.treat:7.0f} ({bench.bse.treat:.0f})")

X = "age + I(age**2) + education + black + hispanic + married + nodegree"
for name in ("cps_controls", "psid_controls"):
    d = pd.concat([trainees, nsw(name).assign(treat=0)], ignore_index=True)
    d["gain"] = d.re78 - d.re75
    est = {
        "difference in means": smf.ols("re78 ~ treat", d),
        "regression, controls": smf.ols(f"re78 ~ treat + {X} + re74 + re75", d),
        "DiD": smf.ols("gain ~ treat", d),
        "DiD, controls": smf.ols(f"gain ~ treat + {X}", d),
    }
    print(name)
    for label, model in est.items():
        f = model.fit(cov_type="HC1")
        print(f"  {label:26s}{f.params.treat:7.0f} ({f.bse.treat:.0f})")
Listing 3.2. The experimental benchmark against four estimators, with each survey as the comparison group. code/bachelor-3/03-difference-in-differences/listings/lalonde_benchmark.py
$ python lalonde_benchmark.py
experiment                     1794 (671)
cps_controls
  difference in means         -8498 (582)
  regression, controls          794 (619)
  DiD                          3621 (610)
  DiD, controls                2264 (644)
psid_controls
  difference in means        -15205 (656)
  regression, controls          795 (780)
  DiD                          2327 (645)
  DiD, controls                2106 (771)
Output 3.2. Effects on 1978 earnings, dollars; robust standard errors in parentheses.

The experiment says $17941794. A raw comparison with either survey says the programme cost its trainees eight to fifteen thousand dollars: the survey samples were simply far richer. The difference in differences removes that level gap and lands on the right side of zero, but at twice the benchmark with the population survey. Adding controls moves it closer, to $22642264; regression with two years of earlier earnings lands below the benchmark, at $794794. No one could have chosen among these numbers without the experiment.

One reason is a pattern Ashenfelter (1978) found in training data: the earnings of people who enter a programme fall in the year or two before they enter, which is often why they enter. Measured from the bottom of that dip, their earnings would have recovered anyway, and the recovery is counted as the programme’s effect. The trainees’ earnings fell from 1974 to 1975, a little more than the surveys’ (Exercise 3.6). The test sees only part of the dip, because the programme selected people who were out of work when they applied.

Model — Difference-in-differences

Assumes. Without the treatment, the treated and comparison groups would have changed by the same amount (parallel trends); the treatment does not affect the comparison group; nothing else that changes the outcome happens to one group only at the same date; the composition of each group is stable.

Predicts. The treated group’s outcome departs from the comparison group’s path at the treatment date, not before; placebo dates, groups and outcomes show no effect.

Tested. Against experiments: in the NSW data, the estimate with a survey comparison group is twice the experimental one; with controls, closer. Its pre-period predictions are checked in every careful application by an event study.

Breaks. When units are selected for treatment because of a temporary shock (Ashenfelter’s dip), when the treated group was already on a different trend, when the treatment spills over into the comparison group, and, in the two-way regression, when the treatment starts at different dates and its effect changes over time (Section 3.5).

3.3 The regression form and its errors

Proposition 3.6 (Difference-in-differences as a regression)

In the regression Yit=κ+γDi+ϕ t+τDit+uitY_{it} = \kappa + \gamma D_i + \phi\, t + \tau D_i t + u_{it} over the four cells, with t∈{0,1}t \in \{0, 1\}, the OLS estimate of τ\tau equals the difference-in-differences estimator.

Proof. The regression has four parameters and the data four cells, so OLS fits each cell mean exactly: Yˉ0,0=κ\bar Y_{0,0} = \kappa, Yˉ1,0=κ+γ\bar Y_{1,0} = \kappa + \gamma, Yˉ0,1=κ+ϕ\bar Y_{0,1} = \kappa + \phi and Yˉ1,1=κ+γ+ϕ+τ\bar Y_{1,1} = \kappa + \gamma + \phi + \tau. Then (Yˉ1,1−Yˉ1,0)−(Yˉ0,1−Yˉ0,0)=τ(\bar Y_{1,1} - \bar Y_{1,0}) - (\bar Y_{0,1} - \bar Y_{0,0}) = \tau. ∎

The regression form earns its place by what it adds: controls, more periods and groups, and standard errors. The last need care. In the NSW listing each person appears twice, so the standard error is clustered by person. In policy applications the treatment is usually assigned to a few groups — two states, a handful of provinces — and the errors of all units in a group share the group’s shocks. Clustering by group is then the rule (Section 2.5), and with two groups it is impossible: the comparison of one state with one other has, in the end, one degree of freedom for the group shocks, however many restaurants were called.

3.4 Event studies

Definition 3.7 (Event study)

An event study regression, for units first treated at different dates, replaces the single treatment dummy with one dummy for each event time kk (periods since the unit’s first treatment), alongside unit and period effects, and omits one reference period, usually k=−1k = -1. The coefficients on k<0k < 0 (the leads) measure differences before the treatment; those on k≥0k \ge 0 (the lags), the effect kk periods after.

An event study plots the leads and lags with their confidence intervals. The leads are a placebo test of parallel trends in the periods where it can be checked, and the lags show how the effect builds up or fades. The chart shows one on simulated data, in which half the treated units adopt in period 6 and half in period 11 and a third group never does.

Event study on a simulated staggered roll-out: estimated coefficient for each period relative to adoption, with 95 % confidence intervals clustered by unit (reference period k = -1). Dashed: the true effect, 0.5 + 0.1k from adoption on. 300 units, 16 periods.
Event study on a simulated staggered roll-out: estimated coefficient for each period relative to adoption, with 95 % confidence intervals clustered by unit (reference period k=−1k = -1). Dashed: the true effect, 0.5+0.1k0.5 + 0.1k from adoption on. 300 units, 16 periods. Source: simulated data, the chapter’s seeded script

The four leads lie within a few hundredths of zero, and every interval covers zero; the lags climb with the true effect. Flat leads do not prove parallel trends after the treatment, and a test with little power will find flat leads in data where the trends differ; but rising or falling leads are hard evidence against the design. Two cautions. If units react before the treatment — shops stocking up before a tax rise is announced to take effect — the reference period k=−1k = -1 is itself treated and every coefficient is shifted (Exercise 3.10). And the regression that produced this chart is safe only because the effect was the same for both cohorts; the next section shows what happens when it is not.

3.5 Staggered adoption

Definition 3.8 (Staggered adoption)

A treatment has staggered adoption when units start it at different dates and, once treated, stay treated. Units that start at the same date form a cohort.

For years the standard estimator for staggered designs was the two-way fixed effects regression of Chapter 2, Yit=ai+μt+βDit+uitY_{it} = a_i + \mu_t + \beta D_{it} + u_{it}, with Dit=1D_{it} = 1 once unit ii is treated. Its coefficient looks like a difference in differences, and with one adoption date it is one. With several, it is a mixture.

Proposition 3.9 (Two-way fixed effects as a weighted average)

In a balanced panel with staggered adoption, the two-way fixed effects coefficient β^\hat\beta is a weighted average, with non-negative weights summing to one, of all the two-group, two-period difference-in-differences estimates that can be formed from the data: each cohort against the never-treated; each earlier cohort against a later one before the later one is treated; and each later cohort against an earlier one after the earlier one is treated. The weights grow with the size of the groups and with the variance of the treatment dummy in each comparison (Goodman-Bacon 2021).

Proof. Admitted at this level. ∎

The proof rewrites the two-way fixed effects coefficient, by the Frisch–Waugh–Lovell theorem, as a ratio of sums over pairs of cohorts; it is in Goodman-Bacon’s paper.

The last kind of comparison is the trouble. When the later cohort is treated, the earlier one serves as its comparison, but the earlier one is itself still being treated, and its effect may still be growing. Its change over that period contains its own treatment effect, which is subtracted.

Staggered adoption in : the early cohort is treated from period 4, the late one from period 8 (dark bars). In periods 8–12 two-way fixed effects uses the early cohort, already treated, as a comparison for the late one.
Staggered adoption in Listing 3.3: the early cohort is treated from period 4, the late one from period 8 (dark bars). In periods 8–12 two-way fixed effects uses the early cohort, already treated, as a comparison for the late one.
"""Staggered adoption: two-way fixed effects against a clean comparison.
Cohort E is treated from period 4, cohort L from period 8, cohort N never;
the effect grows by 1 per period of exposure."""
import numpy as np
import pandas as pd
import statsmodels.formula.api as smf

rng = np.random.default_rng(5)
rows = []
for cohort, start, size in (("E", 4, 100), ("L", 8, 100), ("N", 99, 100)):
    for i in range(size):
        a = rng.normal()
        for t in range(1, 13):
            exposure = max(0, t - start + 1)
            rows.append((f"{cohort}{i}", cohort, t, int(t >= start), exposure,
                         a + 0.2 * t + exposure + rng.normal(0, 0.5)))
d = pd.DataFrame(rows, columns=["unit", "cohort", "t", "d", "exposure", "y"])

twfe = smf.ols("y ~ d + C(unit) + C(t)", d).fit().params["d"]
att = d.loc[d.d == 1, "exposure"].mean()       # true average effect on treated
print(f"true average effect on the treated   {att:.3f}")
print(f"two-way fixed effects                {twfe:.3f}")

# clean: each treated cell against the never-treated, relative to the
# cohort's last untreated period (one 2x2 comparison per cell)
gaps = []
for cohort, start in (("E", 4), ("L", 8)):
    g = d[d.cohort.isin([cohort, "N"])].groupby(["cohort", "t"]).y.mean()
    base = g[cohort, start - 1] - g["N", start - 1]
    for t in range(start, 13):
        gaps.append((g[cohort, t] - g["N", t] - base, 100))
est = sum(v * w for v, w in gaps) / sum(w for _, w in gaps)
print(f"clean comparisons, averaged          {est:.3f}")
Listing 3.3. Two-way fixed effects against clean comparisons, when the effect grows with exposure. code/bachelor-3/03-difference-in-differences/listings/bacon.py
$ python bacon.py
true average effect on the treated   4.286
two-way fixed effects                2.547
clean comparisons, averaged          4.243
Output 3.3. True effect: 1 per period of exposure.

The true average effect on the treated is 4.29; two-way fixed effects reports 2.55, an error of about 40 % with no sampling noise to blame. Here every unit’s effect is positive and the estimate is merely too small; in other designs the bad comparisons can drive it below zero (Exercise 3.8). The repair is to make only clean comparisons: each cohort against units not yet treated, from the cohort’s last untreated period. The last line of the listing uses the simplest clean comparison, each cohort against the never-treated units, 4.24. Several estimators formalise this — Callaway and Sant’Anna (2021) average the cohort-by-period comparisons; de Chaisemartin and D’Haultfœuille (2020) use the units whose treatment changes between consecutive periods — and differ mainly in which comparisons they allow and how they weight them. An event study with a never-treated group and separate coefficients for each cohort is another clean route.

3.6 Synthetic control

Sometimes only one unit is treated: one country reunifies, one state passes a tobacco law. No group of untreated units need follow the treated one in parallel, and choosing a single comparison by hand invites the choice that gives the answer one wanted.

Definition 3.10 (Synthetic control; donor pool)

For one treated unit and a set of untreated units, the donor pool, a synthetic control is a weighted average of the donors, with non-negative weights summing to one, chosen so that its outcome before the treatment tracks the treated unit’s as closely as possible. The estimated effect in each later period is the gap between the treated unit and its synthetic control.

Proposition 3.11 (Synthetic weights)

Given the treated unit’s pre-treatment outcomes y1∈RT0y_1 \in \mathbb R^{T_0} and the donors’ Y0∈RT0×JY_0 \in \mathbb R^{T_0 \times J}, the synthetic weights solve min⁡w∥y1−Y0w∥2\min_w \lVert y_1 - Y_0 w \rVert^2 subject to wj≥0w_j \ge 0 and ∑jwj=1\sum_j w_j = 1: a least-squares problem over the simplex, whose solution exists and is a point of the convex hull of the donors’ paths closest to the treated path.

Proof. Admitted at this level. ∎

Existence follows because the simplex is compact and the objective continuous; the solution is unique when the donors’ paths are affinely independent. In practice the paths are often replaced by pre-period averages of the outcome and of predictors, weighted by a second, outer optimisation; the inner problem has the same form.

The constraint is the method’s discipline: no extrapolation beyond the donors, and weights that a reader can inspect. A regression with unrestricted weights would fit the pre-period at least as well, with negative weights on some countries and weights above one on others.

On the record — Reunification and West German income

Abadie, Diamond and Hainmueller (2015) built a synthetic West Germany from sixteen other rich countries, matched on income per person and its predictors before 1990. Five received weight: Austria 0.42, the United States 0.22, Japan 0.16, Switzerland 0.11 and the Netherlands 0.09. After 1990 the two paths separated. Over 1990–2003, West Germany’s GDP per person was about $16001600 a year below its synthetic control on average, about 8 % of its 1990 level, and by 2003 the synthetic West Germany was about 12 % richer than the real one. (A 2025 erratum by the authors states the dollar figures in current purchasing-power dollars rather than constant ones; the percentages are unchanged.) Placebo runs that pretend each donor reunified in 1990 give ratios of post- to pre-1990 gap all below West Germany’s, which is about 16; ranking first of 17 by luck has a chance of 1/17=0.0591/17 = 0.059.

Listing 3.4 runs the method on a simulated region and twenty donors, all driven by two common factors with different loadings, so that no single donor matches the treated region.

"""Synthetic control on a simulated region and twenty donors: weights, fit before
the policy, the estimated effect after it, and the placebo rank."""
import numpy as np
from synth import rmspe, synth_weights

rng = np.random.default_rng(12)
T, T0, J = 30, 20, 20                       # periods, pre-periods, donors
f = rng.normal(size=(T, 2)).cumsum(0)       # two common factors
load = rng.uniform(0, 1, size=(J + 1, 2))
Y = 10 + f @ load.T + rng.normal(0, 0.3, size=(T, J + 1))
Y[T0:, 0] -= 2.0                            # unit 0 is treated: effect -2

y1, Y0 = Y[:, 0], Y[:, 1:]
w = synth_weights(y1[:T0], Y0[:T0])
top = np.argsort(w)[::-1][:4]
print("largest weights:", ", ".join(f"donor {j + 1} {w[j]:.2f}" for j in top))
print(f"pre-period RMSPE     {rmspe(y1[:T0], Y0[:T0], w):.3f}")
print(f"mean gap after       {np.mean(y1[T0:] - Y0[T0:] @ w):.3f}")


def ratio(unit):
    others = [k for k in range(J + 1) if k != unit]
    wk = synth_weights(Y[:T0, unit], Y[:T0, others])
    return rmspe(Y[T0:, unit], Y[T0:, others], wk) / rmspe(
        Y[:T0, unit], Y[:T0, others], wk)


ratios = [ratio(k) for k in range(J + 1)]
rank = 1 + sum(r > ratios[0] for r in ratios[1:])
print(f"post/pre RMSPE ratio {ratios[0]:.1f}, rank {rank} of {J + 1}")
Listing 3.4. Weights, pre-period fit, effect, and the placebo rank. code/bachelor-3/03-difference-in-differences/listings/synth_demo.py
$ python synth_demo.py
largest weights: donor 20 0.33, donor 8 0.24, donor 2 0.17, donor 18 0.14
pre-period RMSPE     0.258
mean gap after       -1.681
post/pre RMSPE ratio 6.8, rank 1 of 21
Output 3.4. True effect −2-2 from period 21.
A simulated region and its synthetic control (four donors carry most of the weight). The policy starts in period 21; the true effect is -2. Twenty donors driven by two common factors.
A simulated region and its synthetic control (four donors carry most of the weight). The policy starts in period 21; the true effect is −2-2. Twenty donors driven by two common factors. Source: simulated data, the chapter’s seeded script

Before period 21 the two paths are hard to tell apart: the root mean squared gap is 0.26. After, the mean gap is −1.68-1.68 against a true −2-2. Inference uses placebos. Each donor in turn is treated as if it had been treated, a synthetic control is built for it from the others, and the ratio of its post-period to its pre-period gap is computed. The treated region’s ratio, 6.8, is the largest of the 21; if the policy had done nothing, the chance that the true unit would rank first by luck is 1/211/21, about 0.05. With fewer donors, no result can be significant at that level, whatever the gap.

3.7 Exercises

Exercise 3.1 ★

Read the opening chart.

  1. Compute each state’s change from February to November and the difference in differences from the printed means.
  2. Compute New Jersey’s change in percent of its February level.
  3. State in one sentence what the dashed line assumes.
Solution

Solution of Exercise 3.1.

  1. Pennsylvania: 21.17−23.33=−2.1621.17 - 23.33 = -2.16. New Jersey: 21.03−20.44=0.5921.03 - 20.44 = 0.59. Difference in differences: 0.59−(−2.16)=2.750.59 - (-2.16) = 2.75 workers per restaurant (the paper’s 2.76 comes from unrounded means).
  2. 0.59/20.44=0.02890.59/20.44 = 0.0289: employment rose by 2.9 %.
  3. That without the rise, New Jersey’s employment per restaurant would have fallen by as much as Pennsylvania’s did, from 20.44 to 18.28.

Exercise 3.2 ★

Average hourly wages (in dalens) in two regions of Brenland were 20 and 24 in 2023, and 21 and 26.5 in 2025. Only the second region cut its payroll tax in 2024.

  1. Compute the difference-in-differences estimate of the tax cut’s effect on wages.
  2. What assumption does it need, and what would you look at to check it?
Solution

Solution of Exercise 3.2.

  1. First region: 21−20=121 - 20 = 1. Second: 26.5−24=2.526.5 - 24 = 2.5. Estimate: 2.5−1=1.5 dalens2.5 - 1 = 1.5\text{ dalens} an hour.
  2. Parallel trends: without the cut, wages in the second region would have risen by 1 dalen like the first’s. Check that the two regions’ wages moved in parallel in the years before 2024.

Exercise 3.3 ★

In the event-study chart of Section 3.4, read the coefficient at k=2k = 2 and its interval. What would you conclude if the leads had been −0.4-0.4, −0.3-0.3, −0.2-0.2 and −0.1-0.1 at k=−5,…,−2k = -5, \dots, -2?

Solution

Solution of Exercise 3.3.

At k=2k = 2 the estimate is 0.69 with an interval of 0.56 to 0.82, covering the true 0.7. Leads rising steadily from −0.4-0.4 to −0.1-0.1 would show the treated units already gaining on the others before adoption, at about 0.1 a period. Parallel trends would be rejected, and the lags would mix that trend with the effect.

Exercise 3.4 ★

Describe two patterns of pre-treatment data that contradict parallel trends, and one that does not contradict it even though the two groups differ.

Solution

Solution of Exercise 3.4.

Contradicting: a gap between the groups that widens or narrows steadily before the treatment (a differential trend); a dip in the treated group just before treatment (Ashenfelter’s dip). Not contradicting: a constant gap in levels, with both groups moving up and down together.

Exercise 3.5 ★★

Mean sales in two groups of shops go from 100 to 120 (group A, treated) and from 50 to 60 (group B, untreated).

  1. Compute the difference in differences in levels and in logs.
  2. Show that parallel trends cannot hold both in levels and in logs here, and explain how one would choose between them.
Solution

Solution of Exercise 3.5.

  1. Levels: 20−10=1020 - 10 = 10. Logs: ln⁡(120/100)−ln⁡(60/50)=ln⁡1.2−ln⁡1.2=0\ln(120/100) - \ln(60/50) = \ln 1.2 - \ln 1.2 = 0.
  2. Parallel trends is about A’s counterfactual: in levels, A without the treatment would have gained 10, like B; in logs, it would have grown 20 % like B, that is by 20. Starting from different levels, a gain of 10 and a growth of 20 % are different numbers for A, so at most one can hold. Choose the scale on which the groups moved in parallel before the treatment, and on which the outcome’s changes are comparable across its levels: for sales, percentage changes usually.

Exercise 3.6 ★★

Use the NSW data to compute a placebo difference in differences from 1974 to 1975, both before the programme, with each survey as the comparison group.

  1. Report the trainees’ change, each survey’s change, and the two placebo estimates with their standard errors.
  2. What does the result say about parallel trends, and what can it not say?
Solution

Solution of Exercise 3.6.

The tested solution is ex06_placebo_1974.py, in the chapter’s exercises/ folder.

  1. Trainees’ change −$564-\text{\$}564; population survey −$366-\text{\$}366, placebo estimate −198-198 (s.e. 280); the second survey −$365-\text{\$}365, placebo −198-198 (s.e. 317). (From the printed changes the second difference is −199-199; the script works with unrounded means.)
  2. Both estimates are small relative to their standard errors: the trainees’ earnings did not fall significantly faster than the surveys’ before the programme. That is consistent with parallel trends from 1974 to 1975. It cannot show they held from 1975 to 1978, and it does not rule out a dip that began in 1975 itself, after the date the data measure.

Exercise 3.7 ★★

Workers enter a training programme after a year in which their earnings fell for temporary reasons. The evaluator measures the change in their earnings from that year to two years after the programme, against a comparison group without the dip. In which direction is the difference in differences biased? How would choosing an earlier “before” year help?

Solution

Solution of Exercise 3.7.

Upward. The before year is abnormally low, so part of the rise afterwards is a recovery that would have happened anyway, and the comparison group, without a dip, has no such recovery to subtract. Using a before year earlier than the dip compares from a normal level and removes that part of the bias.

Exercise 3.8 ★★

Two equal-sized groups are observed in periods 1, 2 and 3. Group E is treated from period 2, group L from period 3; there is no never-treated group. E’s effect is τ\tau in period 2 and τ+γ\tau + \gamma in period 3 (here γ\gamma is the growth of the effect); L’s effect is τ\tau in period 3.

  1. Compute the double-demeaned treatment dummy in each of the six cells.
  2. Show that the two-way fixed effects coefficient equals τ−γ/2\tau - \gamma/2.
  3. Give values of τ\tau and γ\gamma, both positive, for which the coefficient is negative. Which cell receives a negative weight?
Solution

Solution of Exercise 3.8.

  1. The dummy is E: (0,1,1)(0, 1, 1), L: (0,0,1)(0, 0, 1). Group means: E 2/32/3, L 1/31/3; period means 0,1/2,10, 1/2, 1; overall mean 1/21/2. Subtracting the group and period means and adding the overall mean gives E: (−1/6,1/3,−1/6)(-1/6, 1/3, -1/6) and L: (1/6,−1/3,1/6)(1/6, -1/3, 1/6).
  2. The sum of squares is 4×1/36+2×1/9=1/34 \times 1/36 + 2 \times 1/9 = 1/3. Unit and period effects in YY are orthogonal to the demeaned dummy, so only the treatment effects count: ∑D~Y=13τ−16(τ+γ)+16τ=τ3−γ6\sum \tilde D Y = \frac13 \tau - \frac16(\tau + \gamma) + \frac16 \tau = \frac{\tau}{3} - \frac{\gamma}{6}. Dividing by 1/31/3 gives τ−γ/2\tau - \gamma/2.
  3. With τ=1\tau = 1 and γ=3\gamma = 3 the coefficient is −0.5-0.5, although every effect is positive. The cell weights are 1 on (E, period 2), −1/2-1/2 on (E, period 3) and 1/21/2 on (L, period 3); the negative weight is on the early group’s later, larger effect, which serves as a comparison for L.

Exercise 3.9 ★★

Kestria raises the sales tax on fuel in its two western provinces only. Propose a placebo group, a placebo outcome and a placebo date for a difference-in-differences study of the effect on fuel sales, and say what each would rule out.

Solution

Solution of Exercise 3.9.

Placebo group: provinces far from the western border, split at random into “treated” and “untreated”, or an eastern province given a fictitious tax date; an effect there would show a shock specific to some provinces. Placebo outcome: sales of goods the tax did not touch, such as groceries; a fall there would point to a regional downturn rather than the tax. Placebo date: pretend the tax came two years earlier and use only the years before the true date; an effect would reveal different pre-existing trends.

Exercise 3.10 ★★★

Simulate the design of the event-study chart, but let the units react one period before adoption, with an effect of 0.3 at k=−1k = -1.

  1. Estimate the event study with reference period k=−1k = -1 and report the coefficients at k=−3,−2,0,1,2k = -3, -2, 0, 1, 2.
  2. Re-estimate with reference period k=−2k = -2. Explain the difference.
Solution

Solution of Exercise 3.10.

The tested solution is ex10_anticipation.py, in the chapter’s exercises/ folder.

  1. With k=−1k = -1 as reference: −0.36-0.36, −0.31-0.31, 0.160.16, 0.280.28 and 0.390.39 at k=−3,−2,0,1,2k = -3, -2, 0, 1, 2.
  2. With k=−2k = -2 as reference: −0.05-0.05 at k=−3k = -3, 0.310.31 at k=−1k = -1, and 0.470.47, 0.590.59, 0.700.70 at k=0,1,2k = 0, 1, 2, close to the truth (0.3, then 0.5, 0.6, 0.7). In the first regression every coefficient is measured against a period already raised by 0.3, so all shift down by about 0.3: the leads look like a pre-trend and the effects are understated. The reference period must be one that the treatment cannot have reached.

Exercise 3.11 ★★★

A treated region has outcomes 4 and 6 in two pre-treatment periods. Three donors have (2,4)(2, 4), (6,6)(6, 6) and (4,10)(4, 10).

  1. Find the synthetic-control weights, and check that they reproduce the pre-treatment path exactly.
  2. After the treatment, the region’s outcome is 5 and the donors’ are 3, 7 and 9. Estimate the effect.
  3. Why does the method forbid negative weights?
Solution

Solution of Exercise 3.11.

  1. Solve 2wA+6wB+4wC=42w_A + 6w_B + 4w_C = 4, 4wA+6wB+10wC=64w_A + 6w_B + 10w_C = 6, wA+wB+wC=1w_A + w_B + w_C = 1. Substituting wC=1−wA−wBw_C = 1 - w_A - w_B, the first gives wA=wBw_A = w_B, the second −6wA−4wB=−4-6w_A - 4w_B = -4, so wA=wB=0.4w_A = w_B = 0.4 and wC=0.2w_C = 0.2, all non-negative. Check: 0.8+2.4+0.8=40.8 + 2.4 + 0.8 = 4 and 1.6+2.4+2=61.6 + 2.4 + 2 = 6.
  2. Synthetic: 0.4×3+0.4×7+0.2×9=5.80.4 \times 3 + 0.4 \times 7 + 0.2 \times 9 = 5.8. Effect: 5−5.8=−0.85 - 5.8 = -0.8.
  3. Negative weights, or weights above one, would let the synthetic unit lie outside the range of the donors: an extrapolation that can fit the past exactly and predict the future badly, and that no reader could interpret as a comparison with real places.

Exercise 3.12 ★★★

A state introduces health insurance for people aged 65 and over. A difference in differences of the old in that state against the old in other states may be biased by state-wide shocks that hit the old differently.

  1. Write the triple-difference estimator that also uses people under 65 in both kinds of state.
  2. State the assumption it needs, and show that it is weaker than parallel trends for the old alone.
Solution

Solution of Exercise 3.12.

  1. With Δ\Delta the after-minus-before change of a group’s mean, the estimator is [Δ(old, state)−Δ(young, state)]−[Δ(old, others)−Δ(young, others)][\Delta(\text{old, state}) - \Delta(\text{young, state})] - [\Delta(\text{old, others}) - \Delta(\text{young, others})].
  2. It needs the gap between the old’s and the young’s untreated trends to be the same in the state as elsewhere. That allows any shock to the whole state (hitting old and young alike) and any nationwide shock specific to the old, both of which bias the simple comparison of the old; it fails only for a shock that hits the old in that state alone.

3.8 Problem: The Kestrian Border Tax

Problem 3.1

Weekend problem — the Kestrian border tax

Kestria (invented) has twelve provinces. In 2019 it raised its sales tax in the three western provinces W1–W3, which border Brenland, where shopping became relatively cheaper; in 2021 it raised it in the three eastern provinces E1–E3; the six northern provinces N1–N6 kept the old rate. A statistician has the log annual sales of 50 shops in each province, 2014–2024, and computes the tables below. Standard errors are clustered by province.

The event study uses the western and northern shops only, with shop and year effects and k=−1k = -1 (2018) as reference. The “clean” estimator averages, over every treated province and year, the province’s change since its last untreated year minus the north’s change. The data are invented, so the true average effect over treated shop-years is known: it is the last line.

Part I — two groups, two years.

  1. From the table of means, compute each group’s change from 2018 to 2020 and the difference in differences.
  2. Convert it into a percentage change in sales.
  3. Give a 95 % confidence interval with the clustered standard error.
  4. How many clusters does the standard error rest on? Why is that a concern?
  5. The west’s mean was below the north’s already in 2018. Does that threaten the estimate?
  6. Name one event in 2019–2020, other than the tax, that would bias this estimate, and say in which direction.

Part II — the event study.

  1. Compute the tt-statistic of each lead. What do the leads suggest?
  2. The coefficient at k=1k = 1 equals the difference in differences of Part I. Explain why.
  3. Describe the path of the lags from k=0k = 0 to k=5k = 5, and give one economic reason why an effect on cross-border shopping might grow over two or three years.
  4. The lag at k=4k = 4 has a larger standard error than the others. Why might estimates far from the event be noisier?
  5. Suppose shoppers had learned of the tax in mid-2018 and stocked up before it. What would happen to the coefficients, given the reference year?
  6. Why does this event study leave out the eastern provinces?

Part III — the roll-out to the east.

  1. Which comparisons does the two-way fixed effects regression over all twelve provinces make? Name the three kinds.
  2. Which of them is a forbidden comparison, and why does it bias the estimate toward zero here?
  3. Compute the bias of two-way fixed effects as a percentage of the true effect.
  4. The clean estimator comes within 0.001 of the truth. Which comparisons does it avoid?
  5. Compare the standard errors of the two-by-two and two-way estimates. Is the smaller one a reason to prefer two-way fixed effects?
  6. If the effect had been constant from the first year on, would two-way fixed effects have been biased? Explain.

Part IV — one province.

  1. Check that the synthetic weights for W1 sum to one, and say how many donors receive weight.
  2. Compute the root mean squared gap over 2014–2018.
  3. Compute the mean gap over 2021–2024 and compare it with the west’s event-study lags for the same years.
  4. Give one reason why W1’s effect may be larger than the average western province’s.
  5. Compute the root mean squared gap over 2019–2024 and the ratio of the post- to the pre-period value.
  6. With six donors, what is the smallest pp-value a placebo test of ranks can give? Is a rank of 1 out of 7 strong evidence?
  7. Why should the donor pool exclude the eastern provinces?
  8. State the results of the problem: the effect of the tax on the sales of western shops by each of the four estimators, and which you would report.
Solution

Solution of Problem 3.1.

1. West: 5.0773−5.1633=−0.08605.0773 - 5.1633 = -0.0860. North: 5.1788−5.1871=−0.00835.1788 - 5.1871 = -0.0083. Difference in differences: −0.0860−(−0.0083)=−0.0777-0.0860 - (-0.0083) = -0.0777.

2. e−0.0777−1=−0.0748\eu^{-0.0777} - 1 = -0.0748: sales 7.5 % lower.

3. −0.0777±1.96×0.0225=−0.0777±0.0441-0.0777 \pm 1.96 \times 0.0225 = -0.0777 \pm 0.0441: from −0.1218-0.1218 to −0.0336-0.0336.

4. Nine: three western and six northern provinces. Cluster-robust standard errors are justified as the number of clusters grows and tend to be too small with few; with three treated clusters, the interval should be checked by methods that resample or permute whole provinces.

5. No. Parallel trends allow any difference in levels; only a difference in changes would bias the estimate.

6. For instance, a large shopping centre opening on the Brenland side of the border in 2019 would draw western shoppers whatever the tax, and make the estimate more negative. A downturn in the west’s main industry would do the same.

7. Dividing each lead by its standard error, from k=−5k = -5 to −2-2: −0.0088/0.0211=−0.42-0.0088/0.0211 = -0.42, −0.0004/0.0221=−0.02-0.0004/0.0221 = -0.02, −0.0036/0.0173=−0.21-0.0036/0.0173 = -0.21 and −0.0163/0.0217=−0.75-0.0163/0.0217 = -0.75. None is near 2: the west and north moved together before the tax.

8. The panel is balanced, every western shop is treated in the same year, and each event-time dummy picks one year. With shop and year effects, the coefficient on one year’s dummy is the difference in differences between that year and the reference year; k=1k = 1 is 2020 against 2018, the comparison of Part I.

9. −0.030-0.030 in 2019, −0.078-0.078 in 2020, −0.112-0.112 in 2021, then −0.146-0.146, −0.157-0.157 and −0.144-0.144: the effect builds for about three years and then levels off near −0.15-0.15. Shoppers learn of the price gap, try the trip, and change habits; shops across the border adapt their opening hours and stock.

10. Each coefficient compares one year with 2018. Persistent province shocks drift apart as the two years grow further apart, so the comparison carries more noise; and with nine clusters the standard errors are themselves imprecise.

11. Sales in the west would be high in 2018, the reference year. Every coefficient would be measured from an inflated base: the leads would turn negative, as if the west had been rising before the tax, and the lags would overstate the fall.

12. The east is treated from 2021. In a regression whose dummies mark only western event times, eastern shops would count as untreated in 2021–2024, and their fall would be read as a fall of the comparison group.

13. The west against the north; the east against the north; the west against the east before 2021, while the east is untreated; and the east against the west from 2021, while the west is already treated.

14. The last. From 2020 to 2021 the west’s own effect deepens, from −0.08-0.08 to −0.12-0.12 in the design; subtracting the west’s change from the east’s subtracts that deepening, which makes the east’s effect look smaller.

15. (−0.0907)−(−0.106)=0.0153(-0.0907) - (-0.106) = 0.0153, and 0.0153/0.106=0.1440.0153/0.106 = 0.144: two-way fixed effects understates the effect by 14 %.

16. It compares each treated province only with the never-treated north, and from its own last untreated year: no already-treated province ever serves as a comparison.

17. 0.0225 against 0.0102; the two-way regression uses all years and provinces. A smaller standard error around a biased number is no reason to prefer it: the two-way estimate’s interval, −0.0907±0.0200-0.0907 \pm 0.0200, from −0.1107-0.1107 to −0.0707-0.0707, covers the truth only near its edge.

18. No. If each province’s effect were constant over time, the already-treated comparison group’s change would contain no change in its effect, and the forbidden comparisons would be harmless; differences across provinces would affect only how the effects are weighted.

19. 0.5184+0.2863+0.1231+0.0722=1.00000.5184 + 0.2863 + 0.1231 + 0.0722 = 1.0000; four donors, N1–N4, receive weight.

20. The squares of the five gaps sum to 0.001240870.00124087; divided by 5 and square-rooted, 0.01580.0158.

21. (−0.1527−0.1479−0.1975−0.1846)/4=−0.1707(-0.1527 - 0.1479 - 0.1975 - 0.1846)/4 = -0.1707. The west’s lags for 2021–2024 (k=2k = 2 to 5) average −0.5589/4=−0.1397-0.5589/4 = -0.1397: W1’s gap is larger.

22. W1 is the province where the trip to Brenland is shortest, so more of its shoppers can switch.

23. The squares of the six gaps for 2019–2024 sum to 0.130787370.13078737; divided by 6 and square-rooted, 0.14760.1476. Ratio: 0.1476/0.0158=9.30.1476/0.0158 = 9.3.

24. With W1 and six donors there are seven ratios; the smallest pp-value is 1/7=0.141/7 = 0.14. A rank of 1 is the strongest evidence the test can give, but it cannot reach the 5 % level.

25. The east is taxed from 2021, so its later path contains the tax effect. A synthetic W1 built partly from eastern provinces would fall with them after 2021 and understate W1’s effect.

26. The effect of the tax on western shops’ sales: −0.078-0.078 by the two-by-two comparison of 2020 with 2018, when the effect was still building; −0.091-0.091 by two-way fixed effects, biased toward zero by the roll-out to the east; −0.106-0.106 by clean comparisons with the north, the number to report, with the event-study path beside it; and, for the border province W1 alone, −0.171-0.171 a year over 2021–2024 by synthetic control, with a placebo test that cannot be significant at 5 % with six donors.

本章定义的术语

在术语表中查看全部 1086 个术语