Skip to content

BUG: Exclude implicit intercepts from IV model F tests - #859

Merged
bashtage merged 1 commit into
bashtage:mainfrom
CodingSelim:fix/iv-implied-constant-fstat
Nov 6, 2026
Merged

bashtage merged 1 commit into
bashtage:mainfrom
CodingSelim:fix/iv-implied-constant-fstat

Conversation

@CodingSelim

@CodingSelim CodingSelim commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

when the regressors include a dummy for every group, the IV model F test currently tests all coefficients against zero, including the intercept those dummies span. it should test that the group effects are equal and the other slopes are zero. this also makes the result depend on whether the same model is written with an explicit intercept. the example in #780 changes from 227.678 on 3 degrees of freedom to the intended 10.775 on 2.

this finds the coefficient direction that produces the implied intercept and tests the remaining directions, using the fitted covariance and the existing F/chi-square calculation. the columns are scaled before finding that direction so differently sized dummy columns give the same test.

related to #780. this handles the IV estimators; the panel and system cases in that issue still need their own changes.

added 48 regression cases covering IV2SLS, IVLIML and IVGMM, unadjusted/robust covariance, debiased on/off, weights, and differently scaled dummies. each checks against explicit Wald restrictions and the equivalent explicit-intercept model. the new test fails on main before the fix. also checked a mixed-column design with IV2SLS, IVGMMCUE and IVJIVE.

validation:

  • IV tests plus the singular-F-statistic regression module: 9582 passed, 2400 skipped.
  • ruff check on the changed files, formatting of the new test file, and git diff --check pass.
  • built and tested the current checkout in an editable install. the whole-repository run was stopped after the IV run completed, so there is no full-suite result.

@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.68%. Comparing base (7fa390b) to head (28bed31).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #859   +/-   ##
=======================================
  Coverage   99.68%   99.68%           
=======================================
  Files         199      200    +1     
  Lines       37875    37909   +34     
  Branches     2436     2437    +1     
=======================================
+ Hits        37756    37790   +34     
  Misses         51       51           
  Partials       68       68           
Flag Coverage Δ
adder 99.67% <100.00%> (+<0.01%) ⬆️
subtractor 99.67% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bashtage

bashtage commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Thanks.

@bashtage
bashtage merged commit 2e48973 into bashtage:main Nov 6, 2026
15 checks passed
bashtage added a commit that referenced this pull request Nov 6, 2026
The follow-ups to #858, #859 and #862 (#867, #866, #865) and the Windows ARM64 job of the CI (#868).
s3alfisc pushed a commit to s3alfisc/linearmodels that referenced this pull request Nov 22, 2026
Follow-up to bashtage#859, which leaves an intercept that dummy columns imply out of
the model F test of every IV estimator. Its test covered IV2SLS, IVLIML and
IVGMM; it now also covers IVGMMCUE and IVJIVE (80 cases, from 48).

IVGMMCUE minimizes its objective with BFGS, so the model with an explicit
constant stops at estimates that differ by rounding from those of the model
with the dummies; their F statistics differ by up to 4e-8. The comparison with
the explicit-constant model uses rtol=1e-6 for IVGMMCUE and keeps 1e-10 for the
other estimators. The comparison of the F statistic with its Wald test of the
same fit keeps 1e-10 for all five. The p-values are also compared with
atol=1e-12, since a p-value of 1e-16 changes by 1e-6 relative to itself.

The same problem remains in the robust F statistic of PooledOLS, the equation
F statistics of SUR and the has_constant of AbsorbingLS without effects
(xref bashtage#780).
s3alfisc pushed a commit to s3alfisc/linearmodels that referenced this pull request Nov 22, 2026
- Changes that alter results: missing categorical values are missing values
  of their dummy variables, so the observation is dropped (bashtage#858); the IV model
  F statistic leaves out an intercept that dummies imply (bashtage#859, which does
  not fix the other model families of bashtage#780).
- Bug fixes: the IV estimators do not store weighted copies of the data
  when all of the weights are 1 (bashtage#862, about a third less memory; the rest of
  bashtage#607, keeping float32, is not done).
- Compatibility: Python 3.10 and NumPy 1.x are still supported, although the
  7.1 notes said that 7.1 would be the last release for them. linearmodels 8.0
  will raise the minimum versions, as the README now says too.
- Contributors: jackiectl2, CodingSelim and DresdenGman.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants