Consider a randomized experiment in two strata of 100 units each. In stratum A each unit is treated with probability 0.8, and in stratum B with probability 0.2. Untreated units have outcome 10 in A and 0 in B, and treatment raises the outcome by 1 for everyone. In a typical draw 80 units in A and 20 in B are treated. The treated then have mean \((80 \times 11 + 20 \times 1)/100 = 9\), and the controls \((20 \times 10 + 80 \times 0)/100 = 2\). The difference in means is 7, although every effect is 1. Assignment is random, but A is treated more often and has higher outcomes anyway, and the comparison mixes the two.
The usual fix is to compare treated and control units within each stratum, or to control for the stratum. There is another way to see it. Let \(D_i\) be unit \(i\)’s treatment and \(p_i\) its assignment probability, 0.8 or 0.2. The difference \(D_i - p_i\) averages zero within each stratum, so it is uncorrelated with anything fixed within a stratum, including the baseline outcome. In this draw, using \(D_i - p_i\) as the instrument for \(D_i\) gives exactly 1, and so does controlling for \(p_i\).
Many treatments are computed from a formula that combines a random shock with non-random exposure. Medicaid eligibility is a state’s rules applied to a person’s income. Import exposure is national industry shocks applied to a region’s industry mix. The Bartik instrument of the previous chapter is one such formula. These treatments have the structure of the stratified experiment: units with more exposure expect more treatment in every draw, as stratum A did. Here the stratum is the exposure itself, such as income or a region’s industry shares. It is continuous, so no two units share one and we cannot compare within strata. The expected value of the formula reduces it to one number, as a propensity score does, and plays the role of the assignment probability. This chapter covers the general version of Borusyak and Hull (Borusyak and Hull 2023), their result on which formula is best (Borusyak and Hull 2026), and what both mean for shift-share.
19.1 Formula instruments
Unit \(i\) has outcome \(y_i\) and treatment \(x_i\), with a constant effect \(\beta\):
\[
y_i = \beta x_i + \varepsilon_i .
\tag{19.1}\]
The treatment is \(x_i = h_i(g, w, u)\), where \(h_i\) is a known function, \(g\) collects the random shocks, \(w\) collects predetermined variables such as income or industry shares, and \(u\) collects anything else. The identifying assumption puts all the randomness on the shocks (Borusyak and Hull 2026, Assumption 1):
The error may depend on \(w\) in any way. Poorer people may have worse outcomes, and regions with more manufacturing may have been declining anyway. We need exogeneity of the shocks, not of the exposure.
A formula instrument is \(z_i = f_i(g, w)\) for a fixed function \(f_i\). Its expected value over the shock draws that could have occurred, holding \(w\) fixed, is the expected instrument \(\mu_i = E[z_i \mid w]\). The average is over draws for the same unit, not over units. In the stratified experiment \(\mu_i\) is the assignment probability \(p_i\). The recentered instrument \(\tilde z_i = z_i - \mu_i\) therefore averages zero over the draws for every unit, \(E[\tilde z_i \mid w] = 0\). It is valid, because by iterated expectations and Equation 19.2,
Without recentering the same steps give \(E[z_i \varepsilon_i] = E[\mu_i
E[\varepsilon_i \mid w]]\), which is not zero when the expected instrument is correlated with the predictable part of the error. We can also keep \(z_i\) as the instrument and control for \(\mu_i\). In the population the regression of \(z_i\) on \(\mu_i\) has slope one and intercept zero, so its residual is \(z_i - \mu_i\) and the two approaches use the same variation. In a sample the fitted slope is not exactly one, and the estimates differ.
The work is in computing \(\mu_i\), and it takes three steps in every application below. First, state the shocks and the design: how they could have been drawn. Second, apply the formula to each possible draw, holding the unit’s \(w\) fixed. Third, average over the draws, weighting each by its probability. When the design has many draws, we simulate them, or permute the shocks if they are exchangeable, and take the mean. When the formula is linear in the shocks, the second and third steps reduce to applying the formula to the expected shocks. When it is not, they do not, and we have to average.
When the instrument is the treatment itself, as eligibility in the simulation and spillover exposure in the deworming example are, \(\mu_i\) is also the expected treatment given \(w\). If that treatment is binary, as eligibility is, \(\mu_i\) is a design-based propensity score: the probability of treatment given \(w\), computed from the design. When the instrument differs from the treatment, as Bartik differs from US import exposure in the China-shock application, \(\mu_i\) is the expected instrument, and it is not the expected treatment. In each case \(\mu_i\) differs from the propensity score of an observational study in three ways. It is computed from the formula and the design, like the known assignment probability of a stratified experiment, and not estimated from a model of treatment on covariates. It is used by subtracting it, as the expected treatment is in the partially linear model, and not as a weight. And the assumption is about the shocks. We assume nothing about how \(w\) affects the outcome, so \(z_i - \mu_i\) is uncorrelated with every fixed characteristic, measured or not.
Recentering and instrumenting fix two different problems. Recentering removes the bias from fixed exposure: some units expect a larger treatment in every draw. When the treatment is the formula itself, \(x_i = h_i(g, w)\), as eligibility in the simulation and spillover exposure in the deworming example are, this is the only problem, and OLS controlling for \(\mu_i\) is enough. When the treatment also depends on \(u\), it can be endogenous through \(u\) even given \(\mu_i\). In ADH, US imports also respond to US demand. We then need an instrument built from the shocks alone, such as Bartik with imports into other countries, and that instrument is itself recentered, or its expected value controlled for. ADH need both fixes, and the simulation and deworming need only the first. The expected value itself is never the instrument. It is the part predictable from exposure, the part that can be correlated with the error.
Any recentered formula is valid, so we can pick the most precise. Borusyak and Hull (2026, Theorem 1) show it starts from the best prediction of the treatment, recentered:
Among recentered formulas it has the strongest first stage (Borusyak and Hull 2026, Lemma 1). The full optimal instrument adds two refinements, partly controlling for the predictable part of the error and GLS weighting, which need a model of the error. The authors drop them. Their algorithm predicts the treatment from its formula, recenters the prediction by redrawing the shocks, and uses the result as the instrument. When \(x_i\) depends only on \((g, w)\), the prediction is \(x_i\) itself.
19.2 Shift-share as a formula instrument
The Bartik instrument \(B_\ell = \sum_k s_{\ell k} g_k\) of Equation 18.2 is the linear formula, shares times shocks. It differs from Equation 19.3 in two ways.
The first is recentering. The three steps give the expected instrument. The shocks are the industry shocks \(g_k\), and suppose they are exchangeable within period \(t\): any reshuffling of them across industries is equally likely. Each industry’s expected shock is then the period mean \(\bar g_t\). The formula is linear, so its average is the shares times \(\bar g_t\). Let \(S_\ell = \sum_k s_{\ell k}\) be region \(\ell\)’s sum of shares. Then
\[
\mu_\ell = S_\ell\, \bar g_t .
\tag{19.4}\]
If the shares sum to one, \(\mu_\ell = \bar g_t\) is common to all regions and period effects absorb it, so Bartik is already recentered. If they are incomplete, as with manufacturing shares, heavily manufacturing regions get a large instrument in every draw, and under the shock view Bartik is biased unless we control for \(S_\ell\) interacted with period (Borusyak, Hull, and Jaravel 2022).
The second is the formula. Recentering and choosing a formula are separate decisions. Take two regions with half their employment in electronics, and an import shock to electronics. Region A’s plants compete with Chinese imports. Region B’s make military components and do not. Bartik gives both half the shock, but only A’s import competition rises, so the instrument varies where the treatment does not. The best predictor gives A half the shock and B nothing, then recenters each by its own expected value. Once recentered, both instruments are valid, and the second has the stronger first stage. When the treatment really is shares times shocks, the best predictor is Bartik itself and the two differ only by recentering. The formula matters when the treatment has more structure than Bartik uses: eligibility rules, export exposure, transport networks, nonlinear indices.
Table 19.1: Shift-share and recentered formula instruments.
Shift-share (Bartik)
Recentered formula instrument
Formula
Shares times shocks
Best prediction of the treatment
Expected instrument
Usually not subtracted
Subtracted, or controlled for
Shock design
Implicit
Written down to compute \(\mu_\ell\)
Inputs
Shares and shocks
Treatment formula and shock design
The formula instrument needs more inputs: the treatment’s formula and an explicit shock design. With heterogeneous effects, different instruments weight units differently, so a gain in precision is a gain for a different weighted average (Borusyak and Hull 2026, Proposition D1).
19.2.1 Why recenter
Bartik needs one of two assumptions. If the shares are as good as random given the controls (Goldsmith-Pinkham, Sorkin, and Swift 2020), Bartik is valid as it stands and recentering is not needed. If only the shocks are random (Borusyak, Hull, and Jaravel 2022), the shares may be correlated with the error. Writing each shock as the mean shock plus a deviation splits the instrument in two:
The first part is the expected instrument of Equation 19.4. It depends only on how much exposure the region has, so with incomplete shares a region with more exposure gets a larger value in every draw, and this part is correlated with the error whenever exposure is. The second part depends on whether the region’s industries received larger or smaller shocks than average. If the shocks are independent of the shares and the errors, the deviations average to zero whatever the shares are, so this part is uncorrelated with the error. Recentering keeps only the second part. When the shares sum to one, the first part is \(\bar g_t\) for every region and the period effects absorb it.
This gives the formula instrument four advantages. Its validity rests only on the shocks, such as a policy choice or a foreign supply shock, which are often easier to defend than the shares. The design has to be written down, so the assumption is explicit and can be varied, as the two ADH designs below show. The instrument can use exposure to gain power, because the best predictor tracks the treatment more closely than a shock-only index. And it is not tied to a linear formula or to independent units: it covers eligibility rules, networks and nonlinear indices, with shocks shared by many units.
19.3 Simulation
The aim is to compare a shock-only instrument with the recentered treatment when we know the true effect. There are 50 states and 10,000 people. Person \(i\) lives in state \(s(i)\) and has income \(\text{inc}_i\), in multiples of the poverty line, drawn from a log-normal distribution with median 1.4. The shock is the states’ policy: each state \(k\) draws an eligibility threshold \(T_k\) from \(\{0.5, 1, 1.38, 2\}\), each value with probability 1/4, independently across states. Eligibility and the outcome are
where \(\alpha_k \sim N(0, 0.3^2)\) is a state effect and \(\nu_i \sim N(0, 1)\). The true effect is 0.3. In the notation of Equation 19.2, the shocks \(g\) are the 50 thresholds and the predetermined variables \(w\) are the incomes and states. Poorer people are more often eligible and have higher errors, so eligibility is correlated with the error through income and OLS is biased upward. The thresholds are drawn independently of incomes and errors, so Equation 19.2 holds.
Expected eligibility follows the three steps. The shocks are the thresholds, and the design gives each of the four values probability 1/4. The formula is \(x_i = 1[\text{inc}_i < T_{s(i)}]\). Applying it to each threshold, holding income fixed, and averaging gives \(\mu_i\), the probability that person \(i\) is eligible. It is the share of the four thresholds above their income: 1 below 0.5, 0.75 between 0.5 and 1, 0.5 between 1 and 1.38, 0.25 between 1.38 and 2, and 0 above 2. It depends on income only, because every state draws from the same four values. Given income, the recentered treatment \(x_i - \mu_i\) moves only with the draw, which is why it is exogenous. A person with income 1.2 has \(\mu_i = 0.5\). The instrument is 0.5 if their state drew 1.38 or 2 and −0.5 if it drew 0.5 or 1, with equal chance whatever their error. People below 0.5 or above 2 always have zero and carry no identifying variation. The formula is not linear, so \(\mu_i\) is not eligibility at the mean threshold, 1.22. That would make the person with income 1.2 eligible for sure, while their \(\mu_i\) is 0.5.
We compare four estimators, all with standard errors clustered by state.
OLS of \(y_i\) on \(x_i\). This is the same as instrumenting \(x_i\) with itself, the best predictor without recentering. It is biased.
The simulated instrument of Currie and Gruber (1996). They apply each state’s rules to one fixed national sample and use the share of that sample who would be eligible as the state’s instrument. The same population is run through every state’s rules, so the instrument measures the generosity of the rules and not the composition of the state’s residents. Here the national sample is all 10,000 people, and everyone in a state gets the same value. It is valid.
The recentered treatment, instrumenting \(x_i\) with \(x_i - \mu_i\). It varies within states, among people whose income lies between the lowest and highest thresholds. It is valid.
OLS of \(y_i\) on \(x_i\) and \(\mu_i\). Instrumenting \(x_i\) with \(x_i - \mu_i\) while controlling for \(\mu_i\) reduces to this regression, because \(x_i - \mu_i\) and \(\mu_i\) add up to \(x_i\), so the instrument reproduces the treatment (Borusyak and Hull 2026, footnote 8). It uses the same variation as 3, but the estimates differ in a finite sample. It is valid.
The Monte Carlo is design-based. We generate the people once: their incomes, states and errors are the same in every replication. In each of 1,000 replications we draw new thresholds for the 50 states, recompute eligibility and outcomes, and fit the four estimators. The only randomness across replications is the policy draw, which is what the identifying assumption treats as random, so the spread of the estimates across replications measures each estimator’s precision under that design. The people and the 1,000 × 50 thresholds are stored as CSVs so the Julia companion computes the same numbers.
Code
people = CSV.read("data/recenter_people.csv", DataFrame)draws =Matrix(CSV.read("data/recenter_policy_draws.csv", DataFrame)[:, 2:end])pool = [0.5, 1.0, 1.38, 2.0]beta_true =0.3mu = [mean(v .< pool) for v in people.income] # expected eligibilitygener = [mean(people.income .< t) for t in pool] # state generosityfunctioncoef_x(f) i =findfirst(==("x"), coefnames(f))returncoef(f)[i], stderror(f)[i]endconst CL = Vcov.cluster(:state)functionone_draw(r) thr = draws[r, people.state] d =copy(people) d.x =Float64.(d.income .< thr) d.y = beta_true .* d.x .+ d.eps d.z_sim = gener[[findfirst(==(t), pool) for t in thr]] d.z_rc = d.x .- mu d.mu = mu fits = (feols(d, @formula(y ~ x), vcov = CL),feiv(d, @formula(y ~1), endo =:x, inst =:z_sim, vcov_type = CL),feiv(d, @formula(y ~1), endo =:x, inst =:z_rc, vcov_type = CL),feols(d, @formula(y ~ x + mu), vcov = CL)) r2 = [NaN, cor(d.x, d.z_sim)^2, cor(d.x, d.z_rc)^2, NaN]return [collect(coef_x(f)) for f in fits], r2endR =size(draws, 1)est =zeros(R, 4); se =zeros(R, 4); r2 =zeros(R, 4)Threads.@threadsfor r in1:R # one slot per draw, race-free cs, r2[r, :] =one_draw(r)for j in1:4; est[r, j], se[r, j] = cs[j]; endendDataFrame(estimator = ["OLS", "Simulated instrument", "Recentered treatment","OLS controlling for mu"], mean =round.(vec(mean(est, dims =1)), digits =3), sd =round.(vec(std(est, dims =1)), digits =3), coverage =round.(vec(mean(abs.(est .- beta_true) .<=1.96.* se, dims =1)), digits =3), first_stage_R2 =round.(vec(mean(r2, dims =1)), digits =3))
4×5 DataFrame
Row
estimator
mean
sd
coverage
first_stage_R2
String
Float64
Float64
Float64
Float64
1
OLS
0.637
0.049
0.0
NaN
2
Simulated instrument
0.302
0.167
0.937
0.263
3
Recentered treatment
0.3
0.086
0.927
0.589
4
OLS controlling for mu
0.3
0.08
0.935
NaN
The table gives each estimator’s mean and standard deviation over the 1,000 replications, the share of clustered 95% intervals that contain 0.3, and the average first-stage \(R^2\). OLS averages 0.637 against a true 0.3, and its intervals never contain 0.3. The three other estimators are centred on 0.3, with coverage of 92.7% to 93.7%, slightly below 95% with 50 clusters. They differ in precision. The simulated instrument has a standard deviation of 0.167 and a first-stage \(R^2\) of 0.26. It gives everyone in a state the same value, so it cannot separate people whose eligibility depends on the threshold from people who are eligible, or ineligible, under every threshold. The recentered treatment has a standard deviation of 0.086, half as large, and an \(R^2\) of 0.59, because it uses that variation within states. Its controlled form has 0.080.
In real data, Borusyak and Hull (2026) instrument Medicaid eligibility in the 2014 ACA expansion with actual minus expected eligibility, treating expansion as random within the governor’s party. The first-stage partial \(R^2\) rises from 0.01 to 0.80 over the simulated instrument and the standard error on crowd-out falls by 44%. Most of the gain comes from the 18% of the sample whose eligibility the expansion could change; outside it, the recentered instrument is zero, and in the full sample without an exposure control it is less precise than the simulated one (Borusyak and Hull 2026, Table A4). Their 2012–2013 placebo on private insurance is −0.011, half the main estimate of −0.023 (Table A2).
19.4 The China shock
In ADH the shocks are at the industry-period level: the growth of Chinese imports into eight other high-income countries, per US worker, in 397 manufacturing industries over 1990–2000 and 2000–2007. ADH argue they are exogenous because the growth came from China’s side, through reform, rising productivity and WTO accession, and because imports into other countries do not respond to US demand. The argument is weaker for demand or technology shocks shared by all rich countries, and the identifying variation is concentrated in a few industries such as computers, toys and audio equipment (Goldsmith-Pinkham, Sorkin, and Swift 2020).
All four regressions below use the same instrument and differ only in what they control for. The treatment, US import exposure per worker, is shares times US import growth, and US imports also reflect US demand. Replacing them with the other-country shocks gives the prediction, which is the Bartik instrument itself, so the formula-instrument approach does not change the instrument. It changes the control. The shares, lagged employment shares in the 722 commuting zones, are incomplete, so the expected instrument \(\mu_\ell\) varies across zones, and we control for it. The shocks are the 397 industry shocks in each period and the formula is shares times shocks, so \(\mu_\ell\) depends only on which reshufflings of the shocks the design treats as equally likely.
Design 1: the 397 shocks are exchangeable within each period. Every industry then has the same expected shock, the period mean \(\bar g_t\), which is 4.8 in the first period and 17.3 in the second, and Equation 19.4 gives \(\mu_\ell = S_\ell \bar g_t\). A zone with 20 percent of its workers in manufacturing has \(\mu_\ell = 0.2 \times 4.8 = 0.96\) in the first period and \(0.2 \times 17.3 = 3.46\) in the second. Only a zone’s manufacturing intensity is treated as predictable.
Design 2: the shocks are exchangeable only within each of the 20 two-digit SIC sectors in each period. Each industry’s expected shock is its sector’s mean \(\bar g_{mt}\), and \(\mu_\ell = \sum_m S_{\ell m} \bar g_{mt}\), where \(S_{\ell m}\) is the zone’s share in sector \(m\). A zone’s sector mix is also treated as predictable: a zone heavy in electronics is expected to receive a large instrument.
ADH control for the start-of-period manufacturing share with one coefficient for both periods, which approximates design 1’s \(\mu_\ell\). The second row drops that control, so nothing recenters the instrument, and it is valid only if the shares are exogenous. All fits use ADH’s other controls, census-division effects, population weights and standard errors clustered by state, with the GPSS replication files. The clustered standard errors reproduce ADH; we return to inference under the shock design below.
Code
adh = CSV.read("data/adh_master.csv", DataFrame)tr = CSV.read("data/adh_shares_triplets.csv", DataFrame)shk = CSV.read("data/adh_shocks.csv", DataFrame)functionby_row(v) # sum over industries, by zone out =zeros(nrow(adh))for (r, x) inzip(tr.row, v); out[r] += x; endreturn outendsector =string.(shk.sic87dd .÷100, " ", shk.year)g_bar_m =Dict(s =>mean(shk.g[sector .== s]) for s inunique(sector))adh.B =by_row(tr.share .* shk.g[tr.col])adh.S =by_row(tr.share)adh.S_t2 = adh.S .* adh.t2adh.t2n =Float64.(adh.t2)adh.mu2 =by_row(tr.share .* [g_bar_m[sector[c]] for c in tr.col])controls =term(:l_sh_popedu_c) +term(:l_sh_popfborn) +term(:l_sh_empl_f) +term(:l_sh_routine33) +term(:l_task_outsource) +term(:t2n) +fe(:division)functioniv(extra) rhs =isempty(extra) ? controls :sum(term.(extra)) + controlsfeiv(adh, term(:d_sh_empl_mfg) ~ rhs, endo =:shock, inst =:B, weights =:weights, vcov_type = Vcov.cluster(:statefip))endfits = ["Bartik, ADH controls"=>iv([:l_shind_manuf_cbp]),"Bartik, no manufacturing control"=>iv(Symbol[]),"Bartik, design 1 mu (S x period)"=>iv([:S, :S_t2]),"Bartik, design 2 mu (sector means)"=>iv([:mu2])]DataFrame(specification =first.(fits), estimate = [round(coef(f)[1], digits =3) for f inlast.(fits)], se = [round(stderror(f)[1], digits =3) for f inlast.(fits)])
4×3 DataFrame
Row
specification
estimate
se
String
Float64
Float64
1
Bartik, ADH controls
-0.596
0.1
2
Bartik, no manufacturing control
-0.712
0.083
3
Bartik, design 1 mu (S x period)
-0.267
0.087
4
Bartik, design 2 mu (sector means)
-0.144
0.117
The first row reproduces ADH’s −0.596: an increase in import exposure of $1,000 per worker over a decade lowers the manufacturing employment share by about 0.6 percentage points. Without the manufacturing-share control the estimate is −0.712.
Each of the last two rows removes one source of variation. ADH’s estimate partly compares zones with more and less manufacturing across the two periods: because the mean shock more than triples, a manufacturing-heavy zone gets a much larger instrument in the second period whichever industries China hit. Controlling for design 1’s \(\mu_\ell\) removes that comparison, and the estimate falls to −0.267 (0.087). ADH’s control is close to \(S_\ell\), with a correlation of 0.92, but one coefficient cannot absorb a term whose slope more than triples between periods. Design 2 also removes the comparison across sectors, such as electronics and toys against food and paper, and the estimate falls to −0.144 (0.117).
Whether the removed comparisons are confounded is the substantive question. If manufacturing-heavy zones declined faster in the 2000s for other reasons, such as automation, the design 1 control is needed and ADH overstate the effect. But the average shock is itself part of the China shock, since Chinese imports rose across nearly all of manufacturing. Designs 1 and 2 treat that average as predictable and use only the variation in which industries China hit harder than average, so they cannot measure an effect that works through manufacturing as a whole. ADH’s −0.596 does use it, and it is valid if the shares are exogenous given the controls. The data cannot tell us which assumption holds. Every estimate is negative, and recentering shows how much of the size depends on the assumption.
19.4.1 Inference under the shock design
The standard errors above are clustered by state. They reproduce ADH, but they describe a different source of randomness from the one designs 1 and 2 rely on. Under those designs the random part is which industries received which shocks, and every zone’s instrument is built from the same 397 shocks in each period. Inference that follows the design reshuffles the shocks, as the simulation redrew the thresholds, and asks how unusual the observed data are among the reshuffles (Borusyak and Hull 2023).
Let \(y_\ell\) be the change in zone \(\ell\)’s manufacturing employment share and \(x_\ell\) its US import exposure. For a hypothesised effect \(b\), form \(e_\ell(b) = y_\ell - b x_\ell\). If \(b = \beta\), \(e_\ell(b)\) is the contribution of the controls plus the error, and under the design it is the same whichever reshuffle of the shocks occurred. Let \(\theta(b)\) be the coefficient on the Bartik instrument \(B_\ell\) in a weighted regression of \(e_\ell(b)\) on \(B_\ell\) and the controls, including the design’s \(\mu_\ell\). We recompute \(B_\ell\) and \(\theta(b)\) under 1,999 reshuffles permitted by the design, holding \(e_\ell(b)\) fixed. The p-value for \(b\) is the share of reshuffles, counting the observed one, whose \(|\theta(b)|\) is at least the observed value. The 95% interval collects the values of \(b\) whose p-value is above 0.05. At the IV estimate \(\theta\) is zero, so the interval contains the estimate, and the test does not need a strong first stage. It does need the reshuffles to be equally likely given the errors, which is a little more than Equation 19.2. The reshuffles are stored in the data folder, so both books use the same ones.
Code
usingLinearAlgebraperms = [Matrix{Int}(CSV.read("data/adh_perms_design$d.csv", DataFrame)) for d in1:2]divs =sort(unique(adh.division))W0 =hcat(ones(nrow(adh)), adh.l_sh_popedu_c, adh.l_sh_popfborn, adh.l_sh_empl_f, adh.l_sh_routine33, adh.l_task_outsource, adh.t2n, [Float64.(adh.division .== v) for v in divs[2:end]]...)W = [hcat(W0, adh.S, adh.S_t2), # design 1: mu = S x period meanhcat(W0, adh.mu2)] # design 2: mu = sector meansb_grid = (-1500:1000) ./1000# hypothesised effects bsw =sqrt.(adh.weights)functionri_test(W, perm) Q =Matrix(qr(sw .* W).Q)res(v) = (u = sw .* v; u .- Q * (Q'* u)) # weighted residual on controls and mu yt =res(adh.d_sh_empl_mfg); xt =res(adh.shock)# theta(b) = sum(Bt .* (yt .- b .* xt)) / sum(Bt.^2) is linear in b, so keep three sumssums(B) = (bt =res(B); [dot(bt, yt), dot(bt, xt), dot(bt, bt)]) obs =sums(adh.B) P =size(perm, 2) sims =zeros(P, 3)Threads.@threadsfor p in1:P # one reshuffling per column sims[p, :] =sums(by_row(tr.share .* shk.g[perm[tr.col, p]]))endtheta(m, b) =abs.(m[:, 1] .- b .* m[:, 2]) ./ m[:, 3] p_val = [(1+sum(theta(sims, b) .>=theta(obs', b))) / (P +1) for b in b_grid] ok = b_grid[p_val .>0.05]returnminimum(ok), maximum(ok), p_val[findfirst(==(0), b_grid)]endri = [ri_test(W[d], perms[d]) for d in1:2]est = [coef(last(fits[k]))[1] for k in3:4]se_ = [stderror(last(fits[k]))[1] for k in3:4]DataFrame(design = ["Design 1 (S x period)", "Design 2 (sector means)"], estimate =round.(est, digits =3), state_lo =round.(est .-1.96.* se_, digits =3), state_hi =round.(est .+1.96.* se_, digits =3), ri_lo = [round(r[1], digits =3) for r in ri], ri_hi = [round(r[2], digits =3) for r in ri], ri_p0 = [round(r[3], digits =3) for r in ri])
2×7 DataFrame
Row
design
estimate
state_lo
state_hi
ri_lo
ri_hi
ri_p0
String
Float64
Float64
Float64
Float64
Float64
Float64
1
Design 1 (S x period)
-0.267
-0.438
-0.096
-0.526
-0.016
0.036
2
Design 2 (sector means)
-0.144
-0.373
0.085
-0.418
0.107
0.226
The intervals that reshuffle the shocks are wider than the clustered ones. Under design 1 the interval runs from −0.526 to −0.016, against −0.438 to −0.096 with state clustering, and the p-value for no effect is 0.036. Under design 2 it runs from −0.418 to 0.107, and the p-value is 0.226. With the design’s own inference, design 1 still finds a negative effect at the 5% level, but its interval nearly reaches zero, and design 2 cannot rule out no effect.
19.4.2 A two-zone example
To see what the manufacturing-share control does, take two zones, P and Q, and three manufacturing industries, 1, 2 and 3, in one period. Zone P has 10 percent of its workers in each industry, so its manufacturing share is \(S_P = 0.3\). Zone Q has 10 percent in industry 3 only, so \(S_Q = 0.1\). Suppose we observe China shocks \(g_1 = 30\), \(g_2 = 0\) and \(g_3 = 0\), in thousands of dollars of imports per worker. Under design 1 any reshuffling of these shocks across the industries is equally likely, so the shock of 30 could have gone to any of the three industries, each with probability 1/3. To keep the example short, suppose US import exposure equals the Bartik measure \(B_\ell\), and let the change in the manufacturing employment share, in percentage points, be
\[
y_\ell = -0.6 B_\ell - 10 S_\ell .
\]
Each $1,000 of exposure per worker lowers the share by 0.6 points, and manufacturing-heavy zones decline by a further 10 points per unit of manufacturing share for other reasons, such as automation. P has the larger share, so it declines 2 points more than Q in every draw.
Each row of the table is one draw. A zone’s exposure is its shares times the shocks, and its outcome follows from the equation above. The last row averages each zone’s exposure over the three draws, which is its expected exposure.
Draw
\(g_1\)
\(g_2\)
\(g_3\)
\(B_P\)
\(B_Q\)
\(y_P\)
\(y_Q\)
1
30
0
0
3
0
−4.8
−1.0
2
0
30
0
3
0
−4.8
−1.0
3
0
0
30
3
3
−4.8
−2.8
Average
\(\mu_P = 3\)
\(\mu_Q = 1\)
P’s exposure is \(0.1 \times 30 = 3\) in every draw, because its three shares are equal. Q’s is 3 only when industry 3 is shocked. The averages match Equation 19.4 with the expected shock \(\bar g = 10\): \(\mu_P = 0.3 \times 10 = 3\) and \(\mu_Q = 0.1 \times 10 = 1\).
Comparing the two zones within a draw is biased. In draw 1, P has 3 more units of exposure than Q and an outcome 3.8 points lower:
Of the 3.8 points, 1.8 come from imports and 2 from P’s larger manufacturing share. P has more exposure in most draws, so the comparison counts the 2 points as an effect of imports, and the effect looks larger than it is.
Comparing each zone with its own expected exposure is not biased. P’s exposure equals its average in every draw, so \(B_P - \mu_P\) is always zero and P carries no information. Q’s exposure is 0 in two draws and 3 in one, and when it rises by 3, Q’s outcome falls from −1.0 to −2.8:
\[
\frac{-2.8 - (-1.0)}{3 - 0} = -0.6 .
\]
Q’s manufacturing share is the same in every draw, so it cancels. This is what the instrument \(B_\ell - \mu_\ell\) does. It measures how much more or less exposure a zone got than it expected, which averages zero for every zone, so it is unrelated to any fixed characteristic of the zone. Pooling the three draws of both zones, the raw slope of \(y_\ell\) on \(B_\ell\) is −1.1, and using \(B_\ell - \mu_\ell\) as the instrument gives exactly −0.6. Since \(\mu_\ell = 10 S_\ell\), controlling for \(S_\ell\) does the same.
In real data we see one draw but many zones. The instrument then compares zones that got more exposure than they expected with zones that got less. Whether a zone was lucky does not depend on its manufacturing share, so the lucky and unlucky zones are alike in their shares, as treated and control units are in an experiment.
With two periods the mean shock changes, and \(\mu_\ell = S_\ell \bar g_t\) has a different slope on \(S_\ell\) in each period. With \(\bar g_t\) equal to 4.8 and 17.3, a single coefficient on \(S_\ell\) cannot match both, and part of the decline gap stays in the estimate. This is the difference between ADH’s control and design 1.
19.5 Spillovers: deworming
Miguel and Kremer (2004) study a deworming programme in 75 primary schools in Busia, Kenya. The schools were listed alphabetically within strata and assigned in turn to three groups of 25, which started treatment in different years. Worms spread between children, so treating one school can lower infection at schools nearby. To measure this, they count the pupils at treated schools within 3 km of each school, and they control for the total number of pupils within 3 km.
Let \(D_j\) be 1 if school \(j\) is treated, \(n_j\) its number of pupils, \(p_j\) the probability that it is treated, and \(j \sim i\) mean that \(j\) is another school within 3 km of school \(i\). The spillover exposure of school \(i\) and its expected value are
The three steps give \(\mu_i\). The shocks \(g\) are the assignments, and the predetermined variables \(w\) are the locations and pupil counts. The formula is linear in the assignments, so averaging it over the draws replaces each \(D_j\) by its probability \(p_j\). If exposure were instead 1 for any treated neighbour, the formula would not be linear, and \(\mu_i\) would be the share of draws in which school \(i\) has at least one treated neighbour, found by redrawing the assignment. Assignment is random, but a school in a dense area has more treated neighbours in every draw. If density also affects the outcome, through crowding or sanitation, the exposure is correlated with the error. In the first year one third of the schools were treated, so \(p_j = 1/3\) for every school and \(\mu_i\) is one third of the total pupils within 3 km. Miguel and Kremer’s total-pupils control is therefore the recentering. The exposure is the treatment itself, as eligibility was in the simulation, so the estimator is OLS controlling for \(\mu_i\), estimator 4 above. If the treatment probability differed across schools, for example by stratum, the control would have to be \(\mu_i\) and not the total pupils.
A second simulation checks this in a district like Busia. We place 75 schools in a 30 km by 30 km district, half around a town and half spread over the rest, and give each about 400 pupils. In each draw exactly 25 schools are treated, so \(p_j = 1/3\). Let \(N_i\) be the total pupils at other schools within 3 km and \(\eta_i \sim N(0, 0.05^2)\) a school error. The outcome, school participation, is
with \(x_i\) and \(N_i\) in thousands of pupils. Treatment raises participation by 5 points at the school and by 3 points per thousand treated pupils nearby. Schools in dense areas have lower participation for other reasons. As before, the schools, their pupils and errors are fixed, and the 1,000 replications redraw which 25 schools are treated. We regress \(y_i\) on \(D_i\) and on (a) \(x_i\), (b) \(x_i - \mu_i\), or (c) \(x_i\) and \(N_i\), with heteroskedasticity-robust standard errors. The table reports the mean and standard deviation of each estimate over the replications, the coverage of the robust 95% intervals for 0.03, and the mean robust standard error. Only the assignment changes across replications, so the standard deviation is the estimate’s sampling variation under the design, and a robust standard error is accurate when it matches it.
Code
schools = CSV.read("data/deworm_schools.csv", DataFrame)treat =Matrix(CSV.read("data/deworm_draws.csv", DataFrame)[:, 2:end])ns =nrow(schools)near = [i != j &&hypot(schools.east[i] - schools.east[j], schools.north[i] - schools.north[j]) <3 for i in1:ns, j in1:ns] # within 3 kmN = near * schools.pupils ./1000# total pupils nearby, thousandsmu = N ./3# expected treated pupils nearbyfunctionone_assign(r) D =Float64.(treat[r, :]) x = near * (schools.pupils .* D) ./1000 d =DataFrame(D = D, x = x, N = N, x_rc = x .- mu, y =0.05.* D .+0.03.* x .-0.02.* N .+ schools.eta) fits = (feols(d, @formula(y ~ D + x), vcov = Vcov.robust()),feols(d, @formula(y ~ D + x_rc), vcov = Vcov.robust()),feols(d, @formula(y ~ D + x + N), vcov = Vcov.robust()))return [(coef(f)[3], stderror(f)[3]) for f in fits]endR =size(treat, 1)dw_est =zeros(R, 3); dw_se =zeros(R, 3)Threads.@threadsfor r in1:R # one slot per draw, race-freefor (j, (b, s)) inenumerate(one_assign(r)) dw_est[r, j], dw_se[r, j] = b, sendendDataFrame(estimator = ["(a) Exposure, no control", "(b) Recentered exposure","(c) Exposure, control for nearby pupils"], mean =round.(vec(mean(dw_est, dims =1)), digits =3), sd =round.(vec(std(dw_est, dims =1)), digits =3), coverage =round.(vec(mean(abs.(dw_est .-0.03) .<=1.96.* dw_se, dims =1)), digits =3), mean_se =round.(vec(mean(dw_se, dims =1)), digits =3))
3×5 DataFrame
Row
estimator
mean
sd
coverage
mean_se
String
Float64
Float64
Float64
Float64
1
(a) Exposure, no control
-0.024
0.012
0.0
0.005
2
(b) Recentered exposure
0.03
0.038
0.43
0.016
3
(c) Exposure, control for nearby pupils
0.03
0.02
0.92
0.017
Without the control, the spillover estimate averages −0.024 against a true 0.03, and its intervals never contain 0.03. Dense schools have more treated neighbours and lower participation, and the regression assigns that gap to the spillover. Both recentered versions are centred on 0.03. Regressing on \(x_i - \mu_i\) alone leaves \(-0.02 N_i\) in the error, so its standard deviation is 0.038, about twice the 0.020 of (c). Neighbouring schools share that error and the same treated schools, so the robust standard error of (b) averages 0.016 against a standard deviation of 0.038, and its intervals contain 0.03 only 43% of the time. With the control for nearby pupils the remaining error is independent across schools, the robust standard error averages 0.017 against 0.020, and coverage is 92%. That match is a property of this simulation, where the school errors are independent. The design does not guarantee it, because every school’s exposure comes from the same 25 treated schools. In a single data set the inference that follows the design redraws the assignment, as we reshuffled the shocks for ADH. It has to hypothesise both the direct effect and the spillover, because a school’s outcome under another assignment depends on both.
19.5.1 A two-school example
Take two untreated schools, A and B, and three other schools, 1, 2 and 3, with 400 pupils each. Exactly one of the three is treated, each with probability 1/3, as in the full design, where exactly 25 of the 75 schools are treated. School A is in town and has all three within 3 km, so \(N_A = 1.2\) thousand pupils nearby. School B is rural and has only school 3 nearby, so \(N_B = 0.4\). With both schools untreated and \(\eta_i\) set to zero, Equation 19.8 gives
\[
y_i = 0.03 x_i - 0.02 N_i .
\]
Density lowers A’s participation 1.6 points below B’s in every draw, because A has 0.8 thousand more pupils nearby.
Each row of the table is one draw. A school’s exposure is the pupils at its treated neighbours, in thousands, and its outcome follows from the equation above. The last row averages each school’s exposure over the three draws, which is its expected exposure.
Treated school
\(x_A\)
\(x_B\)
\(y_A\)
\(y_B\)
1
0.4
0
−0.012
−0.008
2
0.4
0
−0.012
−0.008
3
0.4
0.4
−0.012
0.004
Average
\(\mu_A = 0.4\)
\(\mu_B = 0.133\)
Each expected exposure is the pupils nearby times the treatment probability 1/3. The town school expects more treated neighbours because it has more neighbours.
Comparing the two schools within a draw is biased. In draw 1, A has 0.4 more exposure than B and participation 0.004 lower:
The spillover raises A by 0.012 relative to B, and density lowers it by 0.016. A has more exposure in most draws, so the comparison counts the density gap as an effect of exposure. This is omitted-variable bias. Density affects participation, and density is correlated with exposure, because exposure is built from nearby pupils. If either link were absent, there would be no bias. Here the bias is large enough to flip the sign.
Comparing each school with its own expected exposure is not biased. A’s exposure equals its average in every draw, so \(x_A - \mu_A\) is always zero and A carries no information. B’s exposure is 0 in two draws and 0.4 in one, and when it rises, B’s participation rises from −0.008 to 0.004:
\[
\frac{0.004 - (-0.008)}{0.4 - 0} = 0.03 .
\]
B’s density is the same in every draw, so it cancels. Pooling the three draws of both schools, the raw slope of \(y_i\) on \(x_i\) is 0, and using \(x_i - \mu_i\) as the instrument gives exactly 0.03.
The argument uses nothing specific to density. Any fixed characteristic of a school, such as local wealth or sanitation, cancels in the same way, because \(x_i - \mu_i\) comes only from the draw. We do not need to know which fixed variables affect the outcome, or to measure them. We need only \(\mu_i\), which comes from the design.
With 75 schools and one draw, the instrument compares schools that got more treated neighbours than they expected with schools that got fewer. Their densities are alike on average but not exactly, which is the extra noise of estimator (b). Controlling for \(N_i\), which here is the same as controlling for \(\mu_i\), removes the density term exactly. The comparison is then between schools with the same number of pupils nearby, which is why (c) is tighter.
19.6 Summary
The calculation in each setting is the same: hold exposure fixed, redraw the shocks under an explicit design, and average the formula. The result is the expected instrument \(\mu\), which depends on the shocks, the fixed exposure and the design:
Table 19.2: Expected instrument in each application. In the stratified experiment, the Medicaid simulation and deworming, the instrument is the treatment, so \(\mu\) is also the expected treatment.
Case
Shocks
Fixed exposure
Design
Expected instrument \(\mu\)
Stratified experiment
Who is treated
Stratum
Probability 0.8 or 0.2 by stratum
The assignment probability
Medicaid simulation
State thresholds
Income
Each threshold with probability 1/4
Share of thresholds above income
Bartik, design 1
Industry shocks
Industry shares
Reshuffling within period
\(S_\ell \bar g_t\)
Bartik, design 2
Industry shocks
Industry shares
Reshuffling within sector and period
\(\sum_m S_{\ell m} \bar g_{mt}\)
Deworming
Which schools are treated
Locations and pupils
25 of 75 schools at random
Pupils nearby times 1/3
Shift-share is one formula instrument, with the formula and the design fixed by convention. Any formula of shocks and exposure is valid once its expected value over the shock design is subtracted, and the most efficient formula is the recentered best prediction of the treatment. Applied to Bartik, this has two consequences. When the shares do not sum to one, the regression must control for the sum of shares times the period’s mean shock. When the treatment depends on the shocks through more than shares times shocks, a prediction built from the treatment’s own formula is a stronger instrument than Bartik. In the ADH data the first consequence alone moves the estimate from −0.60 to −0.27, and inference that reshuffles the shocks gives it a 95% interval of −0.53 to −0.02, wider than the state-clustered one. The same logic covers spillovers. A school’s expected exposure to treated neighbours is the treatment probability times its nearby pupils, which is the control Miguel and Kremer used.
For the shift-share construction, the share and shock views, and inference, see the previous chapter, Shift-Share Instrumental Variables.
Borusyak, Kirill, and Peter Hull. 2023. “Nonrandom Exposure to Exogenous Shocks.”Econometrica 91 (6): 2155–85. https://doi.org/10.3982/ECTA19367.
———. 2026. “Optimal Formula Instruments.”
Borusyak, Kirill, Peter Hull, and Xavier Jaravel. 2022. “Quasi-Experimental Shift-Share Research Designs.”Review of Economic Studies 89 (1): 181–213.
Currie, Janet, and Jonathan Gruber. 1996. “Health Insurance Eligibility, Utilization of Medical Care, and Child Health.”Quarterly Journal of Economics 111 (2): 431–66. https://doi.org/10.2307/2946684.
Goldsmith-Pinkham, Paul, Isaac Sorkin, and Henry Swift. 2020. “Bartik Instruments: What, When, Why, and How.”American Economic Review 110 (8): 2586–2624.
Miguel, Edward, and Michael Kremer. 2004. “Worms: Identifying Impacts on Education and Health in the Presence of Treatment Externalities.”Econometrica 72 (1): 159–217. https://doi.org/10.1111/j.1468-0262.2004.00481.x.