模型矩阵不是数字矩阵吗?

时间:2019-05-20 11:49:38

标签: r

我已经使用

创建了设计矩阵X
X <- model.matrix( ~ age + BMI + sex, data=df)

,结果看起来像我期望的那样。我想测试多重共线性,所以我正在使用

library(mctest)
mctest(X, y)

产生

Error in mctest(X, y) : X must be a numeric matrix

我在这里想念东西吗?

编辑:这是str()的输出。我将其缩短了一点,我的实际模型比上面显示的模型大得多。

num [1:210, 1:41] 1 1 1 1 1 1 1 1 1 1 ...
- attr(*, "assign")= int [1:41] 0 1 2 3 4 4 4 5 5 5 ...
- attr(*, "contrasts")=List of 27
 ..$ Sex            : chr "contr.treatment"
[...]
 attr(*, "dimnames")=List of 2
 ..$ : chr [1:210] "1" "2" "3" "4" ...
 ..$ : chr [1:41] "(Intercept)" "age" "BMI" "Sex1" ...
- attr(*, "scaled:center")= Named num [1:41] 1 65.0048 25.9557 0.2857 0.0381 ...
 ..- attr(*, "names")= chr [1:41] "(Intercept)" "age" "BMI" "Sex1" ...
- attr(*, "scaled:scale")= Named num [1:41] 0 11.317 5.129 0.453 0.192 ...
 ..- attr(*, "names")= chr [1:41] "(Intercept)" "age" "BMI" "Sex1" ...

0 个答案:

没有答案