[問題] R 程式執行問題 logistic regression

看板Statistics作者 (微喵)時間11年前 (2012/07/25 16:36), 編輯推噓1(103)
留言4則, 3人參與, 最新討論串1/1
各位好,在執行 logistic regression 的時候 遇到了下列的問題,茲將結果 po 上來, 再請各位告知,是哪裡出了問題,造成程式無法執行。 資料:dddd 第一行24個case及16個control 第二行為變項 > dddd V1 V2 R2_S1 1 2 R2_S2 1 1 R2_S3 1 0 R2_S4 1 1 R2_S5 1 1 R2_S6 1 2 R2_S7 1 2 R2_S8 1 2 R2_S9 1 1 R2_S10 1 2 R2_S11 1 0 R2_S12 1 2 R2_S13 1 0 R2_S14 1 2 R2_S15 1 2 R2_S16 1 2 R2_S17 1 2 R2_S18 1 2 R2_S19 1 2 R2_S20 1 1 R2_S21 1 2 R2_S22 1 1 R2_S23 1 1 R2_S24 1 1 R29_S3 0 0 R29_S4 0 2 R39_S1 0 2 R39_S2 0 0 R39_S4 0 2 R41_S1 0 0 R41_S2 0 0 R41_S3 0 1 R41_S4 0 2 R43_S3 0 1 R57_S3 0 0 R60_S2 0 1 R60_S4 0 0 R61_S2 0 1 R66_S2 0 2 R66_S3 0 2 執行 logistic gression 後出現的錯誤訊息 > glm(dddd[,1] ~ dddd[,2], data= dddd) 錯誤在glm.fit(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, : 外部函數呼叫時不能有 NA/NaN/Inf (引數 4) 此外: 警告訊息: 1: In Ops.factor(y, mu) : - not meaningful for factors 2: In Ops.factor(eta, offset) : - not meaningful for factors 3: In Ops.factor(y, mu) : - not meaningful for factors 再請各位告知,哪裡出了問題。 謝謝各位 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.129.5

07/25 18:31, , 1F
要做羅吉斯迴歸的話,加一個family=binomial的參數
07/25 18:31, 1F

07/26 10:28, , 2F
class(dddd) 看看是不是 dataframe, 把data=dddd拿掉
07/26 10:28, 2F

07/26 10:28, , 3F
順便 apply(dddd,2,class) 看看裡面設定是否正確
07/26 10:28, 3F

08/01 11:26, , 4F
謝謝 gsuper,發現是資料格式的問題,建議後已解決了 ^_^
08/01 11:26, 4F
文章代碼(AID): #1G3x03EL (Statistics)