I have designed the following data set with survival times for two different groups:
Timesexample<- c(6,6,6,7,10,13,16,22,23,6,9,10,11,17,19,20,25,32,32,34,35, 1,1,2,2,3,4,4,5,5,8,8,8,8,11,11,12,12,15,17,22,23) Eventsex<-c(1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) Group<-c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) object<-Surv(Timesexample, Eventsex) Group <- factor(Group, labels = c("A", "B")) Tablex<-data.frame(object, Group)
I am trying to compare both survival curves in order to get the p-values for Long-rank, wilcoxon, tarone, peto and flemington-harrington tests. I have seen that function
comp() from package survMisc can perform such tests, however when I applied
comp() to my data, I get the following error message:
library(survMisc) fit = survfit(Surv(Timesexample, Eventsex) ~ Group, data = Tablex) comp(fit)$tests$lrTests
no applicable method for 'comp' applied to an object of class "survfit"
Can anyone help me to solve this problem? I have already tried comp(ten()) as some post suggest, but it doesn't seem to work either.