Data
library(survival)
kidney
Model
model = survreg(Surv(time, censored) ~ sex + age, data = kidney)
Call:
survreg(formula = Surv(time, censored) ~ sex + age, data = kidney)
Coefficients:
(Intercept) sexfemale age
8.44411429 -0.89481679 -0.02170266
Scale= 1.653512
Loglik(model)= -122.1 Loglik(intercept only)= -122.7
Chisq= 1.21 on 2 degrees of freedom, p= 0.547
n= 76
How can I predict the survival (plus 95% CI) of both sexes for multiple time points (e.g. 30, 90, 182 days)?
Is there a trick for doing it in different scales (e.g. original time scale, probability)?
Sample code or an example will be much appreciated.
You can use survminer
package. Example:
library(survival)
library(survminer)
f1 <- survfit(Surv(time, status) ~ sex, data = kidney)
res.sum <- surv_summary(f1, data = kidney)
# define desired time points
times <- c(30, 90, 182)
summary(f1,times)