从运行R 3.4.0的计算机迁移到运行R 3.5.0的计算机后,完全相同的代码为我使用Mouses软件包的插补提供了不同的结果,该软件包已从2.46.0版本更改为3.3版本。 0。具体来说,某些(可能是全部)推定值是不同的,但更值得注意的是,大约50列中的两列根本没有被推算。这些列具有大约50个大多数唯一的已知值和3700个缺失值。另外两列的已知值较少,并且已成功估算出它们。总共大约有20列缺少值,所有值都是数字,并且除了前面提到的两列之外,所有值均已成功估算。我设置了随机种子。
我是数据科学领域的新手,但我怀疑这与mouse软件包版本有关。不幸的是,我无法找到任何信息来解释为什么会发生这种情况或如何纠正它。
#Pseudocode
#Function for determining method for mice, based on data type of each feature (skip dates)
myMeth <- function(myData) {
featureType <- sapply(myData,function(feature) {class(feature)[1]})
return(for each datatype in featureType, character types get "polyreg",
numeric types get "pmm", date types get "")
}
#Perform imputation
#I exclude features with exactly 2 unique values because it was causing
# a "failed to converge" fatal error in R 3.4.0
myImputation <- mice(myData, meth=myMeth(myData), pred=quickpred(myData, mincor=0.1,
minpuc=0.1, exclude=c(featuresWithDateType, featuresWithLessThan3UniqueValues)),
m=myTotalImputations, maxit=myMaxIterations, seed=1)