作者iterate (碎形)
看板Statistics
標題[程式] R coxph model 的 error
時間Tue May 15 14:21:36 2012
各位好
目前以 R 在執行存活分析(coxph)
程式如下:
coxpp <- NULL
for(i in 1:100000){
result <- coxph(Surv(da[,22],da[,20])~da[,14]+t(car[i,])),na.action = na.omit)
coe <- summary(result)
coee <- coe$coefficients
coxpp <- rbind(coxpp, c(i, coee[2,5]))
}
在某些 car 的變項,會出現如下的 error
錯誤在fitter(X, Y, strats, offset, init, control, weights = weights, :
外部函數呼叫時不能有 NA/NaN/Inf (引數 6)
此外: Warning message:
In fitter(X, Y, strats, offset, init, control, weights = weights, :
Ran out of iterations and did not converge
導致程式無法繼續執行,想請教各位問題所在,及可以如何處理這樣的問題!
謝謝各位先進。
da[,22]:月數(連續資料)
da[,20]:狀態(類別資料 0,1)
da[,14]:類別資料(0,1)
car[i,]:類別資料(0,1,2)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.129.5
1F:→ moonbat:你的data有NA吧,試試看在迴圈前面加上na.omit(car) 05/15 16:18