CamDavidsonPilon/lifelines — pull request #89 by spacecowboy (2014-11-22 15:51:52+00:00)
Title: Some failing CoxPH tests

Noticed some strange behavior with CoxPH. I always have
normalized data, which did not seem to work good with
the implementation. The failures here seem unrelated to that
though.

The added tests currently fail with the following trace:

>Traceback (most recent call last):
> File "/home/jonas/workspacepython/lifelines/lifelines/tests/test_suite.py", line 937, in test_crossval_normalized
> event_col='E', k=3)
> File "/home/jonas/workspacepython/lifelines/lifelines/utils.py", line 311, in k_fold_cross_validation
> fitter.fit(training_data, duration_col=duration_col, event_col=event_col)
> File "/home/jonas/workspacepython/lifelines/lifelines/estimation.py", line 998, in fit
> include_likelihood=include_likelihood)
> File "/home/jonas/workspacepython/lifelines/lifelines/estimation.py", line 938, in _newton_rhaphson
> delta = solve(-hessian, step_size * gradient.T)
> File "/home/jonas/anaconda3/lib/python3.4/site-packages/numpy/linalg/linalg.py", line 381, in solve
> r = gufunc(a, b, signature=signature, extobj=extobj)
> File "/home/jonas/anaconda3/lib/python3.4/site-packages/numpy/linalg/linalg.py", line 90, in _raise_linalgerror_singular
> raise LinAlgError("Singular matrix")
>numpy.linalg.linalg.LinAlgError: Singular matrix

However, note that I have commented out one of the datasets because that
seems to cause the cross-validation to end up in an infinite loop of
some kind. The tests never finish (only waited for ~2 minutes).

Doing similar things with *R* works with no problem.

Doing the following is a fast way to check the results:

python -m unittest lifelines.tests.test_suite.CoxRegressionTests