Repository navigation
Conversation
Update scipy.optimize.minimize wrapper bounds list
|
Do you have an example for this using statsmodesl AFAIK we don't support bounds constraints in the models. |
@josef-pkt I am currently following the tutorial at https://www.statsmodels.org/v0.13.2/examples/notebooks/generated/generic_mle.html and want to do If a test for this is wanted I would copy the existing |
|
very good, thanks for figuring this out, I had completely forgotten about this (or not paid enough attention in the first place) related issue #4591 Yes, add the unit test, PRs need unit tests to check that it works Note, Constraints through minimizer are not officially supported in the models because inference with possibly binding constraints is not standard, and we don't have a way to handle inference for inequality constraints yet. e.g. #1382 |
|
trying out the example without constraining the constant results looks strange slsqp optimization with bounds looks fragile Aside: GLM summary does not show update 'L-BFGS-B' with bounds looks much better, Pseudo R-squ. (CS): 0.7854 |
|
I'm currently using a scipy version that is too old for bounds in nm. scipy.version |
|
We can merge this as a simple extension. We need to check if an older version of scipy provides a good error message if |
|
@josef-pkt What do you think of the approach taken in the latest commit, which makes the bounds support check scipy version-aware and adds two version-aware tests? With this approach, I think we might be able to skip the "need to check if an older version of scipy provides a good error message if bounds is not available" as we will never be in a situation where we pass an unsupported option to an older version of scipy. |
|
version check in code looks good. I don't understand how the unit tests work. |
@josef-pkt Oh, I wanted to respect the existing behaviour of the code. Right now if you pass |
|
We changed 1 or 2 versions ago that fit keywords that are not used raise an exception instead of silently being ignored. It should raise instead of silently returning different numbers to the user. However, I don't know where the raise for invalid optimizer keyword is. It might be triggered only when calling |
|
I just checked an example, So for this PR the options are
If this PR only includes the change in bounds, then we should implement the kwarg check in a separate PR before the next release. We might be able to delegate the kwarg check to scipy's minimize. |
|
I"m happy to do the kwarg check if this one is otherwise ok. |
|
Ok, thanks, I've dropped the unit test case for the old scipy version. So this PR now only contains the change in bounds plus tests that for now are run only if the scipy version is new enough (the tests are skipped if it is a too old scipy version for bounds support). Thanks @bashtage for offering to do the kwarg check changes in a new PR. |
|
thanks @bashtage This PR looks good to me. Commits could be squashed before merge I tried out a few more examples with bounds, but using lbfgsb. |
|
@wnfldchen (otherwise, I will do it before merge for 0.14) |
|
reminder to myself: |
|
rebased and squashed in #8545, will merge soon @wnfldchen Thanks for the PR and enhancement |
The
_fit_minimizewrapper function forscipy.optimize.minimizedoes not reflect more recent scipy versions which have bounds support for Nelder-Mead and Powell methods.https://docs.scipy.org/doc/scipy-1.8.1/reference/generated/scipy.optimize.minimize.html
https://docs.scipy.org/doc/scipy-1.8.1/reference/optimize.minimize-neldermead.html
https://docs.scipy.org/doc/scipy-1.8.1/reference/optimize.minimize-powell.html
Update the
has_boundslist in_fit_minimize:Add
'Powell'to reflect scipy 1.5.0 scipy/scipy#12172Add
'Nelder-Mead'to reflect scipy 1.7.0 scipy/scipy#13515