Repository navigation
BUG: Exclude implicit intercepts from IV model F tests - #859
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
|
Thanks. |
This was referenced Nov 6, 2026
Merged
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: