0

I built a cox PH model with the following code:

library(rms)
cox1 <- cph(Surv(survival_time, event) ~ var1 + var2 + var3 + var4, data = myDataBase)
summary(cox1)

Now I want to predict a survival probability at 12/24/36 months for a new individual:

library(pec)
NewPatient <- t(data.frame(c(90, 1, 8, 8)))
colnames(NewPatient) <- c("var1", "var2", "var3", "var4")
predictSurvProb(cox1, NewPatient, times = c(12,24,36))

In the predictSurvProb function from {pec} package, I don't want to use the "cox1" cph model created with the first line of code, but I would rather like to embed a raw cox model with the manually entered coefficients (that I would have taken from the first part of the code).

(ie = I am building a shinyapp in which I want to run the second part of the code without needing the first part, = without the dataBase).

How can I get the cox model equation?

Many thanks!

B_slash_
  • 309
  • 2
  • 17
  • Prediction of survival probability requires both the baseline hazard function and the covariate values. If you only have the "manually entered coefficients" then you can only generate a relative hazard ratio, not a probability. – IRTFM Mar 20 '23 at 20:59
  • I have both: hazard function built with cph function and the covariate value that i will feed to the cph function. But once the cph function is built, I want to rebuild it manually (without using the database)... i am not sure if i am asking properly, am I ? – B_slash_ Mar 22 '23 at 08:32
  • The `cph` function from pkg:rms is quite different than the coxph function from pkg:survival. I don’t know if the survival::basehaz function will work with results of `cph`. I think Harrell includes a `Hazard` function that you might want to use as a model. – IRTFM Mar 25 '23 at 05:47
  • Still do not see a [MCVE] and I don’t spend much effort on Q’s that are incomplete. – IRTFM Mar 25 '23 at 05:50
  • thank you for your help, i finally managed to get the shinny to work, without embedding the database in the code: so I dont need the manual CPH. thanks again – B_slash_ Apr 28 '23 at 10:45

0 Answers0