简体   繁体   中英

Calculate the Survival prediction using Cox Proportional Hazard model in R

I'm trying to calculate the Survival prediction using 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's prediction corresponding to the formula

    h^i(t)=h^0(t)exp(x′iβ^)

But my concern is all about predicting the Survival corresponding to the formula,

    S^i(t)=S^0(t)exp(x′iβ^)

How do I predict the Survival in R? Thanks in Advance.

You can use either predict or survfit . With predict you need to give the newdata argument a list with values for all the 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's a plot method for survfit objects:

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

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM