Hello,
The second argument to your function must be a "vector of indices",
like
the manual page for ?boot says.
And you were missing a comma. That's what the error message was saying.
library(boot)
blue<-c(4, 3, 4, 1, 2, 3, 1)
red<-c(4, 3, 4, 1, 2, 3, 1, 2, 3, 1, 3, 2)
test1<-function(x, d, y){
return(sum(x[d]) - sum(y))
}
b <- boot(red, test1, R=10, y = blue)
b
sum(red) - sum(blue)
Hope this helps,
Rui Barradas
Em 20-03-2013 22:49, paolo brunori escreveu:> Dear all,
> a question about the package boot: is it possible to bootstrap a
> function of arguments of different length? is there an alternative package?
> below an example of a simple try,
>
> many thanks
> paolo
>
>> library(boot)
>> blue<-c(4, 3, 4, 1, 2, 3, 1)
>> red<-c(4, 3, 4, 1, 2, 3, 1, 2, 3, 1, 3, 2)
>>
>> test1<-function(x,y,d){
> + return(sum(x) - sum(y))
> + }
>> b=boot(red blue, test1 ,R=10)
> Error: unexpected symbol in "b=boot(red blue"
>
>
>