With a sample data frame:
d = data.frame(id = rep(c(1,2,3,4),5), x = round(rexp(20), digits=2), y =
round(runif(20), digits=2))
I would like to generate 100 bootstrap data with replacement and save each
bootstrap data as b1, b2, ..., b100. I attempted the sample function but
could not make it work
On Mon, Nov 11, 2013 at 6:11 PM, Dereje Fentie derex@gmail.com wrote:
With a data frame (call it *d*) composed of 2000 individuals and
*n*observations for each individual (thus
*2000n* observations in total), I would like to generate *k* bootstrap
samples with replacement from *d*. Amongst other variables, *d* has a
numeric variable *id* taking on identical value for observations
belonging to the same individual.
Taking into consideration the panel nature of the data, I want to generate
many bootstrap samples with replacement and store each bootstrap sample
data frame for further use. Sampling (or selection into the bootstrap
sample) shall be based on individuals (on unique values of *id*) such
that if an individual is in a particular bootstrap sample, so will all
observations belonging to that individual.
How can I do this in r?
[[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.