# Survival Analysis results are counter intuitive, where am I going wrong?

I am using Survival Analysis to analyse a data set, but i'm having a bit of trouble.

The data consists of everyone who has/has not been terminated from employment within a 4 year period. The aim of the analysis is to uncover the median time to termination.

The data includes 400 people who has experienced the event and 2275 people who have not.

Looking at the raw data, 150 people have remained employed between 30-48 years. The remaining 2525 people have been employed for less than 30 years. The average time spent working in the organisation is 4 years.

However, the median time to survival using survival analysis is 40 years.

I'm very familiar with the organisation and this median time to leaving is counter intuitive. Am I missing something?

My code is below

You will see, I start by calculating the length of time from when they began working in the organisation and when they leave (variable name is 'yrs'). If they have not been terminated, today's date is used as they are still employed in the organisation (perhaps this is where i'm going wrong?).

Then I create a survival curve using 'yrs' and 'termid', where termid is an indicator variable, indicating if the observation has been terminated or not.

The median survival time of 40 years is then returned

Is there an issue with my code? Or is it expected that so few observations could carry this much weight in a Survival Analysis.

#find survival time #calculating the number of days between last follow up date and date of starting in the organisation
leaversanalysis = leaversanalysis %>%
mutate(
yrs =
as.numeric(
difftime(Term.Date,
Date.Joined.Organisation,
units = "days")) / 365.25
)

#Indicator variable for termination is 'termid'
#Kaplan Meier estimator for any termination (termination =1, no termination =0)
a <- Surv(leaversanalysis$$yrs, leaversanalysis$$termid)

#Create survival curve
surv_curvleave <- survfit(Surv(yrs, termid) ~ 1 , data = leaversanalysis)
surv_curvleave



Median survival here is the time at which 50% of your participants would still be non-terminated.

The lower the risk (hazard) of an event (in your case being "terminated"), the longer it will take to get to the point where 50% of participants have had that event.

An example:

simulate data similar to yours:

set.seed(129)
yrs1 <- round(rbeta(n=2225, shape1 = 1.3, shape2 = 8)*48,1)
yrs2 <- runif(450, min=0, max=48)
yrs <- c(yrs1,yrs2)
termid <- sample(x = c(rep(1, each = 400), rep(0,each=2275)), size = 2675)
data <- data.frame(yrs,termid)
sum(yrs>30) # 167 people employed over 30 yrs
hist(yrs, breaks = 20)


Your code is fine. The survival plot below should reveal why the "median survival" is what it is.

fit <- survfit(Surv(yrs,termid) ~1, data = data)
plot(fit, xlab = "years", ylab = "probability of not being terminated")
abline(h=0.5); abline(v=43.3)
fit


Call: survfit(formula = Surv(yrs, termid) ~ 1, data = data)

n  events  median 0.95LCL 0.95UCL
2675.0   400.0    43.3    40.1    46.2


The reported median survival here is 43.3 years.

You have said "this median time to leaving is counter intuitive". What you are studying is the median time to being terminated. If people are leaving for other reasons, then using these methods, they are censored, and so do not affect the position of the survival curve.

The name of the statistic "median survival time" can be a bit misleading - the median survival time of a population is not simply the median of survival times. That is, you can't simply take all the tenure lengths, find the median one, and be done. This is because many people leave for other reasons than being fired, so they drop out of the population (they are censored). If a person leaves voluntarily after 1 year, you know they would have survived at least 1 year without termination, but you can't use that 1 year as a data point for time-to-termination itself. In a population where no one is fired, you never reach median survival, but you will always be able to find a median of tenure times (which isn't nearly as useful).

Rather, the median survival time is the time at which 50% of the uncensored population remains. You note that in your data, you have 400 people who were terminated, and 2275 who were not - only 15% of the population is ever terminated, so it makes sense that you either never see a time when 50% of your workforce has been fired, or see it only very late (when the remaining population is small). It would be possible to see this earlier on, as you could have 1875 people quit over the years, leaving 800 people, 400 of which are later fired. But that would require a very unusual skewing of voluntary quitting in the beginning, followed by a rash of firings at the end. In a population where the overall event rate is well below 50%, you typically won't hit median survival, barring unusual patterns in early censors and late events. Your median survival time is very long, which suggests there are only a handful of people who remain after a 40-year tenure, and half of them get fired.