[R] Bootstrapping in R

David Winsemius dwinsemius at comcast.net
Wed Dec 9 17:25:56 CET 2009


On Dec 9, 2009, at 9:05 AM, Trafim Vanishek wrote:

> I missed number of bootstrap replicates R
>
> boot(Reg, bootcoeff, R=10)
> but still it doesn't work
> Error in statistic(data, original, ...) : unused argument(s)  
> (original)
>
>
> On Wed, Dec 9, 2009 at 2:46 PM, Trafim Vanishek  
> <rdapamoga at gmail.com> wrote:
>
>> Dear all,
>>
>> I have some error trying to bootstrap from a matrix. The error  
>> message is
>> "Error in sample(n, n * R, replace = TRUE) : element 2 is empty;
>>   the part of the args list of '*' being evaluated was: (n, R)"
>>
>> vv <- c(0.5,3.2,5.4,1.1,1.4,1.2,2.3,2.0)
>> Reg <- matrix(data=vv, nrow = 4, ncol = 2)
>>
>> bootcoeff <- function(x){
>> coefficients(lm(x[,1]~x[,2]))[2]+1
>> }
>>
>> boot(Reg, bootcoeff)

?boot

And in particular you need to read the Arguments material more  
closely. The boot function is more complicated that you expected. Then  
work through the examples. You may also get help by doing some  
searching in www.rseek.org or with the RSiteSearch function, e.g.:

RsiteSearch("lm coef boot")

>>
>> It is just an example, in reality I have a matrix in rows of which  
>> I have x
>> and y for which I need to make a regression to find the slope coeff
>> bootstrapping from rows.
>>
>> Thanks a lot for the help.
>>
>

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list