# How to make prediction in survival analysis using R?

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?

library(survival)
attach
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))  • 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. Dec 10, 2014 at 12:03 • What makes you think this expression is for the exponential model? dist = "w" means the model is Weibull. Dec 10, 2014 at 13:04 • Is there a reason you cannot use the predict function? The S3 method is described here. Dec 10, 2014 at 13:31 • 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 Dec 10, 2014 at 16:14 • 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 Dec 10, 2014 at 16:18 ## 1 Answer 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.