R 語言:邏輯回歸 Logistic Regression using R language (三)
文件上有另一個多個數值變數的回歸分析的例子,這裏簡單記錄一下分析流程與結果。 有三組自變數 { w, c, wc(w+c) }, 應變數為 seeen {0,1} STEP 1. 找出相關性 > str(gorilla) 'data.frame': 49 obs. of 4 variables: $ seen: int 0 0 0 0 0 0 0 0 0 0 ... $ W : int 126 118 61 69 57 78 114 81 73 93 ... $ C : int 86 76 66 48 59 64 61 85 57 50 ... $ CW : int 64 54 44 32 42 53 41 47 33 45 ... > cor(gorilla) seen W C CW seen 1.00000000 -0.03922667 0.05437115 0.06300865 W -0.03922667 1.00000000 0.43044418 0.35943580 C 0.05437115 0.43044418 1.00000000 0.64463361 CW 0.06300865 0.35943580 0.64463361 1.00000000 > 根據上面的結果發現其相關性與 seen 甚低。 > glm.out = glm(seen ~ W*C*CW, family=binomial(logit), data=gorilla) > summary(glm.out) Call: glm(formula = seen ~ W * C * CW, family = binomial(logit), data = gorilla) Deviance Residuals: Min 1Q Median 3Q Max -1.8073 -0.9897 -0.5740 1.2368 1.7362 Coefficients: Estimate Std. Error z ...