Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

precision problems in degenerate case #1229

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

Comments

Projects
None yet
1 participant
@josef-pkt
Copy link
Member

commented Dec 12, 2013

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

This comment has been minimized.

Copy link
Member Author

commented Dec 13, 2013

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

josef-pkt added a commit that referenced this issue Dec 15, 2013

Merge pull request #1230 from josef-pkt/regression_resid_person_zero
BUG: numerical precision in resid_pearson with perfect fit closes #1229

PierreBdR pushed a commit to PierreBdR/statsmodels that referenced this issue Sep 2, 2014

Merge pull request statsmodels#1230 from josef-pkt/regression_resid_p…
…erson_zero

BUG: numerical precision in resid_pearson with perfect fit closes statsmodels#1229
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.