# NOT RUN {
## Define a data set.
df <- survival::stanford2
## remove a covariate with missing values.
df <- df[, 1:4]
## next, create the Surv object inside the survreg call:
fit <- survival::survreg(survival::Surv(time, status) ~ age + I(age^2),
data = df, dist = "lognormal")
## Calculate the level 0.75 quantile wit CIs for that quantile
add_probs(df, fit, q = 500, name = c("Fhat", "lwr", "upr"))
## Try a weibull model for the same data:
fit2 <- survival::survreg(survival::Surv(time, status) ~ age + I(age^2),
data = df, dist = "weibull")
## Calculate the level 0.75 quantile with CIs for the quantile
add_probs(df, fit2, q = 500, name = c("Fhat", "lwr", "upr"))
# }
Run the code above in your browser using DataLab