precision problems in degenerate case #1229

Closed
josef-pkt opened this Issue Dec 12, 2013 · 1 comment

Projects

None yet

1 participant

@josef-pkt
Member

OLS(y, y) should have a perfect fit with resid == zeros

at 3303360
problem is that TravisCI has currently a test failure with wresid = -1.45519152e-11
That's too far away for a purely numerical precision problem.
On my computer wresid == zeros is True

this is from a test branch that checks more intermediate results:

======================================================================
FAIL: statsmodels.regression.tests.test_regression.TestOLS.test_norm_resid_zero_variance
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/local/lib/python2.7/dist-packages/statsmodels-0.6.0-py2.7-linux-x86_64.egg/statsmodels/regression/tests/test_regression.py", line 244, in test_norm_resid_zero_variance
    assert_allclose(res.wresid, np.zeros(len(y)), rtol=1e-20)
  File "/usr/lib/python2.7/dist-packages/numpy/testing/utils.py", line 1168, in assert_allclose
    verbose=verbose, header=header)
  File "/usr/lib/python2.7/dist-packages/numpy/testing/utils.py", line 636, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Not equal to tolerance rtol=1e-20, atol=0
(mismatch 100.0%)
 x: array([ -1.45519152e-11,  -1.45519152e-11,  -1.45519152e-11,
        -1.45519152e-11,  -1.45519152e-11,  -1.45519152e-11,
        -1.45519152e-11,  -1.45519152e-11,  -1.45519152e-11,...
 y: array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
        0.,  0.,  0.])
@josef-pkt
Member

As Robert pointed out on the mailing list this is just machine precision since the endog are around 1e4

When I compae scale with zero, then I get an atol around 1e-21 on TravisCI,
Note: rtol doesn't make sense

x86_64.egg/statsmodels/regression/tests/test_regression.py", line 247, in test_norm_resid_zero_variance
    assert_allclose(res.scale, 0, rtol=1e-20)
...
AssertionError: 
Not equal to tolerance rtol=1e-20, atol=0
(mismatch 100.0%)
 x: array(2.2587545260114675e-22)
 y: array(0)
@josef-pkt josef-pkt closed this in 99cf5fc Dec 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment