The hard part of survival analysis is not counting deaths. It is counting the people still alive.
Now for the question you most want to ask.
Do patients with more infiltration live longer?
First, something peculiar about survival data. Every patient carries two values —
OS_time — how long they were observed, in days
OS — what happened at the end of that. 1 means died, 0 means still alive
A patient with OS = 0 is censored.
It means "they were alive at day 1,200 and after that we do not know".
How you count those people is very nearly the whole of survival analysis.
The computation is startlingly simple. At every time t where a death occurred —
S(t) = S(previous) × (1 − deaths at t ÷ people still at risk at t)
A censored patient never steps the curve down; they simply drop quietly out of the
denominator from then on.
One step per death time. This function is the same thing as til.km_curve().
PythonRuns in your browser
In melanoma the two curves part company visibly — 3,564 days against 1,618.
PythonRuns in your browser
Switch cancer types. Some have curves that separate, others have curves that overlap.
Loading…
The melanoma result is striking. Median survival is
3,564 days (9.8 years) in the high-infiltration group and
1,618 days (4.4 years) in the low one — more than double.
But wait. Because a picture looks separated, is it?
Human eyes are very good at manufacturing patterns that are not there.
We need a number for how likely this difference is by chance. That is lesson 14.
🤔 Check yourself
Why must censored patients (OS = 0) not simply be dropped?
Answer Censoring usually means 'still alive when the study ended'. Remove those people and only the dead are left, and the result tilts badly pessimistic.
🤔 Check yourself
When does a Kaplan–Meier curve step down?
Answer The curve steps down only at death times. Censoring never lowers it — it only removes that person from the risk set afterwards.