After computing a kaplan meier model I get the km_fit
list below. How can I extract 95% confidence interval values now?
# Plot Kaplan-Meier curves
sg1_survival <- Surv(
time = sg1$`Time from breast cancer diagnosis to bone metastasis (months) (NA = unknown)`,
event = sg1$`status (=1 as all pts have bone metastasis and BC)`
)
km_fit <- survfit(sg1_survival ~ sg1$`Molecular type (0=hr+her2+, 1=hr+her2-, 2=hr-her2+, 3=TNBC)`, data = sg1)
# Calculate 95% confidence intervals? fails with "no applicable method"
ci <- confint(km_fit, level = 0.95)
It's all in km_fit
.
km_fit <- survfit(sg1_survival ~ sg1$`Molecular type (0=hr+her2+, 1=hr+her2-, 2=hr-her2+, 3=TNBC)`, data = sg1)
c <- data.frame(km_fit$time, km_fit$lower, km_fit$upper)
c
sum.time sum.lower sum.upper
1 28.37260 0.29950713 1
2 34.15890 0.06727839 1
3 137.32603 NA NA
4 14.00548 0.12504883 1
5 75.02466 NA NA