Appendix † — Solutions — PS 4.1 (The 2×2 Difference-in-Differences and Event-Study Construction)

Problem set: book/weeks/week-04/ps4.1.md (PS 4.1, Week 4). Chapter: Ch 4.1 — Difference-in-Differences and Event Studies.

These are full worked solutions, not just answers. Notation follows CONVENTIONS.md and locks to Ch 4.1: the four cell means \bar Y_T^{\,\text{pre}}, \bar Y_T^{\,\text{post}}, \bar Y_C^{\,\text{pre}}, \bar Y_C^{\,\text{post}}; the double difference \widehat{\text{DiD}}; panel potential outcomes Y_{it}(1), Y_{it}(0) with the observation rule Y_{it}=D_{it}Y_{it}(1)+(1-D_{it})Y_{it}(0); the estimand \text{ATT}=\mathbb{E}[Y_{it}(1)-Y_{it}(0)\mid\text{treated, post}]; parallel trends; the TWFE regression Y_{it}=\alpha_i+\lambda_t+\beta D_{it}+\varepsilon_{it} and its dummy-interaction equivalent; the event-study specification with the k=-1 normalization; pre-trend reading and its logical/statistical limits; and cluster-robust inference. Every numerical result here was confirmed in Python (NumPy four-cell arithmetic and a TWFE-equivalence check on a constructed two-period panel); verifying notes appear where useful. All premiums are annual dollars.


Problem 1 — Compute and interpret a 2×2 DiD (14 points)

The four cells: \bar Y_T^{\,\text{pre}}=1{,}620, \bar Y_T^{\,\text{post}}=1{,}845, \bar Y_C^{\,\text{pre}}=1{,}280, \bar Y_C^{\,\text{post}}=1{,}410.

(a) (4 pts) The two contaminated one-way comparisons:

Treated before-and-after change: \bar Y_T^{\,\text{post}}-\bar Y_T^{\,\text{pre}} = 1{,}845-1{,}620 = \$225. This confounds the regulation with the passage of time — everything else that moved premiums that year (worsening wildfires, costlier reinsurance, inflation in rebuilding costs) and would have happened regardless of the rule.

Cross-sectional after-gap: \bar Y_T^{\,\text{post}}-\bar Y_C^{\,\text{post}} = 1{,}845-1{,}410 = \$435. This confounds the regulation with the fixed difference between the states — the treated state’s own fire geography, building stock, and baseline price level, which made it more expensive than the control to begin with (a \bar Y_T^{\,\text{pre}}-\bar Y_C^{\,\text{pre}}=1{,}620-1{,}280=\$340 head start) for reasons having nothing to do with the rule.

(b) (4 pts) Route 1 — (treated change) minus (control change), differencing over time first: \widehat{\text{DiD}} = \big(\bar Y_T^{\,\text{post}}-\bar Y_T^{\,\text{pre}}\big) - \big(\bar Y_C^{\,\text{post}}-\bar Y_C^{\,\text{pre}}\big) = (1{,}845-1{,}620) - (1{,}410-1{,}280) = 225 - 130 = \$95.

Route 2 — (after-gap) minus (before-gap), differencing across groups first: \widehat{\text{DiD}} = \big(\bar Y_T^{\,\text{post}}-\bar Y_C^{\,\text{post}}\big) - \big(\bar Y_T^{\,\text{pre}}-\bar Y_C^{\,\text{pre}}\big) = (1{,}845-1{,}410) - (1{,}620-1{,}280) = 435 - 340 = \$95. \quad\checkmark

Both land on $95, as they must — the double difference is symmetric. What each operation cancels: differencing over time (within a state) kills anything fixed across the two periods — the treated state’s permanently higher price level and fire geography subtract out because they sit in both its “before” and its “after.” Differencing across groups (within a period) kills anything that hits both states equally in that period — the nationwide reinsurance shock and common inflation subtract out because they sit in both rows.

(c) (3 pts) Of the $225 rise in the treated state’s premiums, DiD attributes $95 to the regulation and $130 to “everything else” — the latter being precisely the control state’s change \bar Y_C^{\,\text{post}}-\bar Y_C^{\,\text{pre}}=130, our estimate of the common trend the treated state would have ridden anyway. The “everything else” $130 is picking up forces such as worsening wildfire frequency/severity nationwide and rising reinsurance costs (also acceptable: economy-wide inflation in rebuilding/construction costs) — broad shocks that lifted premiums everywhere, treated and control alike.

(d) (3 pts) Card and Krueger (1994) studied fast-food employment around a minimum-wage change. The treated jurisdiction was New Jersey (which raised its minimum wage in 1992); the control was Pennsylvania (which did not); the treatment was the minimum-wage increase; and the cells held average fast-food employment (they surveyed fast-food restaurants in both states before and after). The result — that employment did not fall, contrary to the textbook competitive prediction — was argued over on the assumption rather than the arithmetic because the 2\times 2 design was clean and the double difference was transparent; the only place left to push back was whether New Jersey’s employment would have tracked Pennsylvania’s absent the hike, i.e., whether parallel trends held. (Arguing with the assumption rather than the arithmetic is exactly the right thing to do, which is why the study became canonical.)


Problem 3 — Build the TWFE regression and say what the fixed effects absorb (16 points)

(a) (5 pts) The two-way fixed-effects regression: Y_{it} = \alpha_i + \lambda_t + \beta\, D_{it} + \varepsilon_{it}. In Priya’s terms: Y_{it} is state i’s average homeowner premium in year t; \alpha_i is the state fixed effect (one intercept per state, capturing that state’s permanent price level); \lambda_t is the year fixed effect (one intercept per year, common to all states, capturing nationwide conditions that year); D_{it} is the treatment indicator (1 when state i is under the wildfire-pricing rule in year t); and \beta is the DiD estimate — the regulation’s effect. In the 2\times 2, D_{it}=1 in exactly one cell: the treated state in the post period, and 0 in the other three.

(b) (5 pts) The state fixed effects \alpha_i absorb everything about a state that is constant over time — its permanently higher price level, fixed fire geography, building stock. This is the regression performing the “difference across groups” that removed the fixed group difference. The year fixed effects \lambda_t absorb everything that hits every state equally in a given year — the nationwide reinsurance shock, common inflation. This is the regression performing the “difference across time” that removed the common time shock. Once both are in, the only variation left for D_{it} to explain is the part that varies across both state and year together — which, in the 2\times 2, is precisely the treated state being treated in the post period. That leftover is the regulation’s effect because every other source of movement (fixed state differences, common year shocks) has already been soaked up by the two sets of dummies.

(c) (3 pts) The interaction coefficient \beta_3 is the DiD estimate (identical to \beta above, identical to the $95). The interaction \text{Treat}_i\times\text{Post}_t is the same regressor as D_{it} here because it equals 1 only when both \text{Treat}_i=1 and \text{Post}_t=1 — i.e., only for the treated state in the post period, which is exactly the one cell where D_{it}=1. We carry the fixed-effects form forward (not the dummy form) because with many states and many years you cannot write a single \text{Treat}\times\text{Post} interaction, but you can still write one intercept per state and one per year — the FE notation scales, the single-interaction notation does not.

(d) (3 pts) Calling \alpha_i and \lambda_t “controls” in the Week-2 sense is misleading because Week-2 controls are covariates you add to hold a confounding variable fixed; the fixed effects are not variables Priya measured at all. They are the algebraic machinery that demeans the data — \alpha_i subtracts each state’s own time-average, \lambda_t subtracts each year’s cross-state average (the within transformation from Ch 2.3) — so that by the time \beta is estimated, the regression is working on data from which the fixed state level and the common year level have already been swept out. They are the two differencing operations of the 2\times 2, written as a regression; \beta is simply what survives both sweeps.


Problem 4 — Construct and read an event study (18 points)

(a) (5 pts) With event time k=t-t_i^{\ast} (t_i^{\ast} = first treated year for unit i), the event-study / leads-and-lags specification is Y_{it} = \alpha_i + \lambda_t + \sum_{k\neq -1} \beta_k\,\mathbb{1}\{\,t - t_i^{\ast} = k\,\} + \varepsilon_{it}. The dummies for k<0 are leads (periods before treatment); the dummies for k\ge 0 are lags (the treatment year and after). The two regions serve distinct purposes: the lags trace the dynamic treatment effect (how the regulation’s effect evolves once it switches on), while the leads serve as the pre-trend check (under parallel trends the groups should not have been diverging before any treatment existed, so the leads should hug zero).

(b) (4 pts) By convention we omit k=-1, the period immediately before treatment. We must omit one event-time dummy because a full set of them, alongside the unit and time fixed effects, is perfectly collinear — the dummies would span the same space the fixed effects already occupy (the dummy-variable trap: you cannot include every category and an intercept structure simultaneously). Dropping k=-1 sets \beta_{-1}=0 by construction, so every remaining \hat\beta_k reads as the treated-versus-control gap in event-period k relative to the last pre-treatment period (k=-1) — “how far has the gap moved from where it stood the instant before treatment.” This pins the period-before to zero and makes the plot easy to read.

(c) (5 pts) Reading \{\hat\beta_{-3},\dots,\hat\beta_2\} = \{4,-3,0,60,120,180\}:

  1. Lags (k\ge 0): \hat\beta_0=\$60, \hat\beta_1=\$120, \hat\beta_2=\$180 — the effect is building, not immediate. The regulation bites gradually (plausibly as policies renew at the new pricing rules), accumulating from $60 in the first treated year toward $180 two years out. It is neither an immediate-and-permanent jump (which would show as a flat post-period) nor a transitory spike that decays.

  2. Leads (k<0): \hat\beta_{-3}=\$4, \hat\beta_{-2}=-\$3 (and \hat\beta_{-1}=0 by construction) — these are tiny, scattered around zero with no slope. They are consistent with parallel trends: the treated and control states moved together in the pre-period, with no divergence before the rule existed. (Consistent with, not proof of — see Problem 5.)

  3. The static 2\times 2 would have collapsed the three lags into a single \beta — roughly their average, a blurry $120-ish number. The event study un-blurs the dynamics: it shows the effect is growing over time rather than constant, information the single coefficient destroys by averaging.

(d) (4 pts) The new leads \{\hat\beta_{-3},\hat\beta_{-2}\} = \{-90,-55\} are not scattered around zero — they slope steadily upward toward k=0 (from -90 to -55 to 0, a rise of roughly $45 per period). That is a pre-trend: the two states were already pulling apart before the regulation existed, so something other than the treatment was driving their relative premiums up. This poisons the post-period coefficients because if you extend the pre-trend line forward — the gap was rising about $45–55 per period before treatment — a good chunk of the post-period \hat\beta_0=40,\hat\beta_1=60,\hat\beta_2=85 is just that pre-existing divergence continuing, mislabeled as a treatment effect. The parallel-trends story is in serious trouble, and the honest reading is that the “effect” here is confounded with a differential trend that was coming anyway.


Problem 6 — Inference: cluster by unit, and the BDM warning (16 points)

(a) (4 pts) With \widehat\beta=\$225 fixed and t=\widehat\beta/\text{SE}:

SE flavor Std. error t
Classical (OLS) $22 225/22 \approx 10.23
Robust (HC1) $26 225/26 \approx 8.65
Clustered by state $95 225/95 \approx 2.37

The point estimate is identical across all three rows. The general principle (from Ch 2.4): the choice of standard-error flavor changes the standard error — and hence the t-stat, the p-value, and the confidence interval — but never the point estimate \widehat\beta itself. Here \widehat\beta=\$225 regardless; what moves is how certain we are about it, and the honest t drops from a triumphant 10.23 to a sobering 2.37 once we let each state’s residuals correlate across years.

(b) (5 pts) Bertrand, Duflo & Mullainathan (2004) took real panel data, assigned placebo treatments at random (fake interventions with no true effect whatsoever), and ran the standard DiD regression thousands of times. With honest standard errors, such pure-noise “effects” should be flagged significant at the 5% level about 5% of the time — that is what 5% significance means. Instead, conventional standard errors flagged the fake effects as significant up to ~45% of the time — nearly half of pure-noise treatments looked “significant,” so the SEs were catastrophically too small. The culprit is serial correlation within units: a state’s premium (and hence its residual) this year is highly correlated with last year’s, because slow-moving local conditions persist. By the Moulton intuition, when observations within a group are positively correlated, each carries less fresh information than an independent draw would, so the effective sample size is far below the nominal count; a “1,000-observation” panel (50 states × 20 years) holds far less independent information than 1,000. Classical/robust formulas assume the within-state residuals are independent across years and so divide by the inflated nominal N, producing a standard error that is too small and a t-stat that lies.

(c) (4 pts) The fix is the cluster-robust standard error, clustered by the unit of treatment — here, by state (each state’s errors allowed to be arbitrarily correlated across all its years; a block-diagonal \boldsymbol\Omega with one block per state). This is especially acute in DiD because the treatment indicator D_{it} is itself highly persistent within a unit — it is 0 for years and then 1 for years — i.e., high within-cluster regressor correlation \rho_x. The Moulton factor 1+(n-1)\rho_x\rho_\varepsilon shows that when both the regressor (\rho_x, high here because D_{it} barely varies within a state) and the residuals (\rho_\varepsilon, high because premiums persist) are strongly within-cluster-correlated, the naive standard error is understated by a large multiplicative factor. So DiD combines exactly the two ingredients that make naive SEs explode, which is why clustering by the treatment unit is the non-negotiable default.

(d) (3 pts) With exactly one treated state, clustering by state cannot rescue inference because the cluster-robust formula needs many clusters — and, more pointedly, many treated clusters — to pin down the treatment’s sampling distribution from the data. There simply is not enough independent variation in the treatment (one switch, in one unit) for the standard cluster-robust formula, the few-clusters t correction, or even the wild cluster bootstrap (Cameron, Gelbach & Miller, 2008) to estimate its variability reliably. This is a genuine limitation of the two-state design, not a software setting to flip. One alternative: placebo / permutation (randomization) inference — assign the fake treatment to each control state in turn, compute the placebo estimate each time, and ask how unusual Priya’s real $225 looks against that distribution of placebo effects. (This is also why researchers reach for many treated units, the staggered-adoption setting of Ch 4.2.)


All numerical answers verified in Python. Key results: P1 \widehat{\text{DiD}}=(1845-1620)-(1410-1280)=225-130=\$95, identical via after-gap minus before-gap (1845-1410)-(1620-1280)=435-340=\$95; treated before-after $225, cross-sectional after-gap $435; $95 to the rule, $130 to common trend. P2 imputed counterfactual \bar Y_T^{\,\text{pre}}+130=\$1{,}750, ATT =1845-1750=\$95. P4 lags \{60,120,180\} build; alt-state leads \{-90,-55\} slope up = pre-trend. P5(c) 95% CI 40\pm1.96(35)=[-28.6,\,108.6], contains both 0 and 100. P6(a) t-stats 225/22\approx10.23, 225/26\approx8.65, 225/95\approx2.37. Citations by name only, per chapter: Card–Krueger (1994), Bertrand–Duflo–Mullainathan (2004), Cameron–Gelbach–Miller (2008). All premiums illustrative/constructed; no fabricated empirical estimates.