I applied survival analysis on the example df

library(survival)

set.seed(123)

data <- data.frame(
  time = rexp(500, rate = 0.02),  # Exponential survival times
  status = sample(0:1, 500, replace = TRUE),  # Event status (0=censored, 1=event)
  arm = sample(1:2, 500, replace = TRUE)  # Treatment arm
)

# Fit the survival model using Kaplan-Meier estimator

fit <- survfit(Surv(time, status) ~ arm, data = data)
fit


the output of fit is as follows


Call: survfit(formula = Surv(time, status) ~ arm, data = data)

        n events median 0.95LCL 0.95UCL
arm=1 262    132   66.5    56.9    78.7
arm=2 238    119   73.9    63.7    86.5

Is there a significant difference between the two medians? How to obtain the p value for that? Is it enough to do the logrank test to know the answer or am I missing something?

0

There are 0 best solutions below