You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MAINT: RuntimeWarning: invalid value encountered in _nct_sf #8624
Output of import statsmodels.api as sm; sm.show_versions()
Details
INSTALLED VERSIONS
Python: 3.10.6.final.0
OS: Linux 6.0.6-76060006-generic #202210290932166906205022.04~d94609a SMP PREEMPT_DYNAMIC Mon N x86_64
byteorder: little
LC_ALL: en_US.UTF-8
LANG: C
scipy is moving many distributions from using the scipy special code to using boost.
Some behavior is different and boost also still has some bugs in edge cases that are getting fixed over time.
Also, I guess that warnings that are just an implementation detail should be removed or silenced over time in scipy or boost.
For the specific case:
This might occur during rootfinding if we have not imposed enough constraints to restrict values to valid ranges.
You can reverse or roundtrip the results to check that the results are consistent
AFAIR, this should work: analysis.power(nobs1=22.959830247088764, effect_size=0.978343, alpha=0.05)
The scipy version that I currently use is too old for me to check those boost cases.
e.g. What I usually do is use a unit test, convert warnings to raise an error and look at it with pytest --pdb. This is usually a quick way to find the parameters that raise a warning. Sometimes those parameters are edge cases that need special handling.
In this case, scipy already clips the sf, cdf values to be within the [0, 1] range, so I guess statsmodels will not need specific code to treat this.
Right, I know the results are correct, thank you.
The question is more along the lines "this is a regression - how do I deal with it?"
You explained that the regression is due to scipy moving to use boost, thank you.
Now, who should change the code to avoid this warning?
I would argue that your should change statsmodels rather than me (and countless others) changing user code.
Or maybe I misunderstood you?
Maybe it is scipy who should change?
Thank you for such a speedy reply!
changed the title [-]RuntimeWarning: invalid value encountered in _nct_sf[/-][+]MAINT: RuntimeWarning: invalid value encountered in _nct_sf[/+]on Feb 8, 2023
Activity
josef-pkt commentedon Jan 19, 2023
scipy is moving many distributions from using the scipy special code to using boost.
Some behavior is different and boost also still has some bugs in edge cases that are getting fixed over time.
Also, I guess that warnings that are just an implementation detail should be removed or silenced over time in scipy or boost.
For the specific case:
This might occur during rootfinding if we have not imposed enough constraints to restrict values to valid ranges.
You can reverse or roundtrip the results to check that the results are consistent
AFAIR, this should work:
analysis.power(nobs1=22.959830247088764, effect_size=0.978343, alpha=0.05)The scipy version that I currently use is too old for me to check those boost cases.
e.g. What I usually do is use a unit test, convert warnings to raise an error and look at it with
pytest --pdb. This is usually a quick way to find the parameters that raise a warning. Sometimes those parameters are edge cases that need special handling.In this case, scipy already clips the sf, cdf values to be within the [0, 1] range, so I guess statsmodels will not need specific code to treat this.
josef-pkt commentedon Jan 19, 2023
That's what I get
sam-s commentedon Jan 19, 2023
Right, I know the results are correct, thank you.
The question is more along the lines "this is a regression - how do I deal with it?"
You explained that the regression is due to
scipymoving to useboost, thank you.Now, who should change the code to avoid this warning?
I would argue that your should change
statsmodelsrather than me (and countless others) changing user code.Or maybe I misunderstood you?
Maybe it is
scipywho should change?Thank you for such a speedy reply!
josef-pkt commentedon Jan 19, 2023
scipy needs to change if it's a numerical problem in boost. (In this case the problem will go away in one or a few scipy versions.)
statsmodels needs to change if we evaluate at invalid parameter values.
Currently I do not know which it is.
josef-pkt commentedon Jan 27, 2023
I just saw scipy/scipy#14901
I don't know if that is the same as the warning here.
josef-pkt commentedon Feb 8, 2023
#8656 replaced scipy.stats distributions by direct use of scipy.special for ncf, nct in
powerandonewaymodules[-]RuntimeWarning: invalid value encountered in _nct_sf[/-][+]MAINT: RuntimeWarning: invalid value encountered in _nct_sf[/+]