set.seed(1115)N =3000# Number of unitsK =10# Number of industriesw =matrix(runif(N*K),nrow=N,ncol=K) # Shares are an NxK matrix# Normalize shares to sum to 1w = w/as.vector((w%*%matrix(1,nrow=K,ncol=1))) g =matrix(runif(K,-1,1),nrow=K,ncol=1) # Shifts are Kx1 vectorZ = w%*%g # Shift shareX =runif(N,-1,1) # Controle =rnorm(N,0,0.1) # Errors D =as.vector(Z) + e # Treatment correlated with errorY = D + X + e # True effect of treatment is 1# Put stuff in matricesY =matrix(Y,nrow=N,ncol=1)rhs =cbind(matrix(1,nrow=N,ncol=1), # Constantmatrix(X,nrow=N,ncol=1), # Controlmatrix(D,nrow=N,ncol=1) # Treatment)rhs_short =cbind(matrix(1,nrow=N,ncol=1), # Constantmatrix(X,nrow=N,ncol=1) # Control)# Annhilator matrixannh =diag(N) - rhs_short%*%solve(t(rhs_short)%*%rhs_short)%*%t(rhs_short)inst =cbind(matrix(1,nrow=N,ncol=1), # Constantmatrix(X,nrow=N,ncol=1), # Control Z # instrument)shift_share_iv_coef =solve(t(inst)%*%rhs) %*% (t(inst)%*%Y)print(paste("Shift Share IV Coef:", shift_share_iv_coef[3,1]))
Y_bar =t(w)%*%Y_fwl # Weight FWL'd outcomes by shares# Y_bar is KxN%*%Nx1 = Kx1D_bar =t(w)%*%D_fwl # Same for treatmentshock_iv_coef =solve(t(g)%*%D_bar)%*%(t(g)%*%Y_bar) # IVprint(paste("Shift Share IV Coef:", shift_share_iv_coef[3,1]))
[1] "Shift Share IV Coef: 1.00437876156168"
print(paste("Shock-level IV Coef:", shock_iv_coef))
[1] "Shock-level IV Coef: 1.00437876156166"
Shifts are Exogenous: Takeaways
SSIV is equivalent to shock-level IV with shock as instrument
Shocks are level of treatment assignment, so need many shocks for good inference
Easier to think of how a design assigns shocks than shares
SSIV as a Special Case of Non-Random Exposure
\(Z_{i,t} = \sum\limits_{k\in\mathcal{K}}w^k_{i}g^k_{t}\) is a special case of \(Z_{i,t}=h(g_t;w_i)\)
When shares are correlated with unobserved determinants of the outcome and shifts aren’t all mean zero, SSIV can be biased
Solution: Re-center instrument around expectation \(Z_{i,t}-\mathbb{E}[Z_{i,t}]\)
SSIV as a Special Case of Non-Random Exposure: Math
Not necessarily zero unless observation-level expected shocks are uncorrelated with unobservables
Re-centering mechanically removes correlation
SSIV as a Special Case of Non-Random Exposure: Code
g_means =runif(K,0,5)g =matrix(sapply(g_means,function(x) rnorm(1,x,1)),nrow=K,ncol=1) # Shifts are Kx1 vectorZ = w%*%g # Shift sharemu = w%*%g_meansZ_rc = Z-mu# Errors correlated with expected instrumente1 =sapply(as.vector(mu),function(x) rnorm(1,x,0.3)) e2 =sapply(e1,function(x) rnorm(1,x,0.1))D =as.vector(Z) + e1 # Treatment correlated with errorY = D + X + e2 # True effect of treatment is 1# Put stuff in matricesY =matrix(Y,nrow=N,ncol=1)rhs =cbind(matrix(1,nrow=N,ncol=1), # Constantmatrix(X,nrow=N,ncol=1), # Controlmatrix(D,nrow=N,ncol=1) # Treatment)rhs_short =cbind(matrix(1,nrow=N,ncol=1), # Constantmatrix(X,nrow=N,ncol=1) # Control)# Annhilator matrixannh =diag(N) - rhs_short%*%solve(t(rhs_short)%*%rhs_short)%*%t(rhs_short)inst =cbind(matrix(1,nrow=N,ncol=1), # Constantmatrix(X,nrow=N,ncol=1), # Control Z # instrument)shift_share_iv_coef =solve(t(inst)%*%rhs) %*% (t(inst)%*%Y)print(paste("Shift Share IV Coef:", shift_share_iv_coef[3,1]))
[1] "Shift Share IV Coef: 1.38369346953507"
SSIV as a Special Case of Non-Random Exposure: Code
recentered_iv_coef =solve(t(Z_rc)%*%D_fwl) %*% (t(Z_rc)%*%Y_fwl)print(paste("Re-centered IV Coef:", recentered_iv_coef))
[1] "Re-centered IV Coef: 0.957521500615535"
SSIV as a Special Case of Non-Random Exposure: Takeaways
Problems can arise in SSIV when expected exposure to shifts is correlated with unobservables
Possible to do proper design-based inference even in these tricky cases
Requires knowledge of shock distribution to perform re-centering and do finite-sample inference
A Word on Inference
With exogenous shares it isn’t immediately obvious how to do proper statistical inference
With exogenous shifts heteroskedasticity robust SEs of shock-level regression are valid under large number of uncorrelated shocks assumption (similar conclusions from Adão et al. 2019)
With non-random exposure, finite sample randomization inference is possible using correlation between (simulated) re-centered instrument and (FWL’d) outcome