Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206459

ggforest function returns error message when used with coxph

$
0
0

when applying ggforest() to a coxph object I get the follwoing error message

error in ggforest(res.cox3, data = Selection_cox) :
class(model) == "coxph" are not all TRUE

res.cox3is the output of coxph() which includes a tt term, strata and is of class:

> class(res.cox3)
[1] "coxph.penal""coxph"

I get the same message for the following dummy data:

set.seed(132456)
'dummy survival data'
df<-data.frame(id=seq(1,1000,1), event=rep(0,1000),time=floor(runif(1000,7,10)),group=floor(runif(1000,0,2)))
'set events for a few random subjects''only within the first 100 to check results more easily'
id_list<-c(as.numeric(floor(runif(10,1,100))))
df$event[df$id %in% id_list]<-1

'set survival times for events'
t_list<-c(as.numeric(floor(runif(8,1,5))))
df2<-df[df$event==1,]
df2
df2$time<-t_list


'combine data'
df<-rbind(df,df2)
summary(df)

'Set up surfit '
require(survminer)
KM_fit<-coxph(Surv(time , event) ~ 1 + strata(group),data= df)

What am i doing wrong?

Thanks!


Viewing all articles
Browse latest Browse all 206459

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>