This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Cox proportional hazards regression model for multistate model.

I have similar data in the following format:

id  start   end event   sex biomarker
1   0   2.3 0   M   0.52
1   2.3 4.5 0   M   0.02
2   0   0.5 0   F   0.75
2   0.5 1   1   F   0.55
3   0   2   0   F   0.56
3   2   3.9 0   F   0.11
4   0   1   0   M   0.43
4   1   2.8 1   M   0.28

I am running the following code after importing reading in my data for a Cox proportional hazards regression model for multistate model:

model1 <- coxph(Surv(data$'start', data$'event')~ data$sex + data$biomarker, id=data$id, data=data)

However, I get the following error:

Error in coxph(Surv(data$'start', data$'event') ~ data$sex + data$biomarker, id = data$id, : Argument id not matched
Traceback:

1. coxph(Surv(data$'start', data$'event') ~ data$sex + data$biomarker, id = data$data$id, 
 .     data)
2. stop(gettextf("Argument %s not matched", names(extraArgs)[indx == 
 .     0L]), domain = NA)

I also tried it in Rgui and got the following error:

Error in coxph(Surv(df$time, df$event) ~  df$sex + df$biomarker, data = df, id = df$id) : 
  object 'id' not found

Is there something I am missing?

r cox survival

What is the output of str(data)?

Perhaps you just need to do:

model1 <- coxph(Surv(start, event, data = data)~ sex + biomarker, id = 'id', data = data)

1 answer

In my experience, this occurs when using a survival package whose version is < 3.0.

You can try sessionInfo() to see which version of survival you are using.

Log in to answer this question.