Update yli.turnbull for the case where no data are right-censored
This commit is contained in:
parent
00ed38d47d
commit
035b1592dc
@ -272,6 +272,9 @@ def calc_survfunc_turnbull(time_left, time_right, *, ci=True, step_loc=0.5, maxi
|
|||||||
|
|
||||||
xpoints = [i[0]*(1-step_loc) + i[1]*step_loc for i in raw_result['failure_intervals'] if i[1]]
|
xpoints = [i[0]*(1-step_loc) + i[1]*step_loc for i in raw_result['failure_intervals'] if i[1]]
|
||||||
ypoints = survival_prob
|
ypoints = survival_prob
|
||||||
|
if raw_result['failure_intervals'][-1][1]:
|
||||||
|
# No right-censored observations - we can draw the whole survival curve
|
||||||
|
ypoints = np.concatenate([ypoints, [0]])
|
||||||
|
|
||||||
# Draw straight lines
|
# Draw straight lines
|
||||||
# np.concatenate(...) to force starting drawing from time 0, survival 100%
|
# np.concatenate(...) to force starting drawing from time 0, survival 100%
|
||||||
@ -296,6 +299,11 @@ def calc_survfunc_turnbull(time_left, time_right, *, ci=True, step_loc=0.5, maxi
|
|||||||
ci0 = survival_prob_ci.T[0]
|
ci0 = survival_prob_ci.T[0]
|
||||||
ci1 = survival_prob_ci.T[1]
|
ci1 = survival_prob_ci.T[1]
|
||||||
|
|
||||||
|
if raw_result['failure_intervals'][-1][1]:
|
||||||
|
# No right-censored observations - we can draw the whole survival curve
|
||||||
|
ci0 = np.concatenate([ci0, [0]])
|
||||||
|
ci1 = np.concatenate([ci1, [0]])
|
||||||
|
|
||||||
# Plot confidence intervals
|
# Plot confidence intervals
|
||||||
ypoints0 = np.concatenate([[1], ci0]).repeat(2)[:-1]
|
ypoints0 = np.concatenate([[1], ci0]).repeat(2)[:-1]
|
||||||
ypoints1 = np.concatenate([[1], ci1]).repeat(2)[:-1]
|
ypoints1 = np.concatenate([[1], ci1]).repeat(2)[:-1]
|
||||||
|
Loading…
Reference in New Issue
Block a user