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

Kalman Filter errors with new pyx #1586

Closed
josef-pkt opened this issue Apr 10, 2014 · 11 comments

Comments

Projects
None yet
3 participants
@josef-pkt
Copy link
Member

commented Apr 10, 2014

I'm getting a large number of errors, always the same AFAICS with the new cython code for Kalman filter

complex derivatives, approx_hess_cs, require that the Kalman Filter works with 'complex double'

Windows with 32bit python 3.3.0, compiled with mingw 32, numpy 1.7.1, scipy '0.12.0'
based on checkout of PR #1520 branch

failure second to last is unrelated to kalman filter
last failure is shape mismatch in test_arima.Test_ARIMA111.test_llf

======================================================================
ERROR: statsmodels.tsa.tests.test_arima.Test_Y_ARMA50_NoConst.test_tvalues
----------------------------------------------------------------------
Traceback (most recent call last):
  File "E:\Josef\testing\tox\py33\lib\site-packages\nose-1.3.0-py3.3.egg\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\tsa\tests\test_arima.py", line 146, in test_tvalues
    assert_almost_equal(self.res1.tvalues, self.res2.tvalues,
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\base\wrapper.py", line 35, in __getattribute__
    obj = getattr(results, attr)
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\tools\decorators.py", line 94, in __get__
    _cachedval = self.fget(obj)
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\base\model.py", line 858, in tvalues
    return self.params / self.bse
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\tools\decorators.py", line 94, in __get__
    _cachedval = self.fget(obj)
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\tsa\arima_model.py", line 1318, in bse
    hess = self.model.hessian(params)
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\tsa\arima_model.py", line 520, in hessian
    return approx_hess_cs(params, self.loglike, args=(False,))
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\tools\numdiff.py", line 227, in approx_hess_cs
    2./hess[i,j]
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\tsa\arima_model.py", line 696, in loglike
    return self.loglike_kalman(params, set_sigma2)
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\tsa\arima_model.py", line 706, in loglike_kalman
    return KalmanFilter.loglike(params, self, set_sigma2)
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\tsa\kalmanf\kalmanfilter.py", line 654, in loglike
    R_mat, T_mat)
  File "kalman_loglike.pyx", line 128, in statsmodels.tsa.kalmanf.kalman_loglike.kalman_loglike_complex (statsmodels\tsa/kalmanf/kalman_loglike.c:3900)
ValueError: Buffer dtype mismatch, expected 'DOUBLE' but got 'complex double'

======================================================================
FAIL: statsmodels.tools.tests.test_numdiff.TestGradLogit.test_hess
----------------------------------------------------------------------
Traceback (most recent call last):
  File "E:\Josef\testing\tox\py33\lib\site-packages\nose-1.3.0-py3.3.egg\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\tools\tests\test_numdiff.py", line 64, in test_hess
    assert_allclose(he, hefd, rtol=5e-10)
  File "E:\Josef\testing\tox\py33\lib\site-packages\numpy\testing\utils.py", line 1179, in assert_allclose
    verbose=verbose, header=header)
  File "E:\Josef\testing\tox\py33\lib\site-packages\numpy\testing\utils.py", line 645, in assert_array_compare
    raise AssertionError(msg)
AssertionError:
Not equal to tolerance rtol=5e-10, atol=0

(mismatch 100.0%)
 x: array([[ -2.96566711e+01,  -1.98886470e+02,  -2.37019378e+00,
         -1.00365370e+01],
       [ -1.98886470e+02,  -1.38337697e+03,  -1.59229215e+01,...
 y: array([[ -2.96566711e+01,  -1.98886470e+02,  -2.37019378e+00,
         -1.00365370e+01],
       [ -1.98886470e+02,  -1.38337697e+03,  -1.59229214e+01,...

======================================================================
FAIL: statsmodels.tsa.tests.test_arima.Test_ARIMA111.test_llf
----------------------------------------------------------------------
Traceback (most recent call last):
  File "E:\Josef\testing\tox\py33\lib\site-packages\nose-1.3.0-py3.3.egg\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "E:\Josef\testing\tox\py33\lib\site-packages\statsmodels-0.6.0-py3.3-win32.egg\statsmodels\tsa\tests\test_arima.py", line 127, in test_llf
    assert_almost_equal(self.res1.llf, self.res2.llf, self.decimal_llf)
  File "E:\Josef\testing\tox\py33\lib\site-packages\numpy\testing\utils.py", line 452, in assert_almost_equal
    return assert_array_almost_equal(actual, desired, decimal, err_msg)
  File "E:\Josef\testing\tox\py33\lib\site-packages\numpy\testing\utils.py", line 812, in assert_array_almost_equal
    header=('Arrays are not almost equal to %d decimals' % decimal))
  File "E:\Josef\testing\tox\py33\lib\site-packages\numpy\testing\utils.py", line 600, in assert_array_compare
    raise AssertionError(msg)
AssertionError:
Arrays are not almost equal to 3 decimals

(shapes (1, 1), (1,) mismatch)
 x: array([[-241.7555769]])
 y: array([-241.7557616])

----------------------------------------------------------------------
Ran 2936 tests in 580.688s

FAILED (SKIP=24, errors=70, failures=2)
@josef-pkt

This comment has been minimized.

Copy link
Member Author

commented Apr 10, 2014

added missing information scipy '0.12.0' python 3.3.0

@jseabold

This comment has been minimized.

Copy link
Member

commented Apr 10, 2014

Do you see these on any other Python version?

@jseabold

This comment has been minimized.

Copy link
Member

commented Apr 10, 2014

Hmm, it looks like this might be a build problem to me. I don't see why this would platform dependent. Can you make sure. Do a python setup.py clean first.

@jseabold

This comment has been minimized.

Copy link
Member

commented Apr 10, 2014

The shape issue shouldn't exist it used to call .item() because it returned an array. No longer necessary. Line 128 is also not in the complex method in the new code.

@josef-pkt

This comment has been minimized.

Copy link
Member Author

commented Apr 10, 2014

I haven't tried other versions yet, py 3.3 was the first because of the remove-2to3 PR.

After replacing approx_hess_cs and approx_fprime_cs with the non _cs versions, tsa tests with only the shape mismatch failure. so everything else is fine

@bashtage

This comment has been minimized.

Copy link
Contributor

commented Apr 10, 2014

Oops, didn't ready closely enough.

@josef-pkt

This comment has been minimized.

Copy link
Member Author

commented Apr 10, 2014

my line numbers will be different than master, because I use the remove-2to3 checkout.

I need to start from a clean directory. I don't want to clean my current working checkout directory.

@jseabold

This comment has been minimized.

Copy link
Member

commented Apr 10, 2014

He's using mingw.

Clean just removes the .c, .so, and .pyc files. That's why it's there, so you don't have to do git clean and lose untracked files.

@josef-pkt

This comment has been minimized.

Copy link
Member Author

commented Apr 10, 2014

It's possible it didn't refresh the cython generated c files. I need to start from the beginning, maybe false alarm.

@jseabold

This comment has been minimized.

Copy link
Member

commented Apr 10, 2014

I saw the shape failures when I was switching back and forth between branches that had the new code and those that didn't.

@josef-pkt

This comment has been minimized.

Copy link
Member Author

commented Apr 10, 2014

OK, took me a while.
I'm not able to install master with py3.3, somehow 2to3 is not run.

However, the the tsa tests all pass without errors or failures if I install the remove-2to3 branch in a python 3.3 virtualenv. I'm still running the entire test suite.

False alarm, my mistake

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.