Extended Instrumental Variables Estimation with Diagnostics
Overview
Comprehensive instrumental variables and GMM estimation with automatic diagnostics, inspired by the 'Stata' command 'ivreg2' of Baum, Schaffer, and Stillman (2003) doi:10.1177/1536867X0300300101 and Baum, Schaffer, and Stillman (2007) doi:10.1177/1536867X0800700402. Supports 2SLS, LIML, Fuller, k-class, two-step efficient GMM, and continuously-updated (CUE) estimators. Provides classical, robust, cluster-robust, HAC, and Driscoll-Kraay standard errors. Reports weak identification, underidentification, overidentification, and endogeneity tests at estimation time. All outputs are verified against 'Stata' within tight numerical tolerances.
Initial CRAN release. ivreg2r provides extended instrumental variables and GMM estimation with automatic diagnostics, inspired by Stata's ivreg2 (Baum, Schaffer & Stillman).
- Estimators: 2SLS, LIML, Fuller, k-class, two-step efficient GMM, and the continuously-updated estimator (CUE).
- Variance estimators: classical, heteroskedasticity-robust, one- and two-way cluster-robust, HAC/AC with eight kernels and automatic bandwidth selection, Kiefer, and Driscoll-Kraay.
- Diagnostics reported at estimation time: weak identification (Kleibergen-Paap, Cragg-Donald, Stock-Yogo critical values), underidentification, overidentification (Sargan, Hansen J, Stock-Wright S), first-stage tests (Sanderson-Windmeijer, Angrist-Pischke), endogeneity, and orthogonality.
- Tidyverse integration: a three-part formula interface and
tidy(),glance(), andaugment()methods, plusdiagnostics()andfirst_stage()accessors that return the specification tests and first-stage results as tidy objects. - Bundled datasets used throughout the help-file examples and vignettes:
card,mroz,wagepan,griliches,klein,grunfeld,abdata,nlswork,phillips,stockwatson, andcigar. - All outputs verified against Stata
ivreg2within tight numerical tolerances.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK7 OK2026-07-22
Documentation
The repository also keeps web-only articles.
- Help pages
- 36 (2 internal)includes a package overview page
- Examples that run
- 100%19 run in a plain check
- Exported functions with examples
- 80%
- Documented parameters
- 100%
- Return-value docs
- 80%
- Help pages citing references
- 6%
Downloads
Repository
Stars over time
8 development-tooling and community-health practices detected across 4 families in the upstream repository
Checks run against github.com/restatr/ivreg2r on 2026-10-21.
The R CMD check workflow runs on Linux, macOS and Windows
GitHub Pages site last deployed 2026-07-21 · The repository has a site deploy workflow
pkgdown site last built 2026-07-21
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-02-18Commits: at least 303 crediting it in the message
- Claude Opus 4.6100 commits · Feb to Mar 2026
Some of these counts are a minimum, because the search stopped before the oldest commits.
Dependencies
Code & Tests
Datasets
People & History
- 0.1.0Latest2026-07-21 · current release
- RR 4.6.0 released · 2026-04-24
Package metadata
- First published
- 2026-07-21
- Total releases
- 1 / 1 yrs
- License
- GPL-3 OSI
- Copyright
- Adapted from the Stata package 'ivreg2' by Christopher F Baum, Mark E Schaffer, and Steven Stillman, distributed under GPL-3. Component-level provenance for the adapted code and the bundled datasets is in inst/COPYRIGHTS.
- Minimum R
- ≥ 4.4.0
- Bundled data
- 407 KB / 11 files
- Download size
- 1.4 MB
Cite
Cite this package
Run in R for the authors' entry:
citation("ivreg2r")The package provides a citation file, so citation() returns the authors' own entry.
It points to 10.1177/1536867x0300300101, 10.1177/1536867x0800700402.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-24, which the citation names so these numbers can be found later. More on citing and the projects behind them.