Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot the survival curve generated by multi-variate survreg

This question follows on from the question here in that we want to plot a multi-variate model.

Lets say we want to plot the Survival function from the example in survreg from the package release notes

Where the model is

survreg(Surv(time, status) ~ ph.ecog + age + strata(sex), lung)

From what I understand the following problem seems to address the problem, but does not provide a data set and only uses one variable. Where in this example, we have two continuous variables and one factor

like image 907
user08041991 Avatar asked Sep 26 '22 15:09

user08041991


1 Answers

Plot for the predicted survival curve for hypothetical individual with mean of lung$age and the mode of lung$ph.ecog (following the example in the help page):

?predict.survreg
pct <- 1:98/100
ptime <- predict(res, newdata=data.frame(ph.ecog=1, age=62.44737, sex=1),  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)

enter image description here

like image 92
IRTFM Avatar answered Oct 11 '22 16:10

IRTFM