Statistician
Statistician

Reputation: 11

Facing an error that an id statement is required for multi-state models while running cox model in R

i am trying to run cox regression model in R studio but facing same error every time.

cox.model <-coxph(Surv(dat$los, dat$died) ~ gender, data=dat)
Error in coxph(Surv(dat$los, dat$died) ~ gender, data = dat) : 
  an id statement is required for multi-state models

Here is data:

enter image description here

Upvotes: 1

Views: 1887

Answers (1)

Shivraj Thutte
Shivraj Thutte

Reputation: 1

Check the type of event i.e., dead in your case. It might be a factor or character. Just convert it into a numeric. You will not get the same again. Event you can plot forest plot.

Upvotes: 0

Related Questions