# DiD with Continuous Treatment
```{r}
#| include: false
library(data.table)
library(fixest)
library(ggplot2)
```
The DiD chapter treats the treatment as on or off. Many treatments come in amounts. A county gets one Walmart or five. A state raises the minimum wage by fifty cents or by three dollars. A hospital receives a small grant or a large one. With a dose we want more than the effect of being treated. We want to know how the effect changes with the dose.
We first look at two periods, where @callaway-goodman-bacon-santanna-2024, CGBS from here on, show what parallel trends identifies with a dose and what it leaves out. Two assumptions carry everything that follows: parallel trends and strong parallel trends. We then move to staggered adoption, using the heterogeneous-slopes extension of extended two-way fixed effects (ETWFE) in @wooldridge-2026-nonbinary, and replicate his study of Walmart and county retail employment.
## Two periods
We observe units $i = 1, \dots, n$ in two periods, $t = 1, 2$. Nobody is treated in period 1. Before period 2, each unit receives a dose $D_i \ge 0$, and units with $D_i = 0$ stay untreated. For each dose $d$, unit $i$ has a potential outcome $Y_{it}(d)$, and we observe $Y_{it} = Y_{it}(D_i)$. No anticipation means $Y_{i1}(d) = Y_{i1}(0)$ for every $d$. Let $\Delta Y_i = Y_{i2} - Y_{i1}$.
There are two natural estimands. Take two doses $d$ and $d'$. The first estimand, $ATT(d \mid d')$, is the average effect of dose $d$, relative to no treatment, among the units that actually received dose $d'$:
$$ATT(d \mid d') = E[Y_{i2}(d) - Y_{i2}(0) \mid D_i = d'].$$ {#eq-dc-att}
The leading case is $ATT(d \mid d)$, the effect of each group's own dose. The second estimand, $ATE(d)$, is the effect of dose $d$ averaged over all treated units, whatever dose they received:
$$ATE(d) = E[Y_{i2}(d) - Y_{i2}(0) \mid D_i > 0].$$ {#eq-dc-ate}
Its derivative $ATE'(d)$ is the average causal response at $d$: the average effect of a small increase in the dose.
### Parallel trends
The first assumption is parallel trends. With a dose it says that, without treatment, every dose group would have followed the trend of the untreated:
$$E[Y_{i2}(0) - Y_{i1}(0) \mid D_i = d] = E[Y_{i2}(0) - Y_{i1}(0) \mid D_i = 0] \quad \text{for all } d.$$ {#eq-dc-pt}
In words, the change in the untreated potential outcome between periods 1 and 2 is the same at every dose, including zero. The assumption restricts untreated outcomes only. Under @eq-dc-pt and no anticipation,
$$E[\Delta Y_i \mid D_i = d] - E[\Delta Y_i \mid D_i = 0] = ATT(d \mid d).$$ {#eq-dc-id}
This is the binary DiD done separately at each dose. Parallel trends identifies the whole curve $ATT(d \mid d)$, each dose group's effect of its own dose. With more periods before treatment we can check it in the usual way: the dose groups should have moved together before anyone was treated.
Parallel trends does not identify comparisons across doses. For the two doses $d$ and $d'$,
$$ATT(d \mid d) - ATT(d' \mid d') = \underbrace{ATT(d \mid d) - ATT(d' \mid d)}_{\text{causal response}} + \underbrace{ATT(d' \mid d) - ATT(d' \mid d')}_{\text{selection on gains}}.$$ {#eq-dc-decomp}
The first term is causal. It is what moving the dose from $d'$ to $d$ does for the units that chose $d$. The second term compares two groups at the same dose $d'$. It is non-zero when the units that chose $d$ would gain differently from dose $d'$ than the units that chose $d'$. Parallel trends says nothing about this term, and pre-treatment data cannot reveal it, because it involves treated outcomes. So the slope of the curve in @eq-dc-id mixes the causal response with selection on gains.
### Strong parallel trends
The second assumption changes the comparison so that the selection term no longer enters. CGBS call it strong parallel trends:
$$E[Y_{i2}(d) - Y_{i1}(0) \mid D_i = d] = E[Y_{i2}(d) - Y_{i1}(0) \mid D_i > 0] \quad \text{for all } d > 0.$$ {#eq-dc-spt}
In words, the average path from untreated in period 1 to dose $d$ in period 2 is the same for the units that chose $d$ as for all treated units. Together with @eq-dc-pt it gives $ATT(d \mid d) = ATE(d)$ for every $d$: each dose group's own-dose effect equals the effect of that dose averaged over all treated units. The identified curve is then $ATE(d)$, and a comparison across doses, $ATE(d) - ATE(d')$, sets two doses for the same population, so it is causal. Its slope is the average causal response of the treated population. This does not make the selection term in @eq-dc-decomp zero group by group. The group that chose $d$ can still respond to dose $d'$ differently from the group that chose $d'$; strong parallel trends only rules this out on average. For example, with three equally likely dose groups and zero untreated outcomes, let row $g$ of the matrix below give the effects of doses 1, 2 and 3 for the group that chose dose $g$:
$$\begin{pmatrix} 1 & 0 & 0 \\ 0 & 2 & 6 \\ 2 & 4 & 3 \end{pmatrix}.$$
The diagonal and the column means are both $(1, 2, 3)$, so $ATT(d \mid d) = ATE(d)$ at every dose. Yet for the group that chose dose 2, moving from dose 1 to dose 2 is worth 2, while the identified contrast is 1.
Strong parallel trends is a stronger assumption than parallel trends, and of a different kind. It restricts treated potential outcomes, so no pre-treatment data can check it, and passing a pre-trend test says nothing about it. It restricts how units choose their dose. It is plausible when the dose is set for reasons unrelated to the gain, for example by a formula or a lottery. It is hard to defend when units choose their dose knowing what they will gain.
@wooldridge-2026-nonbinary reaches the same point from a regression. Let $B_i$ be the gain of unit $i$ from one unit of dose, so that the effect is linear in the dose with a slope that varies across units: $Y_{i2}(d) = Y_{i2}(0) + d B_i$. Let $\gamma = E[Y_{i2}(0) - Y_{i1}(0)]$ be the untreated trend, and let $\delta = E(B_i \mid D_i > 0)$ be the average slope among the treated. Under @eq-dc-pt,
$$E(\Delta Y_i \mid D_i) = \gamma + \delta D_i$$ {#eq-dc-linear}
holds when $E(B_i \mid D_i = d) = \delta$ for every $d > 0$. That condition is strong parallel trends for the linear model. Adding powers of $D_i$ to the regression relaxes the linearity.
## Staggered adoption
Now units enter treatment at different times, as in the ETWFE section of the DiD chapter. Periods run $t = 1, \dots, T$, and the first period in which any unit is treated is $q$. A cohort $g \in \{q, \dots, T\}$ is the set of units first treated in period $g$. Let $D_{ig} = 1$ if unit $i$ is in cohort $g$, and $D_{ig} = 0$ otherwise. Never-treated units have $D_{ig} = 0$ for every $g$. The vector $\mathbf D_i = (D_{iq}, \dots, D_{iT})$ collects unit $i$'s cohort dummies. For each period $s$, the time dummy $fs_t$ equals 1 if $t = s$ and 0 otherwise.
The treatment $\mathbf W_{it}$ is a $1 \times J$ row vector, where $J$ is the number of treatment variables. A single dose has $J = 1$. A dose and its square has $J = 2$. A set of mutually exclusive treatment levels has $J$ equal to the number of levels. Every unit has $\mathbf W_{it} = \mathbf 0$ before its entry period, and $\mathbf W_i$ stacks unit $i$'s rows over all $T$ periods. We write $\mathbf w$ for a possible value of $\mathbf W_{it}$. The dose may change after entry. In the Walmart data it is the number of stores open.
@wooldridge-2026-nonbinary writes potential outcomes as linear in the treatment, with slopes that vary by unit and period. Let $\mathbf B_{it}$ be a $J \times 1$ vector of random slopes, whose $j$-th element is unit $i$'s gain in period $t$ from one unit of treatment variable $j$. Let $\gamma_t$ be a time effect, $C_i$ an unobserved unit effect, and $U_{it}$ an idiosyncratic error. The potential outcome at treatment value $\mathbf w$ is
$$Y_{it}(\mathbf w) = \mathbf w\, \mathbf B_{it} + \gamma_t + C_i + U_{it}.$$ {#eq-dc-po}
For a single dose, $J = 1$, write the scalar dose as $w$. Subtracting the untreated potential outcome cancels the time effect, the unit effect and the error:
$$Y_{it}(w) - Y_{it}(0) = w\, B_{it}.$$ {#eq-dc-diff}
So $B_{it}$ is the difference in potential outcomes per unit of dose. With several treatment variables, the $j$-th element of $\mathbf B_{it}$ is the change in the potential outcome from one more unit of treatment variable $j$, holding the others fixed. The additive $\gamma_t + C_i$ is parallel trends. Nothing restricts $\mathbf B_{it}$. The estimand is its mean for each cohort and period:
$$\boldsymbol\delta_{gs} = E(\mathbf B_{is} \mid D_{ig} = 1), \qquad s \ge g.$$ {#eq-dc-delta}
In words, $\boldsymbol\delta_{gs}$ is the average effect per unit of each treatment variable for cohort $g$ in period $s$. Because the potential outcome is linear in the dose, it is also the effect of one more unit at any dose: going from 0 to 1 has the same effect as going from 1 to 2. Adding powers of the dose, or dummies for dose levels, to $\mathbf W_{it}$ relaxes this. With a binary treatment, $\boldsymbol\delta_{gs}$ is the cohort-period ATT of ETWFE.
Wooldridge assumes no anticipation and strict exogeneity. Strict exogeneity says the error $U_{it}$ has mean zero given the whole treatment path $\mathbf W_i$, the unit effect $C_i$ and the slopes $\mathbf B_{it}$. He needs one more assumption, which has no counterpart in the binary case. He calls it limited selection:
$$E(\mathbf B_{it} \mid \mathbf W_i) = E(\mathbf B_{it} \mid \mathbf D_i).$$ {#eq-dc-ls}
Once we know when a unit entered, its dose path carries no information about its average gain. With a binary treatment the entry date fixes the whole treatment path, so @eq-dc-ls holds automatically. With two periods and a scalar dose it is the strong parallel trends of @eq-dc-spt in its linear form. Parallel trends enters through the additive $\gamma_t + C_i$ in @eq-dc-po. So the staggered estimates rest on the same two assumptions as the two-period ones.
Let $A_i = E(C_i \mid \mathbf W_i)$ be the mean of the unit effect given the treatment path. Under these assumptions,
$$E(Y_{it} \mid \mathbf W_i) = \sum_{g=q}^{T} \sum_{s=g}^{T} (D_{ig}\, fs_t\, \mathbf W_{it})\, \boldsymbol\delta_{gs} + \gamma_t + A_i.$$ {#eq-dc-reg}
$A_i$ is a unit effect. So a two-way fixed effects (TWFE) regression of $Y_{it}$ on the interactions $D_{ig}\, fs_t\, \mathbf W_{it}$, with unit and time effects, estimates every $\boldsymbol\delta_{gs}$. This is ETWFE with the treatment indicator replaced by the dose. Standard errors are clustered by unit.
There are many cohort-period slopes, so we aggregate them. Let $e$ be the exposure time, the number of periods since entry, and let $N_g$ be the number of units in cohort $g$. Let $\hat{\boldsymbol\delta}_{gs}$ be the TWFE estimate of $\boldsymbol\delta_{gs}$. The estimated effect at exposure $e$, written $\hat{\boldsymbol\tau}_{e}$, averages over the cohorts observed that long, with weights proportional to cohort size:
$$\hat{\boldsymbol\tau}_{e} = \sum_{g=q}^{T-e} \frac{N_g}{N_q + \dots + N_{T-e}}\, \hat{\boldsymbol\delta}_{g,g+e}.$$ {#eq-dc-agg}
The overall effect weights every cohort-period slope by $N_g$. In a balanced panel it is the average slope over all treated unit-periods.
Pre-trends can be tested in two ways. A lead is a dummy $D_{ig}\, fs_t$ for a period $s$ before cohort $g$ enters. The first test fits TWFE on the untreated observations only, the unit-periods with $\mathbf W_{it} = \mathbf 0$, with leads for $s \le g - 2$, so that the period just before entry is the base. It then tests whether the leads are zero. The second test adds the same leads to @eq-dc-reg. With a binary treatment the two give identical estimates. With a dose they differ. Both tests check parallel trends. Neither checks limited selection. When the leads show a trend, Wooldridge adds cohort-specific linear trends to @eq-dc-reg. For each cohort $g$, the regressor $D_{ig} \cdot t$ is a linear time trend for that cohort only. The assumption then becomes that each cohort's gap from the never-treated units would have kept growing along the same line after entry.
## Wooldridge's regression and the CGBS estimator
The two approaches target the same objects. Under parallel trends and strong parallel trends, each identifies the average effect of the dose for every cohort and period. They differ in how they estimate it and in what they can handle.
The first difference is the comparison group. Wooldridge runs one TWFE regression in levels on all periods, @eq-dc-reg. Every untreated observation serves as a control: the never-treated units, the not-yet-treated units, and the pre-entry periods of every cohort. In the binary case this regression is the imputation estimator of @borusyak-jaravel-spiess-2024. @callaway-goodman-bacon-santanna-2024 build on @callaway-santanna-2021 instead. For each cohort and period they compare the cohort with the never-treated or the not-yet-treated units, using the long difference from the period just before entry, and fit the dose response in that comparison. The regression uses more data, and it is more efficient when the errors are homoskedastic and serially uncorrelated. In exchange it needs parallel trends in every pre-entry period. The differencing approach needs it only from the base period on.
The second difference is the shape of the dose response. In Wooldridge's regression, the shape comes from the functions of the dose placed in $\mathbf W_{it}$: the dose itself, its powers, or dummies for dose levels. The estimand is the average slope $\boldsymbol\delta_{gs}$. CGBS fit a B-spline in the dose within each cohort and period, or a nonparametric curve whose complexity is chosen from the data. They report the curve $ATT(d \mid d)$ and its derivative. The two also treat a dose near zero differently. With two periods, Wooldridge's regression has no separate intercept for the treated units, so its fitted effect goes to zero as the dose goes to zero. The CGBS fit gives the treated units their own intercept, so the effect can jump at any positive dose. The two coincide once a dummy for a positive dose is added to $\mathbf W_{it}$.
The third difference is scope. The table compares Wooldridge's regression with the R package `contdid`, version 0.1.1, which implements CGBS.
| | Wooldridge (2026) | `contdid` 0.1.1 |
|---|---|---|
| Dose changes after entry | Yes | No |
| Covariates | Yes, in the trends and in the slopes | No |
| Cohort-specific trends | Yes | No |
| Unbalanced panel | Yes | No |
| Multi-level or vector treatment | Yes, through $\mathbf W_{it}$ | No |
| Exit from treatment | Yes | No |
| Standard errors | Analytic, clustered by unit | Multiplier bootstrap |
| Reported effects | Average slopes by cohort and period, aggregated by exposure | $ATT(d \mid d)$ and its derivative, aggregated by dose or by exposure |
The first row decides the Walmart application. The number of stores changes after entry, so the CGBS estimator, as implemented, does not apply. The other rows show what the single regression adds: covariates, trends, exit and missing years enter as extra terms. In the other direction, CGBS trace out the whole dose-response curve within each cohort and period. Wooldridge reports average slopes and needs powers of the dose to show curvature.
## Walmart and county retail employment
@wooldridge-2026-nonbinary applies the method to the county panel of @brown-butts-2025. It covers 1,288 counties from 1977 to 1999. No county had a Walmart before 1986. Stores then opened in 14 cohorts, from 1986 to 1999, and 395 counties never got one. The treatment is a single dose, so $J = 1$ and we write it without bold: $W_{it}$ is the number of Walmarts open in county $i$ in year $t$. The outcome is log retail employment.
```{r dc-wm-load, cache=TRUE}
# extract of walmart_lw.dta from Wooldridge's replication files (data/gen_walmart_lw.R)
wm <- fread("data/walmart_lw.csv")
wm[year == 1999, .N, by = .(cohort)][order(cohort)]
wm[n_open > 0, .N, by = n_open][order(n_open)][, share := round(N / sum(N), 3)][]
```
Most treated counties have a single store. One store accounts for 80% of treated county-years, two for 13%, and the largest count is 13. Within a cohort and year, the slope is fit from the change relative to untreated counties and from the differences in store counts. With so many single-store counties, it mostly measures the effect of the first store.
A single-coefficient TWFE regression is the natural starting point.
```{r dc-wm-twfe, cache=TRUE}
coeftable(feols(log_retail_emp ~ n_open | fips + year, wm, cluster = ~fips))
```
One more Walmart raises retail employment by 3.4%, with a standard error of 0.57 percentage points. In the binary case this regression makes forbidden comparisons, which use already-treated units as controls, when effects vary by cohort and time. The same holds with a dose. So we build the regressors of @eq-dc-reg, one for each cohort and year from entry on: $W_{it}$ times the cohort dummy times the year dummy.
```{r dc-wm-cells, cache=TRUE}
cohorts <- 1986:1999
cells <- CJ(g = cohorts, s = cohorts)[s >= g]
wcols <- sprintf("w_%d_%d", cells$g, cells$s)
for (k in seq_len(nrow(cells)))
set(wm, j = wcols[k],
value = (wm$cohort == cells$g[k]) * (wm$year == cells$s[k]) * wm$n_open)
trcols <- sprintf("tr_%d", cohorts)
for (k in seq_along(cohorts))
set(wm, j = trcols[k], value = (wm$cohort == cohorts[k]) * wm$year)
fit_het <- feols(log_retail_emp ~ ..("^w_") | fips + year, wm, cluster = ~fips)
length(coef(fit_het))
```
That gives 105 slopes. We aggregate them with @eq-dc-agg. Each aggregate is a linear combination of the slopes with fixed weights, so its standard error comes from the clustered covariance matrix. This matches Stata's `margins` in Wooldridge's code.
```{r dc-wm-agg, cache=TRUE}
Ng <- wm[year == 1999 & cohort > 0, .N, by = cohort]
setkey(Ng, cohort)
aggregate_slopes <- function(fit) {
b <- coef(fit)[wcols]; V <- vcov(fit)[wcols, wcols]
lincomb <- function(a) c(estimate = sum(a * b), se = sqrt(drop(t(a) %*% V %*% a)))
by_e <- t(sapply(0:13, function(e) {
gs <- cohorts[cohorts + e <= 1999]
a <- setNames(numeric(length(wcols)), wcols)
a[sprintf("w_%d_%d", gs, gs + e)] <- Ng[J(gs)]$N / sum(Ng[J(gs)]$N)
lincomb(a)
}))
a_all <- Ng[J(cells$g)]$N
rbind(by_e, overall = lincomb(a_all / sum(a_all)))
}
agg_het <- aggregate_slopes(fit_het)
```
Before reading the effects, we check pre-trends. Following the first test above, we fit TWFE on the untreated county-years with a lead for each cohort and each year at least two years before entry. We then average the leads by years until entry, with the cohort weights of @eq-dc-agg.
```{r dc-wm-pre, cache=TRUE, fig.width=7, fig.height=3.6}
#| fig-cap: "Weighted pre-treatment estimates from the untreated observations, with 95% intervals. The year before entry is the base."
un <- wm[n_open == 0, .(fips, year, cohort, log_retail_emp)]
leads <- CJ(g = cohorts, s = 1977:1999)[s <= g - 2]
lcols <- sprintf("l_%d_%d", leads$g, leads$s)
for (k in seq_len(nrow(leads)))
set(un, j = lcols[k], value = (un$cohort == leads$g[k]) * (un$year == leads$s[k]))
fit_pre <- feols(log_retail_emp ~ ..("^l_") | fips + year, un, cluster = ~fips)
b <- coef(fit_pre); V <- vcov(fit_pre)
pre <- rbindlist(lapply(2:22, function(k) {
gs <- cohorts[cohorts - k >= 1977]
a <- setNames(numeric(length(b)), names(b))
a[sprintf("l_%d_%d", gs, gs - k)] <- Ng[J(gs)]$N / sum(Ng[J(gs)]$N)
data.table(time = -k, estimate = sum(a * b), se = sqrt(drop(t(a) %*% V %*% a)))
}))
ggplot(pre, aes(time, estimate)) +
geom_hline(yintercept = 0) +
geom_pointrange(aes(ymin = estimate - 1.96 * se, ymax = estimate + 1.96 * se),
colour = "darkcyan") +
labs(x = "Years until first Walmart", y = "Log retail employment") +
theme_bw()
```
The leads fall almost linearly as we go back in time. Twenty years before entry, counties that later got a Walmart had retail employment about 19 log points lower, relative to the year before entry, than the never-treated counties. Retail employment was growing faster in these counties long before any store opened. Parallel trends fails, so Wooldridge also reports estimates with the cohort-specific linear trends.
```{r dc-wm-trend, cache=TRUE}
fit_trend <- feols(log_retail_emp ~ ..("^w_") + ..("^tr_") | fips + year,
wm, cluster = ~fips)
agg_trend <- aggregate_slopes(fit_trend)
tab <- data.table(exposure = c(0:13, "overall"),
no_trends = sprintf("%.4f (%.4f)", agg_het[, 1], agg_het[, 2]),
cohort_trends = sprintf("%.4f (%.4f)", agg_trend[, 1], agg_trend[, 2]))
knitr::kable(tab, col.names = c("Exposure", "No trends", "Cohort trends"),
align = "lrr")
```
The table reproduces Table 7.1 of @wooldridge-2026-nonbinary, estimates and standard errors, to all four decimals.
Without trends, one more store raises retail employment by about 3% to 4% in the first years. The effect climbs to 9% by year 13. The overall effect is 0.0386 (0.0051). It is close to the single-coefficient TWFE estimate of 0.0344, and a little more precise.
The cohort trends change the estimates a lot. The effect in the entry year is 0.0049 (0.0033), indistinguishable from zero. From the entry year to year 6, the effects are between a sixth and a half of their values without trends. They then rise steadily, and by year 13 the two columns agree at about 0.09. The overall effect falls to 0.0156 (0.0046), less than half the estimate without trends. The trends also make the estimates more precise up to about year 8. The long exposures rest on the earliest cohorts only, so their standard errors grow. Year 13 comes from the 1986 cohort alone.
For comparison, we add the same 14 cohort trends to the single-coefficient regression. One slope on the store count is then shared by every cohort and year.
```{r dc-wm-twfe-trend, cache=TRUE}
coeftable(feols(log_retail_emp ~ n_open + ..("^tr_") | fips + year,
wm, cluster = ~fips))["n_open", ]
```
With the same trends, the single-coefficient regression gives 0.0100 (0.0045). The flexible model costs almost nothing in precision.
The table averages over cohorts. To see the path of a single cohort, we take the 1990 cohort, the largest, with 118 counties and ten years after entry. Under @eq-dc-po, with $J = 1$, the effect of $w$ stores on cohort $g$ in year $s$ is $w\,\delta_{gs}$. The figure plots the estimated effect of one store, $\hat\delta_{1990,s}$, for each year after entry, with and without cohort trends. The effect of two stores is twice as large in every year, because the model is linear in the dose.
```{r dc-wm-cohort, cache=TRUE, fig.width=7, fig.height=3.6}
#| fig-cap: "Effect of one Walmart on log retail employment in the 1990 cohort, by year since entry, with 95% intervals."
g0 <- 1990
nm <- sprintf("w_%d_%d", g0, g0:1999)
path <- rbindlist(lapply(list(`No trends` = fit_het, `Cohort trends` = fit_trend),
function(f) data.table(e = 0:9, estimate = coef(f)[nm], se = se(f)[nm])),
idcol = "model")
ggplot(path, aes(e, estimate, colour = model)) +
geom_hline(yintercept = 0) +
geom_pointrange(aes(ymin = estimate - 1.96 * se, ymax = estimate + 1.96 * se),
position = position_dodge(width = 0.4)) +
scale_x_continuous(breaks = 0:9) +
labs(x = "Years since the first Walmart opened", y = "Effect of one store", colour = NULL) +
theme_bw() + theme(legend.position = "bottom")
```
Without trends, one store raises retail employment in the 1990 cohort by 1.7% in the entry year and by 4.0% a year later, and the effect then settles near 2.7%. From year 1 on, the estimates are about twice their standard errors or more. With cohort trends the path is lower, and the gap grows from 0.6 percentage points in the entry year to 1.6 by year 9. Only the year-1 estimate, 3.1%, is more than twice its standard error. The growing gap is what we would see if the cohort trend, which is also fit on post-entry years, absorbs part of an effect that grows with exposure. The plot holds the dose at one store. The cohort's average number of stores rises from 1.08 in 1990 to 1.75 in 1999, so the effect it actually experienced grows faster than the plotted per-store effect.
Cohort trends are one response to the failed pre-test, and they are fit on all
years, so they can absorb part of a growing effect, as above. @rambachan-roth-2023
offer another: bound how far the post-entry violation of parallel trends can
depart from the pre-entry trend, and report the confidence set for the effect
that is valid under that bound. Their method needs pre- and post-entry
estimates from one regression with a joint covariance matrix. The dose
regression above does not provide them in a common unit, so we apply it to the
event study of store entry, fit by @sun-abraham-2021 on the same data. Most
counties open one store at entry, so the entry effect is close to the effect of
the first store. We use the five leads from six to two years before entry and
the first six years after. The smoothness restriction with $M = 0$ says that the
pre-entry trend continues on a straight line after entry; larger $M$ lets the
slope of the violation change by up to $M$ per year.
```{r dc-wm-honest, cache=TRUE, warning=FALSE, message=FALSE}
library(HonestDiD)
# Event study of first entry; never-treated counties get a cohort outside the panel
wm[, cohort_sa := fifelse(cohort == 0, 10000L, as.integer(cohort))]
es <- feols(log_retail_emp ~ sunab(cohort_sa, year) | fips + year, wm, cluster = ~fips)
et <- as.integer(sub("year::", "", names(coef(es))))
keep <- c(which(et >= -6 & et <= -2), which(et >= 0 & et <= 5))
bh <- coef(es)[keep]; sg <- vcov(es)[keep, keep]
round(bh, 4)
# Confidence sets for the entry-year effect under DeltaSD(M)
orig <- constructOriginalCS(betahat = bh, sigma = sg,
numPrePeriods = 5, numPostPeriods = 6)
sens <- createSensitivityResults(betahat = bh, sigma = sg,
numPrePeriods = 5, numPostPeriods = 6,
Mvec = c(0, 0.005, 0.01), method = "C-LF")
rbind(orig[, c("lb", "ub")], sens[, c("lb", "ub")])
```
The leads repeat the pre-trend test: relative to the year before entry, retail
employment in future Walmart counties is 3.5 log points lower six years before
and 0.3 lower two years before, a steady rise. The entry-year effect is 0.025
with a conventional 95% interval of $[-0.024, 0.074]$. Allowing the pre-entry
trend to continue on a straight line, $M = 0$, widens the interval to
$[-0.12, 0.17]$, and allowing the trend to bend by up to 0.01 per year widens it
slightly more. Under the trend we see before entry, the data cannot tell whether
the first year's effect is positive. This agrees with the cohort-trend estimate
of 0.0049 (0.0033) for the entry year, and it reaches that conclusion without
fitting the trend on the post-entry years.
## Summary
Wooldridge's method is ETWFE with the treatment indicator replaced by the dose. The regression in @eq-dc-reg interacts cohort, year and dose. Each interaction has its own slope $\boldsymbol\delta_{gs}$, the average effect of one more unit of dose for cohort $g$ in year $s$, and the slopes are averaged by exposure time. Covariates, cohort trends, exit and unbalanced panels enter as extra terms in the same regression.
Two assumptions identify the slopes. Parallel trends lets us compare each cohort's change with the change of the untreated units, and the pre-trend tests check it. Strong parallel trends, which Wooldridge's limited selection extends to staggered adoption, says the dose a unit ends up with tells us nothing about its average gain. It makes comparisons across doses causal, and no test in the data checks it. In the Walmart data parallel trends fails, so we add cohort trends, and the overall effect of one more store falls from 3.9% to 1.6%.