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?