nodes_mis[ i] 中的错误:使用 meth="rf" 的 mice 包中的维数不正确

Error in nodes_mis[, i] : incorrect number of dimensions in the mice package using meth="rf"

我是R的新手。 我正在尝试使用随机森林方法作为插补算法来测试 mice 包是否缺少插补:

library(mice)
data <- matrix(c(1.0, 10.5, 1.5, 13.2, 1.8, 8.0, 1.7, 15.0, 23, 40.0, 2.0, 21.0, 3.3, 38.0, 4.5, -2.3, NA, -2.4),nrow=9,ncol=2, byrow=TRUE)
impObject <- mice(as.data.frame(data),m=1,meth='rf',printFlag=FALSE)
completedData <- complete(impObject,1)
print(completedData)

上面的代码已经给出了错误:Error in nodes_mis[, i] : incorrect number of dimensions.

如果我使用其他插补方法,或者如果我使用稍微修改过的输入数据(比方说 data <- matrix(c(1.0, 10.5, 1.5, 13.2, 1.8, 8.0, 1.7, NA, 23, 40.0, 2.0, 21.0, 3.3, 38.0, 4.5, -2.3, NA, -2.4),nrow=9,ncol=2, byrow=TRUE)),它会起作用。 这是为鼠标实现 rf 方法的包中的错误吗(顺便说一句,我找不到它的名字,它确实要求我安装它,但我无法取回它的名字)? 最终,您是否报告了 R 包中的错误?

此问题已解决,讨论 here

简而言之,在 mice 版本 3.14.0 中,mice:::mice.impute.rfrfPackage 参数的默认值从 randomForest 切换为 ranger (参见 here). When there was only one missing value, something went wrong with subsetting one of the matrices. This has been fixed (see here) 并在版本 3.14.2 中实现。