[英]extract coefficients from glm in R
我已經進行了邏輯回歸,結果如下:
ssi.logit.single.age["coefficients"]
# $coefficients
# (Intercept) age
# -3.425062382 0.009916508
我需要拿起age
系數,目前我使用以下代碼:
ssi.logit.single.age["coefficients"][[1]][2]
它有效,但我不喜歡這里的神秘代碼,我可以使用系數的名稱(即(Intercept)
或age
)
有一個名為coef
的提取函數可以從模型中獲取系數:
coef(ssi.logit.single.age)["age"]
我從這里找到了它
查看summary()生成的數據結構
> names(summary(lm.D9))
[1] "call" "terms" "residuals" "coefficients"
[5] "aliased" "sigma" "df" "r.squared"
[9] "adj.r.squared" "fstatistic" "cov.unscaled"
現在看一下摘要中系數的數據結構:
> summary(lm.D9)$coefficients
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.032 0.2202177 22.850117 9.547128e-15
groupTrt -0.371 0.3114349 -1.191260 2.490232e-01
> class(summary(lm.D9)$coefficients)
[1] "matrix"
> summary(lm.D9)$coefficients[,3]
(Intercept) groupTrt
22.850117 -1.191260
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.