I have made my survival analysis using survfit and ggsurvplot, but as far as I can tell the assumption of proportional hazards is "violated". So i want to look at the HR for my two groups in different time intervals (Year 0 - 3 and from year 3 until end).
my variables are: idnumber, Serialtime (in days), type (compliant or non-compliant) and event1 (1= event, 0 = censored)
KMcurve <-survfit(Surv(SerialTime, event1)~type, data = KM)
ggsurvplot(KMcurve, xlim=c(0, 2191.5), break.x.by = 365.25, ylab="", xlab="Days",
pval= TRUE, risk.table = "nrisk_cumevents", risk.table.title="",
legend.labs=c("Non-compliant", "Compliant"), legend.title="",
surv.scale = "percent", palette="nejm",
title="Disease Free Survival", risk.table.height=.25,
censor = TRUE, conf.int = TRUE,
axes.offset = TRUE)
coxph(Surv(SerialTime, event1)~type, data = KM) %>%
tbl_regression(exp = TRUE)
which gives me a HR of 0.53 (95% CI, 0.31-0.88)
tried making a dataframe:
dat <- data.frame(
id = 1:100,
SerialTime = as.numeric(sample(95:2900, 100, replace = TRUE)),
type = as.numeric(rep(1:2)),
event1 = as.numeric(rep(0:1)))
dput(dat)
If you need more information, please let me know.
i think i need to use Survsplit, im just not sure how.