1

我有一个导入 R 的数据集。我成功地在数据集上运行了 survfit。我有一列显示患者存活的时间,另一列显示患者是否存活的 (0/1) 结果。我知道尝试对coxph()数据进行操作,并且正在使用以下内容。

coxph <- coxph(Surv(mydata$V11, mydata$event), method ="breslow")

但是,我不断收到以下错误。我试过as.numeric在变量上使用,但这仍然不能解决问题。我还尝试mydata$从上面代码行中的每个变量中删除。谢谢你。

Error: $ operator is invalid for atomic vectors
4

1 回答 1

0
  1. 为防止出现此错误,您必须显式包含"formula ="in coxph(),如下所示。

  2. 此外,如果您尝试对 null 模型进行建模,则需要~ 1Surv().

coxph <- coxph(formula = Surv(mydata$V11, mydata$event) ~ 1, 
               method ="breslow")
于 2021-09-11T09:00:15.670 回答