I'd like to learn about how to get confidence interval from the prediction of value and standard error from a weibull survreg model in R "survival".
R doc for predict.survreg has an example showing a plot not only gives the fit
of the prediction of a weibull survreg model but also the fit+2*se.fit
and fit-2*se.fit
. Then the range from fit-2*se.fit
to fit+2*se.fit
corresponds to what confidence interval? And for a given confidence interval, how to choose the n for fit +/- n*se.fit
to obtain that confidence interval? Following is the code:
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)
For normal distribution, I think for 95% confidence interval, can use fit +/- 1.96*se.fit
. I'm not sure whether it works for a weibull survreg model.