r/rprogramming • u/Top_Replacement_1262 • 18h ago
Plot curves for coxph frailty model
Hello I am asking if anyone is aware of how to draw adjusted cum hazard and survival curves after running a frailty model using coxph. I am using the Surv(start, stop ,event status) framework with gap times. Importantly, I have had to stratify a binary variable as it violated the proportional hazards assumption - using strata(var). The goal is to do curves for the overall sample (showing the two strata), and then separately for each individual variables. I have an interaction and it would be good to plot the hazards of 1 variable versus the actual values of the other variables. Any guidance, particularly code implementation, of this would be very helpful.
I am a clinician and not a statistician, but also not trying to use AI at all as Im against it and dont want to have to use it and then declare it.
I am aware of other setups for example cluster() option for robust standard errors as well as frailtypack, coxme, etc. The curves could be drawn in easily with the cluster() option. However, the research question very much needs a frailty model. Also Ive written out the whole thing based on the frailty findings and Kaplan Meier curves...the findings dont necessarily remain with other modelling options which is a problem.




