【发布时间】:2014-04-12 04:10:48
【问题描述】:
我想估算一些数据。我使用 mvoutlier 包中的数据 moss。目标是从 Bi 列中估算 moss 日期是组成数据,所以我使用包 robCompositions 中的方法。当我尝试估算这些值时,出现错误。
代码:
library(mvoutlier)
library(robCompositions)
data(moss)
attach(moss)
x <- moss[-c(1,2,3)] # copying the data from moss, withoud the first 3 variables into x
x$Bi[Bi < 0.004] <- 0 # the values that are under 0.004 are replaced with 0
res <- impRZilr(x,dl=c(0,0,0,0,0,0.004,rep(0,25)))
|======= | 10%Error in !all.equal(x[!w], xOrig[!w]) : invalid argument type
不知道如何处理这个错误
【问题讨论】:
-
我已经缩小了问题的范围,但我没有解决方案。这有效:
res <- impRZilr(x[,c(1:5,7:31)],dl=rep(0,30)),所以问题与 Bi 列有关。不过我不知道是什么。 -
尝试用
x$Bi[x$Bi < 0.004] <- 0替换x$Bi[Bi < 0.004] <- 0 -
@crmhaske 我尝试了你的建议,但是这样做我不会在结果变量中包含 Bi 列,所以它很无奈
-
@jlhoward 您的建议对结果没有影响
-
是的,我并没有试图提供解决方案,只是为了演示,因为它在没有该列的情况下也可以工作,所以错误在 Bi 中......并且 jlhoward 为您找到了解决方案。
标签: r missing-data imputation