我进行了逻辑回归,结果如下:
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"]
关于list - 从 R 中的 glm 中提取系数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4780152/