Error when bootstrapping large n with boot package (error: integer overflow)

Error when bootstrapping large n with boot package (error: integer overflow)

为什么我不能使用 boot 包 bootstrap 大 n 的统计数据?虽然,150,000 obs 并不大,所以我不知道为什么这不起作用。

例子

library(boot)

bs <- boot(rnorm(150000), sum, R = 1000)
bs

ORDINARY NONPARAMETRIC BOOTSTRAP


Call:
boot(data = rnorm(150000), statistic = sum, R = 1000)


Bootstrap Statistics :
WARNING: All values of t1* are NA

错误信息

In statistic(data, i[r, ], ...) : integer overflow - use sum(as.numeric(.))

您没有按照记录使用 boot()(无可否认,这非常复杂)。来自 ?boot:

In all other cases ‘statistic’ must take at least two arguments. The first argument passed will always be the original data. The second will be a vector of indices, frequencies or weights which define the bootstrap sample.

我想你想要:

bsum <- function(x,i) sum(x[i])
bs <- boot(rnorm(150000), bsum, R = 1000)

我还没有花时间弄清楚 boot() 实际上 在你的情况下做了什么 - 虽然几乎可以肯定不是你想要的。