Repository navigation
BUG: Preserve small upper-tail Wald p-values - #975
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. |
|
Thanks. I"m sure this is correct but will wait for green. I'm happy for all 1- cdf to be replaced with sf if there are any more. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #975 +/- ##
=======================================
Coverage 98.95% 98.95%
=======================================
Files 137 137
Lines 30099 30104 +5
Branches 2337 2337
=======================================
+ Hits 29785 29790 +5
Misses 256 256
Partials 58 58
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:
|
|
Merged, thanks. |
- Highlights and new features: NGARCH (bashtage#966), the VaR backtests (bashtage#965), the local block bootstrap (bashtage#967) and bandwidth_method (bashtage#964, and phillips_ouliaris here). - Changes that alter results: the automatic bandwidth entry of bashtage#983 now also describes the bandwidth of the kernels with bounded support, the fractional bandwidths and the Tukey-Parzen constant of bashtage#964, its S&P 500 bandwidths are those of the bandwidth attribute (30.96 and 34.50, where it said the 31.96 and 35.50 of opt_bandwidth), and it links phillips_ouliaris in arch.unitroot.cointegration. The ADF-Z tables of bashtage#972, bashtage#973 and bashtage#980. - Backward-incompatible changes: strings in object data. - Bug fixes: bashtage#954, bashtage#970, bashtage#974, bashtage#975, bashtage#977, bashtage#978, bashtage#982, and the constant data of the Newey-West bandwidth and mackinnonp at -inf and inf. - Maintenance: the CI changes and the version file. - Contributors: galafis, jackiectl2, mkzung and wavebyrd.
WaldTestStatistic.pval subtracts the chi-squared CDF from 1. This loses relative accuracy in the upper tail and rounds representable p-values to zero. For a statistic of 100 and 2 degrees of freedom it returns 0 instead of exp(-50), approximately 1.92875e-22.
Use the distribution's survival function. Four regression cases compare the two-degree-of-freedom tail against its independent closed form exp(-stat/2), with zero absolute tolerance; all four fail before the change. Existing tests continue to cover ordinary values, NaN and infinity.
SciPy documents sf as the upper tail and notes its greater accuracy over 1-cdf: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chi2.html .
Validation: 1227 utility tests passed; Ruff lint and formatting passed for both changed files; git diff --check passed. Tested on current source main with Python 3.12.14, NumPy 2.5.4, pandas 3.1.0 and SciPy 1.18.1. The installed arch 8.0.0 distribution supplied only the ignored version metadata file; tests import the current source tree.