library(tidyverse) dsl_csv <-"~/dsl/102725_DSL_df_adac.csv" dsl_df <- read.csv(dsl_csv, header = TRUE) #https://stats.oarc.ucla.edu/wp-content/uploads/2025/02/survival_r_full.html dsl_df <- dsl_df |> filter(source == "c1") library(survival) library(broom) dsl_df$ttr_weeks <- dsl_df$TTR / 168 trial.survival <- Surv(dsl_df$ttr_weeks) trial.model <- coxph(trial.survival ~ isAuthorWMF + median_PC3_adac + week_index + median_gerrit_loc_delta + median_gerrit_reviewers + olmo_BI_prop_adac, data=dsl_df) summary(trial.model) trial.tab <- tidy(trial.model, exponentiate=T, conf.int=T) ggplot(trial.tab, aes(y=term, x=estimate, xmin=conf.low, xmax=conf.high)) + geom_pointrange() + # plots center point (x) and range (xmin, xmax) geom_vline(xintercept=1, color="red") + # vertical line at HR=1 labs(x="hazard ratio", title="Hazard ratios and 95% CIs") + theme_classic() surv.at.means <- survfit(trial.model) plot(surv.at.means, xlab="weeks", ylab="survival probability")