An index error occurs at this line when calling KaplanMeier.test_diff (only for certain data sets):
dk = dk[:,list(tind)]
It appears to be easily fixed by changing this line (4 lines up)
if np.max(tind) != len(dk):
if np.max(tind) > len(dk)-1:
This occurs in two different places, once in the "if self.censoring == None" condition and once in the following "else" condition.
The fix looks correct to me.
A simple test case that triggers the bug would be useful.
Note: survival2 has been rewritten and enhance in a branch. code is not yet merged into master
I opened PR #548 to keep track of that.
comments on and help with #548 would be very useful to get this properly included in statsmodels.
Here is some code that produces this error:
import numpy as np
from statsmodels.sandbox.survival2 import KaplanMeier
T = [0.5, 0.14, 0.36, 0.13, 0.19, 1.92, 0.02, 1.77, 0.05, 1.08]
C = np.ones(10)
G = np.array(_5 + _5)
Z = np.vstack((T, G, C)).T
km = KaplanMeier(Z, 0, exog=1, censoring=2)
p = km.test_diff([0,1])
Needs to be checked against whatever version of survival2 will be the final PR to be merged.
I don't think anything will happen for 0.7