测试R中的共线性

时间:2017-04-05 10:54:04

标签: r

我试图在R中运行混合模型

result < lme(sleep ~ Age + BMI + Family_Type + Bedroom_Darkness + Race + Air_Condition + Bedroom_Sound, random = ~ Date_value | user_id, data = df)

但我收到错误

Error in lme.formula(sleep ~ Age + BMI + Family_Type + Bedroom_Darkness +  : 
nlminb problem, convergence error code = 1
message = iteration limit reached without convergence (10)

所以我希望测试共线性,所以我将预测变量放在一个看起来像(但有几百行或几行)的数据框中

 Bedroom_Darkness                   Family_Type            Air_Condition   Bedroom_Sound    Race     BMI         Age
Medium Dark (without eye mask)    Married and No Child    Yes             Quiet            Others   23.80540    41
Medium Dark (without eye mask)    Married and No Child    Yes             Quiet            Indian   20.66116    52 
Medium Dark (with eye mask)       Single                  No              Quiet            Chinese   21.35921   31

但是当我从usda包运行vif函数时

vif(df_predictors)

我得到了

         Variables      VIF
1 Bedroom_Darkness       NA
2      Family_Type       NA
3    Air_Condition       NA
4    Bedroom_Sound       NA
5             Race       NA
6              BMI 1.267998
7              Age 3.170107

那么如何获得分类变量的VIF?

0 个答案:

没有答案