我正在尝试使用包survAUC估算生存模型的AUC。运行代码后,我收到一个错误:
Error in AUC.hc(Surv.rsp, Surv.rsp.new, lpnew, times) :
NA/NaN/Inf in foreign function call (arg 6)
出现此错误的原因可能是什么?如何将其删除?我的代码是:
head(duration)
Event_ID Time Status Season Time_of_day
1 1 15 1 1 0
2 2 30 1 0 1
3 3 15 1 1 0
4 4 15 1 0 0
5 5 45 1 0 1
6 6 105 1 0 1
TR<-duration[1:2176,]
TE<-duration[2177:6528,]
clearance5<-survreg(Surv(duration$Time)~Season+Time_of_day,data = duration,dist = 'weibull',na.action=na.omit)
lpnew<-predict(clearance5,TE)
Surv.rsp<-Surv(TR$Time)
Surv.rsp.new<-Surv(TE$Time)
times<-seq(60,90,105)
auc_hc<-AUC.hc(Surv.rsp,Surv.rsp.new,lpnew,times)
答案 0 :(得分:0)
我认为以下代码应该有效:
library(survival)
library(survAUC)
duration <- na.omit(duration)
TR <- duration[1:2176,]
TE <- duration[2177:6528,]
clearance5 <- survreg(Surv(Time, Status) ~ Season+Time_of_day,
data = TR, dist='weibull', na.action=na.omit)
lpnew <- predict(clearance5, newdata=TE)
Surv.rsp <- Surv(TR$Time, TR$Status)
Surv.rsp.new <- Surv(TE$Time, TE$Status)
times <- c(60,90,105)
auc_hc <- AUC.hc(Surv.rsp, Surv.rsp.new, lpnew, times)