Repository navigation
Conversation
Use scipy.special.xlogy in powerdiscrepancy for lambd=0 (loglikeratio) and lambd=-1 (modified_loglikeratio) to prevent log(0) evaluating to -inf and 0 * -inf evaluating to NaN. Closes statsmodels#10703
gr-0x076
commented
Nov 11, 2026
gr-0x076
left a comment
Author
There was a problem hiding this comment.
Friendly check-in on this whenever you have a chance to take a look @josef-pkt!
All CI checks are passing green (✓), and regression tests are included for both lambd=0 and lambd=-1) with zero observed counts. Happy to make any adjustments or address feedback if needed.
Author
|
I've pushed an update reverting the |
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.
Description
In
powerdiscrepancywithlambd=0(orlambd="loglikeratio") andlambd=-1(modified log-likelihood ratio), passing zero observed counts causednp.log(0)to evaluate to-inf, producingRuntimeWarning: divide by zero encountered in logandinvalid value encountered in multiply, yielding(nan, nan).Mathematically,$\lim_{x \to 0^+} x \ln(x) = 0$ . By using
scipy.special.xlogy, zero counts evaluate cleanly to0.0without warnings orNaNs, matchingscipy.stats.power_divergence.AI Disclosure
Contributions must comply with the statsmodels AI Policy.
Tool(s): Google Antigravity.
Used for: understanding the statistical concepts, researching numerical limit behavior, and drafting the regression test.
I have personally read, understood, and can explain every line of this diff, and have verified the statistical/numerical correctness of the change.