I have a Cox regression which employs strata()
and a tt()
.
How can i plot this? All the usual suspects (ggsurvplot
, hazard.ratio.plot
) dont work for a coxph.penal
format.
Here is some dummy data:
set.seed(132456)
'dummy survival data'
df<-data.frame(id=seq(1,1000,1), df<-data.frame(id=seq(1,1000,1), event=rep(0,1000),time=floor(runif(1000,7,10)),group=floor(runif(1000,0,2)),
var1 = rnorm(1000, 1, 3), var2 = seq(1,1000), ID=rep(c("A","B","c","D", 250))))
'set events for a few random subjects'
id_list<-c(as.numeric(floor(runif(500,1,1000))))
df$event[df$id %in% id_list]<-1
'set survival times for events'
t_list<-c(as.numeric(floor(runif(394,1,5))))
df2<-df[df$event==1,]
df2$time<-t_list
'combine data'
df<-rbind(df,df2)
summary(df)
'Set up cox regression:'
library(survival)
coxph(Surv(time , event) ~ tt(var2) + strata(group)+ var1+frailty(ID) ,data= df)
Is there a way to plot a curve like this, or is it just not possible, due to the frailty()
term?
If this is not possible, can I manually plot hazard rates for each covariate?
Thanks for any advice!!!