Hi,there,

I am using R package "boot" to bootstrap. I have one question here: does
anybody possibly know how the boot package generates the "indices" which is
used in the statistic function?

I thought "indices = sample(data, replace=TRUE)", but when I replaced
"indices" with this command and used "boot", I got different results.

Specifically, below are the codes for illustration.

(1) The typical way by generating indices in the package:
boot1 <- function (data, indices)
{
 d <- data[indices]
 return(d)
}
AA <- c(1:10)
require(boot)
set.seed(123)
results1 <- boot(data= AA, statistic=boot1, R=100)

(2) The alternative way by calculating "indices" myself:
boot2 <- function (data,indices)
{
 indices <- sample(data, replace=TRUE)
 d <- data[indices]
 return(d)
 }
AA <- c(1:10)
set.seed(123)
results2 <- boot(data= AA, statistic=boot2, R=100)

When I looked up using results1$t and results2$t, I had totoally different
bootstrap samples. I found this even had great impacts on the results in my
study. Does the second approach have any problem? Anyone could provide any
inputs on this? Thank you very much in advance!
Regards
Nina

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to