GLM中所有虚拟因子变量的系数

时间:2018-07-30 15:40:56

标签: r logistic-regression glm

我正在如下构建Logistic回归(在R中):

glm_hr1 = glm(attrition_value ~ BusinessTravel+Department+Gender,              
binomial(link="logit"), data=hr1)

X变量的定义如下:

BusinessTravel 
--------------
[type=Factor]
[values="Frequently","None","Rarely"]
[Ref group = "Frequently"] 

Department
----------
[type=Factor]
[values="HR","RD","Sales"
[Ref group = "HR"]

Gender
------
[type=Factor]
[values="Male","Female"]
[Ref group = "Male"] 

summary(glm_hr1)返回以下内容:

Coefficients:
                     Estimate Std. Error z value Pr(>|z|)    
(Intercept)           -0.8168     0.2476  -3.298 0.000973 ***
BusinessTravelNone    -1.3738     0.2354  -5.836 5.35e-09 ***
BusinessTravelRarely  -0.6464     0.1166  -5.545 2.94e-08 ***
DepartmentRD          -0.3805     0.2387  -1.594 0.110906    
DepartmentSales        0.1187     0.2441   0.486 0.626912    
GenderFemale          -0.2086     0.1052  -1.982 0.047496 *

如何获得的系数: 经常商务旅行 人力资源部 性别男

全部汇总?

我尝试了什么?

我使用-1来建立模型,如下所示:

glm_hr2 = glm(attrition_value ~ BusinessTravel+Department+Gender -1,
                  binomial(link="logit"), data=hr1)

此模型的输出为:

Coefficients:
                         Estimate Std. Error z value Pr(>|z|)    
BusinessTravelFrequently  -0.8168     0.2476  -3.298 0.000973 ***
BusinessTravelNone        -2.1905     0.3101  -7.063 1.63e-12 ***
BusinessTravelRarely      -1.4632     0.2333  -6.272 3.56e-10 ***
DepartmentRD              -0.3805     0.2387  -1.594 0.110906    
DepartmentSales            0.1187     0.2441   0.486 0.626912    
GenderFemale              -0.2086     0.1052  -1.982 0.047496 *  

(拦截)一词消失了,由“ BusinessTravelFrequently”代替。 我知道为什么会这样。

更改公式的顺序,但是每个级别的游戏系数 例如:

glm(attrition_value ~ Department+BusinessTravel+Gender -1, ....)

为部门的所有值赋予系数

glm(attrition_value ~ Gender+Department+BusinessTravel -1, ....)

为所有性别值赋予系数

有没有办法在一个摘要中获得所有因子变量的所有系数?

还有其他方法吗?

0 个答案:

没有答案