Skip to content

emplike/OLS convergence checks in conf_int_el and test_el #1216

Open

Description

@josef-pkt

OLSResults conf_int_el and test_el
don't have checks for successful convergence, rootfinding.

In a Debian test run the returned results is out of bounds
The test fails only on some machines.

Instead of returning wrong results we should try again for better convergence or raise an exception if a root cannot be found

statsmodels_0.5.0+git13-g8e07d34-1~nd13.04+1_i386.build FAILED  18:05.47 real, 671.50 user, 186.72 sys, 1147360 out
FAIL: statsmodels.emplike.tests.test_regression.TestRegressionNM.test_ci_beta2
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/tmp/buildd/statsmodels-0.5.0+git13-g8e07d34/debian/python-statsmodels/usr/lib/python2.7/dist-packages/statsmodels/emplike/tests/test_regression.py", line 149, in test_ci_beta2
    assert_almost_equal(beta2ci, self.res2.test_ci_beta2, 6)
  File "/usr/lib/python2.7/dist-packages/numpy/testing/utils.py", line 452, in assert_almost_equal
    return assert_array_almost_equal(actual, desired, decimal, err_msg)
  File "/usr/lib/python2.7/dist-packages/numpy/testing/utils.py", line 812, in assert_array_almost_equal
    header=('Arrays are not almost equal to %d decimals' % decimal))
  File "/usr/lib/python2.7/dist-packages/numpy/testing/utils.py", line 645, in assert_array_compare
    raise AssertionError(msg)
AssertionError:
Arrays are not almost equal to 6 decimals

(mismatch 50.0%)
 x: array([ 0.60120459,  0.        ])
 y: array([ 0.60120459,  2.18470794])

Activity

  1. josef-pkt commented on Nov 30, 2013

    @josef-pkt
    MemberAuthor

    also upper_bound = self.conf_int(.01)[param_num][1] has hardcoded alpha 0.01
    I think this should be a fraction of sig

  2. josef-pkt commented on Nov 30, 2013

    @josef-pkt
    MemberAuthor

    el_test could take a start_params for x0.

    This might make it possible to speed up the conf_int_el search, if the parameters are further away from the unrestricted estimate.
    This might only help if we trace the el_test values or calculate them on a grid, where we can use neighboring params. It won't help with brentq or similar because they don't do a sequential search, but might help close to the root of the conf_int search (when it searches more locally).
    Sounds too complicated for the rootfinding because we would need to memoize, since we don't have direct access to what brentq is doing during search.

    It could still help in a grid search.

  3. josef-pkt commented on Nov 30, 2013

    @josef-pkt
    MemberAuthor

    The root function looks monotonic when printing out some results for the root function in the neighborhood of the conf_int lower bound. (parameter number 2)

    My guess is that we need to check the convergence of fmin_powell or fmin, and warn or raise if it didn't converge well enough.

    @j-grana6 Do you have an example that always breaks in the convergence? It would be useful to have a case for testing when we don't have nice convergence.

  4. josef-pkt commented on Nov 30, 2013

    @josef-pkt
    MemberAuthor

    another possibility to narrow down where the problem on the difficult machines is to add a unit test for el_test at the confidence bounds to test_ci_beta2

    >>> res1.el_test(0.60120509116947018, [2])
    (3.8414512399018919, 0.05000022605567922)
    >>> res1.el_test(2.1847027275193485, [2])
    (3.8414115503604016, 0.05000140959687227)
    
  5. j-grana6 commented on Nov 30, 2013

    @j-grana6
    Contributor

    On 11/30/2013 02:03 PM, Josef Perktold wrote:

    The root function looks monotonic when printing out some results for
    the root function in the neighborhood of the conf_int lower bound.
    (parameter number 2)

    My guess is that we need to check the convergence of fmin_powell or
    fmin, and warn or raise if it didn't converge well enough.

    @j-grana6 https://github.com/j-grana6 Do you have an example that
    always breaks in the convergence?

    I just tried fiddling around and I don't. I'm a bit confused because I
    also tried a simulated example with a very poorly specified model. I
    thought maybe that was the cause for convergence issues but it actually
    converged very quickly.

    It would be useful to have a case for testing when we don't have nice
    convergence.

    —
    Reply to this email directly or view it on GitHub
    #1216 (comment).

  6. j-grana6 commented on Nov 30, 2013

    @j-grana6
    Contributor

    On 11/30/2013 02:14 PM, Josef Perktold wrote:

    another possibility to narrow down where the problem on the difficult
    machines is to add a unit test for el_test at the confidence bounds to
    test_ci_beta2

    I can do this. I even wrote in the documentation that users should do
    this after computing a confience interval. maybe I just should build it
    in as an extra assertion.
    |>>> res1.el_test(0.60120509116947018, [2])
    (3.8414512399018919, 0.05000022605567922)

    res1.el_test(2.1847027275193485, [2])
    (3.8414115503604016, 0.05000140959687227)
    |

    —
    Reply to this email directly or view it on GitHub
    #1216 (comment).

  7. yarikoptic commented on Jan 4, 2014

    @yarikoptic
    Contributor

    Hi guys -- any advice on my course of action to address tests failures on those exotic architectures?
    https://buildd.debian.org/status/package.php?p=statsmodels
    should they be skipped there or ... ?

  8. j-grana6 commented on Jan 4, 2014

    @j-grana6
    Contributor

    On 01/04/2014 01:40 PM, Yaroslav Halchenko wrote:

    Hi guys -- any advice on my course of action to address tests failures
    on those exotic architectures?
    https://buildd.debian.org/status/package.php?p=statsmodels
    should they be skipped there or ... ?

    Sorry this was for me to look into and I have been jammed lately. It
    might be best to skip them for this release as I do not know when I will
    be able to get to this. Josef, what do you think?

    —
    Reply to this email directly or view it on GitHub
    #1216 (comment).

  9. jseabold commented on Jan 4, 2014

    @jseabold
    Member

    Skipping them sounds fine to me. All we would do is change the tests to pass AFAIK. The code is "right."

  10. added
    type-bug-wrong
    on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp-emplikecomp-regressiontype-bugtype-bug-wrong

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions