[R] bootstrap help

Marek Janad marek.janad at gmail.com
Mon Dec 7 01:11:58 CET 2009


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 at r-project.org

2009/12/7 casperyc <casperyc at 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 at 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 at 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




More information about the R-help mailing list