# How to calculate the confidence interval around difference in median survival time between two (censored) groups?

I need the confidence interval around the difference in median survival time in a two-sample test. I have data for right-censored survival time for a treatment and a control groups, and I want to estimate the magnitude of the difference in median survival time. I have found ways to calculate confidence intervals around one population, or even confidence intervals around the difference in survival of 2 populations at a fixed time, but I'm looking for the confidence interval around difference in median survival time.

Example:

timeControl <- c(16, 17, 18, 31, 32, 33, 34, 35, 36, 37, 40, 45, 50, 81)
censorControl <- rep(1, 14)
timeTreatment <- c(10, 36, 38, 45, 47, 51, 63, 69, 102, 96, 105, 125)
censorTreatment <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0)


Desired output is in the form of a 95% CI, e.g. (x, y).

Are there packages in R or Python that do this calculation that I'm missing? If not, how would I implement the calculation?

Note, I've looked at the R packages: km.ci, controlTest, bpcp, and survival, and the python package lifelines, and they don't appear to do what I'm asking.

• I don't believe the median survival time difference has a distribution from which one could sample and create a CI. Mar 28 '18 at 2:25

I ended up using survRM2::rmst2() to calculate the confidence interval around the difference in survival times. It doesn't calculate a confidence interval of the median, but it incorporates censoring so I can censor that have a large impact on the mean (e.g. censor events from the longest 20% of events).