In R, I can use the boot
function (from here) to calculate some estimate of a statistic.
How can I read the std.error
or that estimate into an R variable from the output of the boot
function?
Take this simple example using the Boston
data set from the ISL book
get_mean <- function(data, index) {
return(mean(data[index]))
}
bootstrap_res <- boot(Boston$medv, get_mean, 1000)
bootstrap_res
This prints
ORDINARY NONPARAMETRIC BOOTSTRAP
Call:
boot(data = Boston$medv, statistic = get_mean, R = 1000)
Bootstrap Statistics :
original bias std. error
t1* 22.53281 0.007650791 0.4106622
How can I get the 0.4106622
value into a variable in R code ?
For example I can use
mean_original <- bootstrap_res$t0
To read 22.53281
into the mean_original
variable.
How can I read the reported std.error ?
Looking at the other fields in the boot
's return, I do not see an obvious way
> summary(bootstrap_res)
Length Class Mode
t0 1 -none- numeric
t 1000 -none- numeric
R 1 -none- numeric
data 506 -none- numeric
seed 626 -none- numeric
statistic 1 -none- function
sim 1 -none- character
call 4 -none- call
stype 1 -none- character
strata 506 -none- numeric
weights 506 -none- numeric