Fits a Kaplan-Meier survival curve, optionally stratified by a grouping variable. Returns the survfit object, log-rank test, and summary statistics.
Value
List with components: - `fit`: survfit object - `logrank`: survdiff result (NULL if no strata) - `logrank_p`: log-rank p-value (NA if no strata) - `median_survival`: named vector of median survival times - `n_per_group`: sample sizes per stratum - `strata`: the stratification variable used