Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does the bootstrap standard error live in the boot class?

Tags:

r

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?

like image 330
merlin2011 Avatar asked Nov 13 '13 20:11

merlin2011


2 Answers

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)
like image 160
Roland Avatar answered Nov 12 '22 07:11

Roland


This command seems to work:

apply(output$t,2,sd)[1]
like image 44
Loren Mell Avatar answered Nov 12 '22 06:11

Loren Mell