Hi All,

Apologies for the simple question, but I could not find a straightforward
answer based on my limited knowledge of survival analysis.

I’m trying to obtain the predicted median survival time for each subject on
a new dataset from a fitted coxph{survival} or cph{rms} object. Would the
quantile.survfit function (as used below) return the expected median
survival? Why this function returns NAs in this case, when all predictors
have non-missing values?

As an alternative, I’ve tried to use the Quntile{rms} function as in my
second chunk of code, but in this case I get an error message (most likely
due to my lack of understanding as well).

library(MASS)

library(survival)

library(rms)

data(gehan)

leuk.cox <-coxph(Surv(time, cens) ~ treat + factor(pair), data = gehan)

leuk_new <- gehan[1:10, ] # take first 10 patients

pred_leuk <- survfit(leuk.cox, newdata=leuk_new)

quantile(pred_leuk, 0.5)$quantile



### alternative using rms

leuk.cox.rms <-cph(Surv(time, cens) ~ treat + factor(pair), data = gehan,
surv = T)

med <- Quantile(leuk.cox.rms)

Predict(leuk.cox.rms, data = leuk_new, fun=function(x)med(lp=x))

>Error in Predict(leuk.cox.rms, data = leuk_new, fun = function(x) med(lp =
x)) :

  predictors(s) not in model: data


Thank you for your help.

Best,

Lars.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to