Consider the following bootstrap:
library(MASS)
library(boot)
# c)
set.seed(1)
boot.fn= function(data, index) mean(data[index])
output=boot(Boston$medv, boot.fn, 1000)
If we run print(output), we get
Call:
boot(data = Boston$medv, statistic = boot.fn, R = 1000)
Bootstrap Statistics :
original bias std. error
t1* 22.53281 0.008517589 0.4119374
However, when I examine the output object, I cannot find values representing the bootstrap statistics. Where is original, bias and std. error in the actual output object returned by boot?
They are calculated by print.boot and not stored in the boot object. Look at getAnywhere(print.boot) for the details.
You can either calculate these values yourself or use capture.output.
For your example:
#original:
output$t0
#bias:
mean(output$t)-output$t0
#se:
sd(output$t)
This command seems to work:
apply(output$t,2,sd)[1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With