Hey guys, I am stuck here with this error message while running survival analysis in R:
> hcm.cox <- coxph(Surv(FU, MACE) ~ Fibrosis + MaxLVWT, data = hcm)
Error in coxph(Surv(FU, MACE) ~ Fibrosis + MaxLVWT, data = hcm) :
an id statement is required for multi-state models
FU
stands for follow-up period (numeric) and MACE
stands for events (factor; 1 = no, 2 = yes). Fibrosis
is a binary factor (1 = -
, 2 = +
) and maxLVWT
is a continuous numeric variable.
Before running the analysis, I've converted MACE
and Fibrosis
into binary factors by doing so:
> hcm$MACE <- factor(hcm$MACE, levels = c("N", "Y"), labels = c("1", "2"))
> hcm$Fibrosis <- factor(hcm$Fibrosis, levels = c("-", "+"), labels = c("1", "2"))
I can't understand why the error keeps popping up, please help me out!
Please use the formatting bar (especially the
code
option) to present your post better. You can use backticks for inline code (`text` becomestext
), or select a chunk of text and use the highlighted button to format it as a code block. I've done it for you this time.