1

我首先在 R 中建立了一个 cox 模型:

test1<- test[1:20,]
model.1 <- coxph(Surv(test1$days,test1$status==1) ~ test1$MTT+test1$ADC,data=test1)

当我试图像这样预测下一个病人的生存时:

covs1 <- data.frame(test[21,]$MTT,test[21,]$ADC)
summary(survfit(model.1, newdata= covs1, type ="aalen"))

它给了我太多的生存结果,警告是“'newdata' 有 1 行,但发现的变量有 20 行”仅供参考,有 20 个事件,结果包含 20 个生存结果。

4

1 回答 1

1

作为预测基础的 datframe 中的列名必须与模型公式的 RHS 中的列名相同。我认为除非您执行以下操作,否则您的将不合格:

test1<- test[1:20,]
model.1 <- coxph( Surv(days, status==1) ~ MTT + ADC, data=test1)

covs1 <- test[21, c("MTT", "ADC")]
 # then do your prediction

您不应该使用$向 Surv 提供参数。在数据框的环境中构建模型很重要。

于 2017-06-28T22:32:31.880 回答