# How to calculate the individual probability of survival of each individual in a dataset using survival analysis?

I have developed a cox regression model to find out the parameters.

    fit_cox_Price_plan_device <-  coxph(Surv(df_life_4$$Line.Tenure.In.Days,df_life_4$$Churn.Flag==0)~df_life_4$$Subscriber.Activity.Price.Plan.Code+df_life_4$$Months.on.Price.Plan+df_life_4$$Device+df_life_4$$Months.on.Device + df_life_4$$Total.MOU + df_life_4$$Total.Active.Subscribers + df_life_4$$GPS.Flag+df_life_4$$WIFI.Flag + df_life_4$$Multimedia.Flag + df_life_4$$Price.Plan.Change.Flag)
summary(fit_cox_Price_plan_device)
pred_fit_cox_Price_plan_device<- survfit(fit_cox_Price_plan_device)
summary(pred_fit_cox_Price_plan_device,times=c(1,30,60,90*(1:20)))


Now the result I obtain from this summary is like this:

time   n.risk  n.event  survival  lower 95%CI  upper 95% CI
1      165805   7316      0.963         0.962        0.964
30     149249   6109      0.929         0.928        0.930


And so on. My question is can anyone write an R code here that estimates the survival probability of each individual on the 500th day given that they already survived for more than 400 days?

 predicted_days_dflife_4<-predict(pred_fit_cox_Price_plan_device,type='expected')
basehaz_cox<-basehaz(fit_cox_Price_plan_device)
predicted_days_dflife_4<-as.data.frame((exp(-53.12277))^exp(predicted_days_dflife_4)*2.4)
df_life_4<- df_life_4[1:173258,]#Here 53.12277 is the approximation of the baseline hazard integrated upto time t but I know this is wrong
individual_prob_on450<-cbind(predicted_days_dflife_4,df_life_4$$Subscriber.Line.Id,df_life_4$$Total.Active.Subscribers,df_life_4$$Total.MOU,df_life_4$$Months.on.Device,df_life_4$$Months.on.Price.Plan,df_life_4$$Subscriber.Activity.Price.Plan.Code,df_life_4$Market.Name) write.csv(individual_prob_on450,file = "individual_probability_on_450_day.csv")  ## 1 Answer You can do this by dividing the survival probability at 500 days with the survival probability at 400 days or better by doing a landmark type of analysis in which you only consider the patients at risk at 400 days. Check these examples with the lung dataset from the survival package: library("survival") # Cox model in the whole dataset fm <- coxph(Surv(time, status) ~ age + ph.karno, data = lung) # Survival probabilities at 400 and 500 days sfit <- summary(survfit(fm), times = c(400, 500)) sfit$$surv[2] / sfit$$surv[1] # landamark approach; consider only the patients at risk at # 400 days, fit the Cox model to them, and predict at 500 days lung2 <- lung[lung$time >= 400, ]
gm <- coxph(Surv(time, status) ~ age + ph.karno, data = lung2)
summary(survfit(gm), times = 500)

• But can the individual probability on a certain time = t not be obtained? – Nothing Sep 28 '18 at 8:25
• I'm not sure what you mean... – Dimitris Rizopoulos Sep 28 '18 at 8:26
• Person1 :probability of survival on 500th day given he has already lived for 400 days .The same for Person 2 and so on... – Nothing Sep 28 '18 at 8:27
• More specifically for(each person):Calculate P(t=500|t>400) End loop. – Nothing Sep 28 '18 at 8:29
• If you want to calculate these probabilities for specific persons, you can use the newdata argument of the survfit() function to provide their covariate information. – Dimitris Rizopoulos Sep 28 '18 at 8:30