ENDID_IV
收藏NIAID Data Ecosystem2026-05-10 收录
下载链接:
https://data.mendeley.com/datasets/dpzjjnh6hf
下载链接
链接失效反馈官方服务:
资源简介:
This repository reproduces the paper’s main empirical results from:
“Difference-in-differences with endogenous externalities: Model and application to climate econometrics”
Papers in Regional Science, 104 (2025) 100125.
The code implements the paper’s strategy by combining (i) a PPML first stage to predict bilateral flows and construct a country–year exposure instrument, and (ii) an IV second stage to estimate causal effects on country–year outcomes.
First stage (PPML). We estimate a Poisson model with high-dimensional fixed effects (exporter–importer and year) using fixest::fepois. From the estimated coefficients, we compute predicted bilateral flows and build WD_row_hat, an instrument that measures country i’s exposure in year t to shocks occurring in node j (e.g., drought). Exposure is weighted by shares derived from predicted bilateral flows, using either row-standardization (by exporter-year) or a year-global normalization, depending on the option selected.
Second stage (IV). We estimate country–year panel models for outcomes such as ln_production (and optionally ln_area, ln_yield) as functions of observed exposure WD_row_obs, treated as endogenous and instrumented by WD_row_hat. Specifications include fixed effects and climate/structural controls (temperature, precipitation, irrigation, and drought indicators), estimated with fixest::feols using its IV formula syntax.
Inference. Standard errors are obtained via a two-level bootstrap: (1) draw PPML coefficient vectors from a multivariate normal approximation based on the first-stage variance–covariance matrix; (2) resample country clusters (or a user-defined cluster key) with replacement and re-estimate the second-stage and IV models for each replication. This yields bootstrap standard errors that incorporate both first-stage uncertainty and within-cluster dependence. Parallelization uses foreach/doParallel, and reproducibility is ensured via doRNG with a fixed seed.
Inputs are: (a) a bilateral panel (isoi, isoj, year) for the PPML stage and (b) a country–year panel (iso, year) for the IV stage. Running the replication script produces point estimates and a coefficient table with bootstrap standard errors and key diagnostics (e.g., first-stage F-statistics when available).
创建时间:
2026-01-28



