Пример #1
0
censoring = np.ones_like(dta[:, 0])
censoring[dta[:, 0] > 80] = 0
dta = np.c_[dta, censoring]
print('with censoring')
print('\n')
print(dta[lrange(5), :])
print('\n')
km3 = KaplanMeier(dta, 0, exog=1, censoring=2)
km3.fit()
km3.summary()
print('\n')
km3.plot()

#Test for difference of survival curves

log_rank = km3.test_diff([0.0645, -0.03957])
print('log rank test')
print('\n')
print(log_rank)
print('\n')

#The zeroth element of log_rank is the chi-square test statistic
#for the difference between the survival curves for exog = 0.0645
#and exog = -0.03957, the index one element is the degrees of freedom for
#the test, and the index two element is the p-value for the test

wilcoxon = km3.test_diff([0.0645, -0.03957], rho=1)
print('Wilcoxon')
print('\n')
print(wilcoxon)
print('\n')
Пример #2
0
censoring = np.ones_like(dta[:,0])
censoring[dta[:,0] > 80] = 0
dta = np.c_[dta,censoring]
print 'with censoring'
print '\n'
print dta[range(5),:]
print '\n'
km3 = KaplanMeier(dta,0,exog=1,censoring=2)
km3.fit()
km3.summary()
print '\n'
km3.plot()

#Test for difference of survival curves

log_rank = km3.test_diff([0.0645,-0.03957])
print 'log rank test'
print '\n'
print log_rank
print '\n'

#The zeroth element of log_rank is the chi-square test statistic
#for the difference between the survival curves for exog = 0.0645
#and exog = -0.03957, the index one element is the degrees of freedom for
#the test, and the index two element is the p-value for the test

wilcoxon = km3.test_diff([0.0645,-0.03957], rho=1)
print 'Wilcoxon'
print '\n'
print wilcoxon
print '\n'