Compute a Kaplan-Meier Curve and Median by Hand for Eight Trial Users
A SaaS team tracks how many weeks eight trial users take to convert to a paid plan, with the data cut at week 12. Times are in weeks; "converted" is the event, and "still trialing" means the user was censored at that time (still in trial, or the trial expired and the user left, which the team treats as non-informative censoring).
| user | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| weeks | 3 | 5 | 5 | 7 | 8 | 8 | 10 | 12 |
| converted | yes | yes | no | yes | yes | no | yes | no |
- Build the Kaplan-Meier table (at-risk, events, step factor, \hat S(t)) and read off the median time to conversion. Explain how the two users with a tied time of 5 and the two with a tied time of 8 are handled.
- The analyst's colleague says: "Just compute the share who converted within 8 weeks: 4 converted by week 8 out of 8 users, so 50 percent." What is wrong, and what does the curve say instead?
- Compute the Greenwood standard error of \hat S(8). Why would you report a log-log interval rather than \hat S\pm1.96\,\text{se}?
- Another colleague proposes averaging the eight times (7.3 weeks) as "the mean time to convert" and dropping the three censored users to "keep only real conversions" (mean 6.6 weeks). Why are both wrong, and what summary would you report instead?
1. The table. At each distinct event time, the at-risk count is everyone whose time is at least t (including users censored at exactly t); \hat S multiplies by 1-d/n.
| t | at risk n | events d | censored at t | 1-d/n | \hat S(t) |
|---|---|---|---|---|---|
| 3 | 8 | 1 | 0 | 0.875 | 0.875 |
| 5 | 7 | 1 | 1 | 0.857 | 0.750 |
| 7 | 5 | 1 | 0 | 0.800 | 0.600 |
| 8 | 4 | 1 | 1 | 0.750 | 0.450 |
| 10 | 2 | 1 | 0 | 0.500 | 0.225 |
The tie at 5 is one conversion and one censoring: the censored user is still in the risk set at t=5 (7 at risk), counts in the denominator there, and leaves afterwards, so n=5 at week 7. The same at 8: 4 are at risk, one converts, the censored user leaves after. The week-12 censoring does not change \hat S because nothing happens after it. The curve is 0.6 at week 7 and 0.45 at week 8, so the median time to conversion is 8 weeks (the first time \hat S\le0.5). Computed by hand and checked against lifelines (verified).
2. The "within 8 weeks" shortcut. Counting conversions among all eight users (4 of 8) treats users 3 and 6, who were censored at weeks 5 and 8, as "never converting". Their true conversion times are at least 5 and at least 8, so some of them might well convert by week 8. The curve uses what is known about them (they were still trialing until their censoring time) and says 1-\hat S(8)=0.55, not 0.50. The gap grows with more censoring: by week 10 the shortcut gives 5/8=0.625 against 1-\hat S(10)=0.775 (arithmetic). A censored user is "not converted yet", not "never".
3. Standard error. Greenwood: \sum d/(n(n-d))=\frac1{8\cdot7}+\frac1{7\cdot6}+\frac1{5\cdot4}+\frac1{4\cdot3}=0.0179+0.0238+0.0500+0.0833=0.175. \text{se}(\hat S(8))=0.45\sqrt{0.175}=0.188 (verified). The plain 95 percent interval is 0.45\pm0.369=(0.08,0.82); at week 10 the sum is 0.675 and the se 0.185, so 0.225\pm0.363 has a negative lower bound (-0.14), an impossible survival. The log-log interval, \hat S^{\exp(\pm1.96\hat\sigma)} with \hat\sigma=\sqrt{\sum d/(n(n-d))}/|\ln\hat S|, stays inside [0,1]: at week 8 it is (0.108,\ 0.751) (verified). With eight users the intervals are very wide; the sample is far too small to distinguish medians of 6 and 10 weeks.
4. Averages. The mean of all eight times (7.3 weeks) treats the three censored times (5, 8, 12) as completed conversion times; they are lower bounds, so it under-states the true mean. Dropping the three censored users keeps only the five conversions at 3, 5, 7, 8 and 10 weeks (mean 6.6), which are biased toward quick converters: the users who stay in trial longest are exactly the ones deleted. Report the median (8 weeks) and, for a mean-like summary, the restricted mean over 12 weeks, the area under \hat S up to week 12: 3\cdot1+2\cdot0.875+2\cdot0.75+1\cdot0.6+2\cdot0.45+2\cdot0.225=8.2 weeks of expected time before conversion within the window (arithmetic from the table). State "restricted to 12 weeks", because nothing is known about the tail beyond the last observation.
Share this question