0

Why can I not bootstrap a statistic with large n using the boot package? Although, 150,000 obs is not large, so I don't know why this isn't working.

Example

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

Error Message

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

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
Vedda
  • 7,066
  • 6
  • 42
  • 77

1 Answers1

1

You're not using boot() as documented (which is, admittedly, surprisingly complex). From ?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.

I think you want:

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

I haven't taken the time to figure out what boot() is actually doing in your case - almost certainly not what you want though.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453