Skip to content
awhobbsPublic

About

R implementation of the Abadie-Gu-Shen (2024) split-sample select-and-interact 2SLS estimator

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

seliv

R-CMD-check

R implementation of the split-sample select-and-interact 2SLS estimator of Abadie, Gu, and Shen (2024, Journal of Econometrics 240(2): 105425). For settings where first-stage strength varies across subpopulations, a data-driven procedure selects groups with informative first stages and estimates interacted 2SLS on a split sample to avoid pre-testing bias and many-instrument bias.

Install

# install.packages("remotes")
remotes::install_github("awhobbs/seliv")

Usage

library(seliv)

result <- seliv(
  depvar     = "log_crime",
  endogvar   = "nightlight",
  instrument = "blackout",
  group      = "pop_quintile",
  fe         = c("subplace_id", "year", "month"),
  controls   = c("temperature", "rainfall"),
  cluster    = "subplace_id",
  data       = panel,
  nsplits    = 50          # multi-split for stable inference
)

print(result)
#> Split-sample select-and-interact IV (Abadie, Gu & Shen 2024)
#> --------------------------------------------------------------------
#>   Dep var:     log_crime
#>   Endogenous:  nightlight
#>   Instrument:  blackout
#>   Group:       pop_quintile  (G = 5)
#>   FE:          subplace_id + year + month
#>   Cluster:     subplace_id
#>   N:           261,263
#>   kappa:       (log G)^2 * 0.5 = 1.295
#>   K* selected: 5 / 5 groups
#> --------------------------------------------------------------------
#>
#>   Estimator                  Coef.  Std.Err.       t   P>|t|
#>   --------------------------------------------------------
#>   Pooled 2SLS              -0.2313    0.0408   -5.66   0.000
#>   Interacted 2SLS          -0.2015    0.0395   -5.10   0.000
#>   AGS (K=5/5)              -0.2001    0.0393   -5.08   0.000
#>   AGS multi (S=50)         -0.1989    0.0410   -4.85   0.000

See vignette("seliv") for a worked example with synthetic data.

Validation

Validated against the authors' actual Stata + R replication pipeline on all 8 panels of the Stephens & Yang (2014) application from AGS Table 5:

  • Pooled 2SLS: within 0.8% on every panel (two panels match to machine epsilon).
  • Fully-interacted 2SLS: within 0.55% on every panel.
  • Adaptive split-sample: differs by 50-150% relative because Stata rnormal() and R rnorm() produce different within-group random splits at the same nominal seed. The difference washes out under multi-split (nsplits = 50 or more) with Rubin's combining rules.

Two documented divergences from the authors' code:

  1. abs(rho_g) instead of the signed first-stage coefficient, so the procedure handles applications where all first stages are negative. Equivalent under Assumption 1.2 (same-direction first stages).
  2. residualize_by_group = TRUE is the default and matches the authors' group-by-group residualization. Set to FALSE for pooled FE absorption (faster, but gives different numerical results when controls cut across groups).

References

Abadie, A., Gu, J., and Shen, S. (2024). "Instrumental variable estimation with first-stage heterogeneity." Journal of Econometrics 240(2): 105425.

Stephens, M., and Yang, D.-Y. (2014). "Compulsory education and the benefits of schooling." American Economic Review 104(6): 1777-1792.

About

R implementation of the Abadie-Gu-Shen (2024) split-sample select-and-interact 2SLS estimator

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages