我正在對具有 CHD 疾病與幾個變數的模型進行邏輯回歸(參見資料框)。
ind sbp tobacco ldl adiposity typea obesity alcohol age chd
1 1 160 12.00 5.73 23.11 49 25.30 97.20 52 1
2 2 144 0.01 4.41 28.61 55 28.87 2.06 63 1
...
我在這個模型上執行了向后逐步選擇以獲得最佳模型,但我得到的結果是只包含截距的模型。為什么會這樣?這是什么意思?
model <-glm(chd ~ ., data = CHD, family = "binomial"(link = logit))
intercept_only <- glm(chd ~ 1, data=CHD, family = "binomial"(link = logit))
#perform backward stepwise regression
back <- step(intercept_only, direction='backward', scope=formula(model), trace=0)
#view results of backward stepwise regression
Step Df Deviance Resid. Df Resid. Dev AIC
1 NA NA 461 596.1084 598.1084```
uj5u.com熱心網友回復:
要進行反向回歸,您應該從包含變數的模型開始,而不是僅使用截距的模型:
back <- step(model, direction='backward', scope=formula(model), trace=0)
僅當您設定或intercept_only
時才應使用該模型。direction='forward'
direction='both'
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/494929.html