0

I have a data set of patients on a waiting list for an organ transplant. Event is death time. The set containts the following variables: patientID, time, status , age, gender, bmi, disease. I made a model of the survival time of a patient on the waiting list as function of the covariates age, gender, bmi and disease by using accelerated failure time models, in which the baseline distribution was given by a Lognormal distribution.

fitLog <- survreg(Surv(time, status)~age+gender+bmi+disease, dist = "lognormal", data = patients)

Now, I need to give a prediction of the survival curve for a male Fibrosis (disease = 2) patient of age 60 and bmi of 23 and I also need to add a pointwise confidence interval to this curve.

new_data <- with(patients, data.frame(gender = c(1),
                                  age = c(60),
                                  bmi = c(23),
                                  disease = c(2)))

plot(predict(fitLog, newdata=new_data, type="quantile", p=seq(.01,.99,by=.01)), seq(.99,.01,by=-.01), col="red", type="l", xlab = "Time (days)", ylab = "Survival probability (%)", main="Survival time")

So when I run this code, I get my prediction model, but now I have to add a pointwise confidence interval to this plot. How do I have to do this? I already tried conf.type but that didn't do anything.

Edit: I used the following code to calculate and plot the confidence intervals:

pred <- predict(fitLog, newdata=new_data, 
type="quantile",p=seq(.01,.99,by=.01), se=TRUE)

plot(pred$fit - 1.96*pred$se.fit, seq(.99,.01,by=-.01),col="red", type="l", 
lty=2, xlab = "Time (days)", ylab = "Survival probability (%)", 
main="Survival time")

lines(pred$fit + 1.96*pred$se.fit,seq(.99,.01,by=-.01),col="red", type="l", 
lty=2)

lines(predict(fitLog, newdata=new_data, 
type="quantile",p=seq(.01,.99,by=.01)),seq(.99,.01,by=-.01),col="red", 
type="l")

So now I can plot the confidence interval, but the question is now how to make the dotted line continue until the end of the follow up?

image of the plot

  • Does this help? https://stackoverflow.com/questions/9151591/how-to-plot-the-survival-curve-generated-by-survreg-package-survival-of-r or this http://blogs2.datall-analyse.nl/2016/02/19/rcode_confidence_intervals_parametric_survival_models/ or maybe try the `broom::tidy` function https://www.rdocumentation.org/packages/broom/versions/0.5.2/topics/tidy.survreg – MrFlick May 25 '19 at 18:48
  • 1
    The survival probability can not be < 0 by definition. Thus lower CI can also not go below 0. – adibender May 27 '19 at 11:27
  • Voting to close as unclear. Makes no sense to ask for survival curve to cross the zero line. – IRTFM May 29 '19 at 16:17
  • unless the question is how to make the dotted line continue until the end of the follow up? But not clear from the question – adibender May 31 '19 at 16:13
  • yes, that's my question, I will edit it! – Dries De Witte Jun 01 '19 at 17:02

0 Answers0