I have fitted a survival model in R which is below. However, I am not sure how to make predictions. I tried predicting the survival probability that a patient whose design matrix is X lives longer than 100 days, but no matter what design matrix I use, the probability is always 0. What do you think I am doing wrong?

weibull <- survreg(Surv(time,status)~celltype + karno+diagtime+age+prior+trt ,dist="w")
beta[,1] <- as.matrix(c(weibull$coef))
x <- as.matrix(c(1,1,0,0,80,10,65,0,2)) #Design matrix
lambda <- beta[,1]%*%x
1 - (1 - exp(-lambda*100))
  • $\begingroup$ You have requested that a Weibull model be fit but are using the expression for an exponential model, unless I'm missing something. If you replace survreg with psm in the rms package you can use latex(fit object, file='') to see full algebraic form of fit. psm calls survreg. $\endgroup$ Dec 10, 2014 at 12:03
  • $\begingroup$ What makes you think this expression is for the exponential model? dist = "w" means the model is Weibull. $\endgroup$
    – Günal
    Dec 10, 2014 at 13:04
  • 3
    $\begingroup$ Is there a reason you cannot use the predict function? The S3 method is described here. $\endgroup$
    – cdeterman
    Dec 10, 2014 at 13:31
  • $\begingroup$ Actually I was hoping to see how fitted values are calculated in survival analysis. That is why I wanted to calculate them by hand, but thanks for the link $\endgroup$
    – Günal
    Dec 10, 2014 at 16:14
  • $\begingroup$ I used the predict function, but the fitted values are not probabilities. I want to calculate the probabilities. For example living longer than 100 days $\endgroup$
    – Günal
    Dec 10, 2014 at 16:18

1 Answer 1


This is the code, copied & pasted from the help file to the function predict.survreg, which relates to predicting Weibull models:

lfit <- survreg(Surv(time, status) ~ ph.ecog, data=lung)
pct <- 1:98/100   # The 100th percentile of predicted survival is at +infinity
ptime <- predict(lfit, newdata=data.frame(ph.ecog=2), type='quantile',
                 p=pct, se=TRUE)
matplot(cbind(ptime$fit, ptime$fit + 2*ptime$se.fit,
                             ptime$fit - 2*ptime$se.fit)/30.5, 1-pct,
        xlab="Months", ylab="Survival", type='l', lty=c(1,2,2), col=1)

Hope this helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.