# Why does the survival probability of the survival package return 0% at the end of the time horizon when there are survivors in the dataset?

I've just started using the survival and survminer packages in R and am trying to understand its output. In the code below I create a dataframe with the first 12 rows of my actual dataset, as representative of the issue/question. In this representative data:

• ID = unique identifier for each element
• time = survival time for the element in months where value > 0 means death (the month that death occurs) and value = 0 means no death (right censored) during the study period
• status = the element's censoring status where 1=censored and 2=dead
• node = one of the variables associated with each element where I try to assess its association with the probability of death

Running length(which(testDF$status == 2))/nrow(testDF) shows a death rate of 66.67% with this data, but the survival probability curves shown in the image below end at 0%. Should they not be ending at 66.67% at least for the average of all the data? What am I doing wrong here or am I misinterpreting survival probability? Code: library(ggplot2) library(survival) library(survminer) testDF <- data.frame( ID = 1:12, time = c(0,34,0,12,12,21,0,0,39,11,13,26), status = c(1,2,1,2,2,2,1,1,2,2,2,2), node = c("C","C","B","A","C","C","B","C","B","C","A","B") ) fit <- survfit(Surv(time, status) ~ node, data = testDF) ggsurvplot(fit, pval = TRUE, conf.int = TRUE, linetype = "strata", surv.median.line = "hv", ggtheme = theme_bw() ) # percentage of deaths length(which(testDF$status == 2))/nrow(testDF)


Modifying the OP above to reflect accepted solution:

Revised dataframe to reflect paulduf solution to correctly represent censored data (in my data, no deaths within the 40 month study is "censored"), with commented revised graphic beneath:

testDF <- data.frame(
ID = 1:12,
time = c(40,34,40,12,12,21,40,40,39,11,13,26), # 40 month study window (0's for no death changed to 40)
status = c(0,1,0,1,1,1,0,0,1,1,1,1), # 0 = censored, 1 = death
node = c("C","C","B","A","C","C","B","C","B","C","A","B")
)

# percentage of deaths summary
length(which(testDF$$status == 0))/nrow(testDF) length(which(testDF$$status == 0 & testDF$$node == "A"))/length(which(testDF$$node == "A"))
length(which(testDF$$status == 0 & testDF$$node == "B"))/length(which(testDF$$node == "B")) length(which(testDF$$status == 0 & testDF$$node == "C"))/length(which(testDF$$node == "C"))


In the plot confidence intervals are removed for enhanced clarity: • Without understanding what the shaded areas on your chart are trying to show (they do not reach the bottom), the coloured vertical lines are for the uncensored observations for each node. (so for blue node C the four values 11, 12, 21, 34) and so go down to the bottom. The black vertical lines are the "median" from the fit for each node (for node C this is 16.5 - halfway between 12 and 21 - while 0.95LCL is 11 and 0.95UCL is NA). Your censored values (all with time 0) do not seem to have affected the graph or the fit Feb 27 at 9:19

• time = survival time for the element in months where value > 0 means death (the month that death occurs) and value = 0 means no death (right censored) during the study period
• status = the element's censoring status where 1=censored and 2=dead

The data you entered in the model is corrupted. The setting of "value=0" for a censored observation is the cause of the "bug". The information that death did not occur for an individual within the study period is already contained in status. Set time=T where T is the observation time (end of study date - enrollment date) and you should see the expected behaviour.

As Henry noticed,

Your censored values (all with time 0) do not seem to have affected the graph or the fit

I think indeed if you write the math you see they have no influence so the model is not fitted on the data you expect.

• Good catch! (+1) I hope that you will continue contributing to the site.
– EdM
Feb 27 at 15:13
• Hi, I modified my OP to reflect your solution. Please let me know if you see anything wrong in my modified example. Feb 28 at 7:21