[R] bootstrap help

casperyc casperyc at hotmail.co.uk
Mon Dec 7 02:01:38 CET 2009


Hi there,

This seems to 'simple' for that. ( I mean the codes are too good)
Can I ask for a bit explaination? or some simplier (maybe few more line
codes) to archieve that goal?

And the codes you gave here,
first line give a table with x and y , random normal values,
but  the second line, what does that do?

I totally can't follow that line.
the result is a 50 by 2 table.
what is that? is a sample? 

Thanks.

casper




Marek Janad wrote:
> 
> 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
> 
> ______________________________________________
> 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-tp949807p954088.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list