Calculate survival prediction using Cox proportional hazard model in R

I am trying to calculate the Survival prediction using the Cox proportional hazard model in R.

    library(survival)
    data(lung)
    model<-coxph(Surv(time,status ==2)~age + sex + ph.karno + wt.loss, data=lung)
    predict(model, data=lung, type ="expected")

      

When I use the above code, I get the Cumulative Hazard Prediction corresponding to the formula

    h^i(t)=h^0(t)exp(xβ€²iΞ²^)

      

But my concern is to predict survival according to the formula,

    S^i(t)=S^0(t)exp(xβ€²iΞ²^)

      

How can I predict survival in R? Thanks in Advance.

+4


source to share


2 answers


You can use either predict

or survfit

. With, predict

you need to provide the newdata argument with a list with values ​​for all variables in the model:

predict(model, 
      newdata=list(time=100,status=1,age=60,sex=1, ph.karno=60,wt.loss=15),
      type ="expected")
[1] 0.2007497

      

There is a method for constructing objects for protection:



?survreg
png(); plot(survfit(model)); dev.off()

      

enter image description here

0


source


my question may be related to this post.

I use Cox's proportional hazard regression to determine the relationship between physical behavior (physical activity, sedentary lifestyle, and sleep) and mortality. To build on these findings, I created hypothetical combinations for physical behavior to see how they relate to mortality. for example, what happens to the likelihood of death if physical activity is increased by 1 hour and sleep is decreased by 1 hour while maintaining a sedentary time constant. by doing this step, I obtained the survival probability for each new hypothetical combination of physical behavior for each time point during the observation.

My question is how to calculate the risk ratio from the probabilities of survival obtained at each time point in r?

Also, we get the probabilities at each point in time of observation, how do we get that one number in relation to the risk that the researchers report in the paper based on those probabilities?

Thereafter,



I also want to calculate how big the difference is between the probabilities obtained on the basis of the new combination and the reference combination (the average physical behavior in which we did not change anything in the physical behavior). this step will show me the size of the effect due to a hypothetical change in physical behavior.

after that I want to know if this difference in probabilities is significant.

Any suggestion on how I can calculate the difference between survival probabilities and the confidence interval for that difference at each point in time?

Regards, Nidhi

0


source







All Articles