phit

IV

Verification

Scope

Structural coefficients, covariance, inference, residuals, first-stage strength, SW F, Wu–Hausman, and Sargan.

References

Reference
ivreg, fixest, and Sanderson–Windmeijer (2016)
Versions
R 4.6.1 (2026-06-24), ivreg 0.6.8, fixest 0.14.2, sw Sanderson & Windmeijer (2016), equations 14-15; finite-sample n-L divisor

Data

Inputs
Twelve cases including a weighted heating-shaped design.

Method

Saved public R API outputs and independent paper-derived conditional F calculations, checked in the extension and polyfill.

Check
Comparison with a reference implementation

Tolerances

|x − r| ≤ 1e-9 + 1e-7 × |r|

Applies to: Numerical results

x: package value; r: reference value. Absolute error: |x − r|. Max errors are over the values a row compares.

Results

24 comparisons in 12 cases: 24 pass, 0 fail, 0 skipped.

By case

Results by case
Case Comparisons Largest abs. error Status
no_exog 2 2.3e-13 pass
one_exact 2 1.1e-13 pass
one_over 2 4.5e-13 pass
two_over 2 6.8e-13 pass
two_exact 2 6.8e-13 pass
weighted 2 1.4e-13 pass
no_intercept 2 4.5e-13 pass
factors 2 2.8e-13 pass
interactions 2 2.3e-13 pass
missing 2 1.1e-13 pass
weak_conditional 2 1.1e-12 pass
heating 2 7.2e-13 pass

Every comparison

Every comparison
Case Implementation Quantity Criterion Values Max abs. error Status
no_exog native IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 596 2.3e-13 pass
one_exact native IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 588 1.0e-13 pass
one_over native IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 592 1.7e-13 pass
two_over native IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 624 6.8e-13 pass
two_exact native IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 617 6.8e-13 pass
weighted native IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 624 1.1e-13 pass
no_intercept native IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 609 4.5e-13 pass
factors native IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 622 2.8e-13 pass
interactions native IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 624 1.7e-13 pass
missing native IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 610 1.1e-13 pass
weak_conditional native IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 624 2.3e-13 pass
heating native IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 3,628 7.2e-13 pass
no_exog polyfill IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 596 4.3e-14 pass
one_exact polyfill IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 588 1.1e-13 pass
one_over polyfill IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 592 4.5e-13 pass
two_over polyfill IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 624 5.1e-13 pass
two_exact polyfill IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 617 3.0e-14 pass
weighted polyfill IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 624 1.4e-13 pass
no_intercept polyfill IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 609 4.5e-13 pass
factors polyfill IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 622 2.8e-13 pass
interactions polyfill IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 624 2.3e-13 pass
missing polyfill IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 610 5.9e-14 pass
weak_conditional polyfill IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 624 1.1e-12 pass
heating polyfill IV inference and diagnostics |x − r| ≤ 1e-9 + 1e-7 × |r| 3,628 7.2e-13 pass

Limitations

Known differences

  • No-intercept Sargan uses the specified uncentered auxiliary regression R²; see specs/cleanroom/iv.md.

Reproduction

From the repository root
Rscript docs/verifications/iv.R
python3 docs/verifications/compare_iv.py
Raw record
site/verifications/iv.json
Full results
docs/verifications/iv-results.json
Input data
tests/fixtures/iv-r.json