Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #860 +/- ##
========================================
Coverage 99.69% 99.69%
========================================
Files 207 209 +2
Lines 39478 39756 +278
Branches 2541 2552 +11
========================================
+ Hits 39357 39635 +278
Misses 52 52
Partials 69 69
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:
|
|
While I'm not fundamentally opposed to this PR or the direction, it is too heavy. It has many large binary files. Retaining results is fine, but I would suggest putting them in a single file. If the data is needed, it should be simulated internally as part of the process. If you need the data to confirm R results, simply simulate it in Python, then check R and record results as needed, and then use the same simulation in the test suite. |
|
Thanks, Kevin. I agree that the PR was carrying too much data. I’ve pushed b4a3497 to remove the duplicated calibration files and simplify the implementation. The binaries contained precomputed tF critical-value tables used during inference. The test inputs are already generated in Python with a fixed seed. The revised implementation calls the public API of Both tF methods now require the optional All 109 feature tests pass against the PyPI installation. I also compared 18,108 inputs across all 18 confidence levels with the previous reader, including boundary and plateau cases, and obtained identical results. The full suite has 23,387 passing tests; its 13 failures reproduce on the previous PR head (one existing RandomEffects case and 12 notebook socket restrictions in the local sandbox). Style checks pass, both distributions build without the calibration files, and remote CI is running. |
bashtage
left a comment
There was a problem hiding this comment.
Thanks for slimming this down. I'm not keen on a public method that needs another package at run time, especially a new one that needs pyarrow and Python 3.12 or later, and with the pin only in the test requirements users get whatever version is current. My earlier comment was about computing what is needed in linearmodels rather than shipping data files. Could the critical values for the bundled levels be computed here, or stored as one small array on a coarse grid?
Also needed: a rebase (the imports in iv/results.py conflict with #870, which added resolve_method), .. versionadded:: 7.2 on tf_conf_int, and a 7.2 note under "New features".
IVResults.tf_conf_int returns the tF interval of Lee, McCrary, Moreira and Porter (2022) for a model with one endogenous regressor and one instrument, with unadjusted or robust covariance and debiased=False. The critical values are computed in linearmodels from the paper's Appendix B.3 construction (an inverse-map recurrence from a closed-form start near the chi-square boundary, interpolated with PCHIP), using only NumPy and SciPy. The only stored data is the F at which the critical value stops falling at each of the 18 supported levels, chosen offline by a numerical size search. The values agree with the tf-inference 0.1.0 tables to 3e-8 over 18,126 inputs across all levels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62ce675 to
0827f0c
Compare
The construction runs only at the 18 fixed levels, where it is deterministic and its output is checked by the reference tests, so the two RuntimeError branches could not be reached. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks — reworked as you suggested. The critical values are now computed in linearmodels ( |
Adds
IVResults.tf_conf_int(level=0.95, *, method="table")for IV2SLS with one endogenous regressor and one excluded instrument. The method reuses the fitted coefficient, covariance convention and first-stage regression. Included controls, constant weights, unadjusted or robust covariance (including aliases), anddebiased=Falseare supported. Unsupported configurations raiseValueError; conventional inference is unchanged.Both methods delegate to the public API of the optional tf-inference package. That package owns table loading, interpolation, integrity checks and calibration caching. This PR contains no calibration binaries or copied metadata. The adapter maps confidence levels to the package's exact significance-level keys and caches that mapping.
Using tF inference requires installing tf-inference 0.1.0 from PyPI with Python 3.12+, NumPy 1.26+, SciPy 1.12+ and PyArrow 18+. Installation instructions and compatible CI jobs pin the published release. Core linearmodels requirements are unchanged, and a missing optional package produces installation guidance when tF inference is requested.
The default table method covers 18 confidence levels from 75% to 99.99%, with no interpolation across levels or implicit numerical calibration. Explicit
method="compute"supports other levels within that range. At 95%, F strictly above approximately 3.84145882 gives finite bounds, including F between that boundary and 4. For an estimate of 1, SE of 0.4 and F=10, the interval is approximately [-0.37214, 2.37214]. Each confidence level has its own calibrated plateau.Calibration uses deterministic integration, a finite nuisance-parameter grid and local searches. Numerical validation is not a uniform size proof, a conservative rounding guarantee, or a finite-sample coverage guarantee. The procedure remains asymptotic under the single-instrument IV assumptions; no p-value API is introduced.
The dependency uses the independently reviewed 0.1.0 release, which stores its calibrations in one validated Parquet file. All 109 tF feature tests pass against the PyPI installation; changed-file style checks and all 15 guide examples pass. The published package separately passes all 137 tests in a clean environment, and its installed source/data files match the reviewed candidate.
Earlier full-suite and artifact validation at
b4a3497cd1b3e623dab9f6193c50ae688b6e12ac:References: Valid t-Ratio Inference for IV; author manuscript, Appendix B.3; calibration package release and validation.
AI assistance was used for implementation, testing and documentation.