data<-data.frame(x=rnorm(49), y=rnorm(49)) t(sapply(1:50,function(i){colMeans(data[sample(nrow(data),size=nrow(data),replace=TRUE),])}))
r-help@r-project.org 2009/12/7 casperyc <caspe...@hotmail.co.uk>: > > Hi there, > > i think that's not what i was aiming for... > > i was aked to > > Generate 50 Bootstrap samples and corresponding estimates > > if i do data[sample(nrow(data),size=50,replace=TRUE),] > it will give me a table of 50 rows ( 50 sets of x and y) > then how do i estimate the mean? ( mean was esitmated by the bar{x}/bar{y} ) > > i mis undertood that too. > but now, i think what i actually need is > > 50 sets of this kind (49 rows) of tables from bootstrapping > so that i can have 50 different 'bar{x}/bar{y}' s > then to estimate the mean... > > Thanks. > > casper > > > > Ben Bolker wrote: >> >> casperyc <casperyc <at> hotmail.co.uk> writes: >> >>> I have 49 pairs in my data.frame 'data' >>> >>> x y >>> 76 80 >>> ... ... >>> >>> how do I get a bootstrap sample of size n=50? >>> >> >> data[sample(nrow(data),size=50,replace=TRUE),] >> >> ______________________________________________ >> 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. >> >> > > -- > View this message in context: > http://n4.nabble.com/bootstrap-help-tp949807p954053.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > -- Marek ______________________________________________ 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.