Dear Francisca,

On Wed, 16 Feb 2005 11:28:24 -0500
 "Francisca xuan" <[EMAIL PROTECTED]> wrote:
> Dear Sir/Madam:
> 
> I try to use the library boot to bootstrap the median of a data set.
> Can anybody tell me why this doesn't work? Thanks.
> 
> library(boot)
> x=rnorm(100)
> boot(x,median,999)
> 
> I know I can write a simple code for bootstrapping myself. but I am
> so curious to know why the above code does not work.

Take a closer look at ?boot: The function that computes the statistic
that you're bootstrapping (in a simple situation like this) should take
two arguments -- the data and an index vector. Thus,

boot.median <- function(x, i) median(x[i])
result <- boot(x, boot.median, 999)

I hope this helps,
 John

______________________________________________
R-help@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

Reply via email to