所以這是一個非常簡單的問題,似乎無法弄清楚。爲什麼我用glm獲得「算法沒有收斂」和「擬合數值爲0或1」的警告?
我使用glm函數運行logit,但不斷收到與自變量有關的警告消息。它們存儲爲因素,我已將它們更改爲數字,但沒有運氣。我也將它們編碼爲0/1,但這也不起作用。
請幫忙!
> mod2 <- glm(winorlose1 ~ bid1, family="binomial")
Warning messages:
1: glm.fit: algorithm did not converge
2: glm.fit: fitted probabilities numerically 0 or 1 occurred
我也試圖在澤裏格柯,但類似的錯誤:
> mod2 = zelig(factor(winorlose1) ~ bid1, data=dat, model="logit")
How to cite this model in Zelig:
Kosuke Imai, Gary King, and Oliva Lau. 2008. "logit: Logistic Regression for Dichotomous Dependent Variables" in Kosuke Imai, Gary King, and Olivia Lau, "Zelig: Everyone's Statistical Software," http://gking.harvard.edu/zelig
Warning messages:
1: glm.fit: algorithm did not converge
2: glm.fit: fitted probabilities numerically 0 or 1 occurred
編輯:
> str(dat)
'data.frame': 3493 obs. of 3 variables:
$ winorlose1: int 2 2 2 2 2 2 2 2 2 2 ...
$ bid1 : int 700 300 700 300 500 300 300 700 300 300 ...
$ home : int 1 0 1 0 0 0 0 1 0 0 ...
- attr(*, "na.action")=Class 'omit' Named int [1:63021] 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 ...
.. ..- attr(*, "names")= chr [1:63021] "3494" "3495" "3496" "3497" ...
這將是不可能回答沒有關於您的數據的一些詳細信息。例如'str(dat)'。另外,這些是警告,而不是錯誤。有很大的不同。 – joran 2011-12-21 20:58:59
我只是想指出,有一個'glm2'包聲稱實現融合'glm'沒有。我不知道這是否與這個問題有關。看到http://journal.r-project.org/archive/2011-2/RJournal_2011-2_Marschner.pdf – 2011-12-22 06:46:19
因爲你似乎在處理分類數據,所以我會考慮將你的整數變量作爲因子。 dat $ home < - as.factor(dat $ home) – eamo 2013-09-20 16:11:20