1

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.

user438383
  • 5,716
  • 8
  • 28
  • 43
EmmaM
  • 11
  • 3
  • Welcome to Stack Overflow. There are various approaches if the assumption is violated, e.g. stratification (which `survival` supports) or splines (e.g. a Royston Parmer model with an interaction between the spline constant and the time-varying coefficient). You still need to test proportionality afterwards to see if they were effective. Please see [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) to see how to update the question with sample data so people can post an example of an approach as an answer. – SamR Jun 27 '23 at 12:47
  • @SamR - I tried making a dataframe in the original question, hope that helps. – EmmaM Jun 27 '23 at 13:09
  • 1
    Where does year come from? Is `SerialTime` in days so it's that value / 365.25? If so the proportional hazards assumption isn't violated - it can't be violated by the time variable. The proportional hazards assumption is that the impact of the covariates on the hazard function are proportional over time, not that that hazard function itself is constant over time. – SamR Jun 27 '23 at 14:05

0 Answers0