# Finding median survival time from survival function

Is the best way to find the median survival time from a survival plot just to draw a horizontal line from $p = 0.5$ to the curve and project down to the x-axis?

-

Assuming your survival curve is the basic Kaplan-Meier type survival curve, this is a way to obtain the median survival time. From Machin et al. Survival Analysis: A Practical Approach:

If there are no censored observations (...) the median survival time, $M$, is estimated by the middle observation of the ranked survival times $t_{(1)}, t_{(2)},\ldots,t_{(n)}$ if the number of observations, $n$, is odd, and by the average of $t_{(\frac{n}{2})}$ and $t_{(\frac{n}{2}+1)}$ if $n$ is even, that is,
$$M = \left\{\begin{array}{ll} {t_{(\frac{n + 1}{2})}} & \text{if}\ n\ \text{odd}; \\ \frac{1}{2}\left[{t_{(\frac{n}{2})}} + {t_{(\frac{n}{2} + 1)}}\right] & \text{otherwise}. \end{array}\right.$$
In the presence of censored survival times the median survival is estimated by first calculating the Kaplan-Meier survival curve, then finding the value of $M$ that satisfies the equation $S(M) = 0.5$.

This can either be done, as you suggested, using a graphical technique with your curve, or using the survival function estimates used to construct said curve.

-
 @EpiGard: +1, I have posted an answer in which I give formula to do what you recommend for computing the median survival time. – ocram Nov 27 '11 at 8:45 Here you are... the main trick is to use double-dollar enclosure even for math environment. – mbq♦ Nov 27 '11 at 9:51 @mbq It seems we texified the text at the same time :) (EpiGrad: A further Markdown trick, add two spaces to insert a 
statement; useful to keep the text within the quoting environment.) – chl♦ Nov 27 '11 at 10:40 @chl Yup; anyway your version is better. – mbq♦ Nov 27 '11 at 11:43

Here is some extra:

In SAS 9.1, the $p$th sample percentile of the survival time distribution is computed as

$q_{p} = \frac{1}{2} \left( \inf \left\{ t: 1 - \hat{S}(t) \geq p \right\} + \sup \left\{ t: 1 - \hat{S}(t) \leq p \right\} \right)$

where the $t$'s are those from your observed survival times.

For example, the first sample quartile is given by

$q_{0.25} = \frac{1}{2} \left( \inf \left\{ t: 1 - \hat{S}(t) \geq 0.25 \right\} + \sup \left\{ t: 1 - \hat{S}(t) \leq 0.25 \right\} \right)$

The associated $100(1 - \alpha)\%$ confidence interval is calculated as the set

$I_{p} = \left\{ t: -z_{1 - \tfrac{\alpha}{2}} \leq \frac{\hat{S}(t) - (1-p)}{\sqrt{\hat{V}(\hat{S}(t))}} \leq z_{1 - \tfrac{\alpha}{2}} \right\}$

where $z_{1 - \tfrac{\alpha}{2}}$ stands for the $(1 - \tfrac{\alpha}{2})$th percentile of a standard normal distribution and where $\hat{V}(\hat{S}(t))$ is given by Greenwood's formula. Note that, for instance, if there is no $t$ such that $\frac{\hat{S}(t) - (1-p)}{\sqrt{\hat{V}(\hat{S}(t))}} \leq z_{1 - \tfrac{\alpha}{2}}$ then the upper limit of $I_{p}$ is undetermined.

You can also use the conftype= option to construct a confidence interval based on a $g$-transformed confidence interval for $S(t)$:

$I'_{p} = \left\{ t: -z_{1 - \tfrac{\alpha}{2}} \leq \frac{g(\hat{S}(t)) - g((1-p))}{g'(\hat{S}(t)) \sqrt{\hat{V}(\hat{S}(t))}} \leq z_{1 - \tfrac{\alpha}{2}} \right\}$

By default in SAS 9.1, conftype=linear for which $g(x)=x$. We obtain slightly different results when conftype=loglog for example but the prevailing tendency is unchanged.

Of note, the confidence of the interval is generally less than $95\%$ and SAS extends it to the next event time (not included).

-

In case you wanted a hands-on example on how to get the median survival in R:

library(survival)
data(aml)
# Get the survival curve by x groups
leukemia.surv <- survfit(Surv(time, status) ~ x, data = aml)
# Get the median time
print(leukemia.surv)

# Do a KM plot
col = c("blue", "red")
plot(leukemia.surv,
lwd=2,
col=col,
xlim=c(0, 50), ylab="Survival", xlab="Time")
# Mark the 50 % survival
abline(a=.5, b=0)
title("AML")
legend("topright", fill=col, inset=.1, legend=c("Nonmaintained", "Maintained"))


This gives you this plot:

and the print(leukemia.surv) gives the exact median survival:

> print(leukemia.surv)
Call: survfit(formula = Surv(time, status) ~ x, data = aml)

records n.max n.start events median 0.95LCL 0.95UCL
x=Maintained         11    11      11      7     31      18      NA
x=Nonmaintained      12    12      12     11     23       8      NA

-