[R] About using the boot function

Andrew Robinson A.Robinson at ms.unimelb.edu.au
Fri Nov 10 11:00:45 CET 2006


Joaquim,

you have to write your own function that takes the data and the index,
which is passed to it by boot().

try this ...

x2 <- c(2, 3, 4, 5, 6, 5, 4, 5, 6, 5, 4, 5, 6, 5, 7, 2, 3, 4, 3,
          4, 3, 5, 6, 7, 5)

mean.boot <- function(x, i) mean(x[i])
 
b1 <-boot(x2, mean.boot, 999)
 
b1

Cheers

Andrew
                                
> Dear All,
> 
> I tried to use the boot function, provided in the boot package, in such a
> simple task as to create a bootstrap distribution of the mean of a vector x.
> I wrote:
> 
> b <- boot(x, mean, R=200)
> 
> Well, it doesn't work. I suspect it has something to do with what is called
> "second argument" of the "statistic" in the help page of boot. What is the
> second argument of mean? I don't understand. The whole description in the
> documentation about this "second argument" is somewaht cryptic and
> confusing.
> 
> Will someone please help me?
> 
> Sincerely,
> 
> J. Marques de S?
> 
> jmsa at fe.up.pt
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.

-- 
Andrew Robinson  
Department of Mathematics and Statistics            Tel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia         Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/



More information about the R-help mailing list