dimnames(x) <- dn 中的错误:“dimnames”的长度; [1] 当我在 R 中运行logistic.display时,不等于数组范围
我正在尝试建立二项式逻辑回归模型。这些是我使用的代码行。我的初始 df 大约是 800000 个观察值。我只是使用 1000 个 obs 来构建模型,而不会使 R studio 运行它变得非常繁重。之前的线路运行没有任何问题。现在,我尝试将这些行应用于我的初始 df,当我运行 stepaic 方法时,我没有得到相同的变量,并且对于logistic.display 函数,我收到错误 "Error in dimnames(x) < ;- dn : 'dimnames' 的长度 [1] 不等于数组范围”
任何人都可以帮忙吗?谢谢
library(epiDisplay)
library(caret)
model <- glm(decision ~., data = train.data,family = "binomial")
step.model <- stepAIC(model, direction = "both",
trace = FALSE)
logistic.display(step.model)
structure(list(id = c(1, 3, 5, 10, 11, 13, 15, 17, 18, 21),
var1 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), var2 = c(0.1,
0.77, 0.75, 0.09, 0.84, 0.52, 0.45, 0.27, 0.71, 0.15), var3 = c("D",
"D", "B", "B", "B", "E", "E", "C", "C", "B"), var4 = c(5L,
5L, 6L, 7L, 7L, 6L, 6L, 7L, 7L, 7L), var5 = c(0L, 0L, 2L,
0L, 0L, 2L, 2L, 0L, 0L, 0L), var6 = c(55L, 55L, 52L, 46L,
46L, 38L, 38L, 33L, 33L, 41L), var7 = c(50L, 50L, 50L,
50L, 50L, 50L, 50L, 68L, 68L, 50L), var8 = c("B12", "B12",
"B12", "B13", "B12", "B14", "B12", "B12", "B13", "B12"),
var9 = c("Regular", "Regular", "Diesel", "Diesel", "Diesel",
"Regular", "Regular", "Diesel", "Diesel", "Diesel"), var10 = c(1217L,
1217L, 54L, 76L, 76L, 3003L, 3003L, 137L, 137L, 60L), var11 = c("R82",
"R82", "R22", "R72", "R72", "R31", "R31", "R91", "R91", "R52"
), decision = c(1, 1, 1, 1, 0, 1, 1, 0, 1, 1)), row.names = c(NA,
10L), class = "data.frame")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您当前的数据和代码,我得到以下结果:
由 reprex 包于 2022 年 2 月 26 日创建 (v2.0.1)
With your current data and code I get the following result:
Created on 2022-02-26 by the reprex package (v2.0.1)