Cox proportional hazards regression model for multistate model.
1
0
Entering edit mode
4.1 years ago

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 • 2.5k views
ADD COMMENT
0
Entering edit mode

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)
ADD REPLY
0
Entering edit mode
3.2 years ago
James • 0

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.

ADD COMMENT

Login before adding your answer.

Traffic: 1740 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6