2006/6/7, Recep Aykaya <recepaykaya@gmail.com>:
>
> hi.
> i'm a statistics student and studying bootstrap in R.
>
> i'm trying to draw bootstrap samples from a sample, using the following R
> code:
>
> > *boot = numeric(200)*
> *> {for (i in 1:200)*
>
> *  boot [i] = (sample(data,replace=T))}*
>
>
>
> i obtain 200 samples but all of them are the same.
>
> i want to obtain different samples. what should i do? can you please help
> me
> if possible.
>
>
>
> thank you.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> 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
>

Hi,
I think you have forgotten an parameter of the sample function. Indeed the
help page give these information:

sample(x, size, replace = FALSE, prob = NULL)

size: non-negative integer giving the number of items to choose

By default 'size' is equal to 'length(x)' so that 'sample(x)'
generates a random permutation of the elements of 'x' (or '1:x').

Therefore try to add the number of observed values with this:

nb=100  #the number of  values for each sample
boot = c()
for (i in 1:200)
   boot [i] = mean(sample(x=data,size=nb,replace=TRUE)) # if you try to
estimate the mean


-- 
Clément Viel
Student in Polytech-Lille's engineering school
http://www.polytech-lille.fr

	[[alternative HTML version deleted]]

