Re: [R] boot error: Error in statistic(data, original, ...) : unused argument(s) ( ...)

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Sat 13 Aug 2005 - 15:13:30 EST

Please look at the examples and the book which package boot supports (see its DESCRIPTION file). From ?boot

statistic: A function which when applied to data returns a vector

           containing the statistic(s) of interest.  When
           'sim="parametric"', the first argument to 'statistic' must be
           the data.  For each replicate a simulated dataset returned by
           'ran.gen' will be passed.  In all other cases 'statistic'
           must take at least two arguments.
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
and yours only takes one argument, hence the error message.

I suspect you want

AdjForBase2 <- function (data, inds)

and to refer to data[inds, 1] and data[inds, 2], but since your code is completely devoid of spaces and indentation, I have paid it little attention.

On Fri, 12 Aug 2005, John Sorkin wrote:

> I have added on additional line to the code below, the line the
> defines the matrix passed to AdjForBase2.
>
> I am having difficulty setting up a boot strap.
> My code is listed below. I am getting the following
> error message:
> Error in statistic(data, original, ...) : unused argument(s) ( ...)
> I neither understand the error I have made that leads to
> the error message, nor do I know how to fix my error.
> Any help would be appreciated.
> Thank you,
> John
>
>
>> AdjForBase2<-
> + function (data)
> + {
> + cat("******************\n")
> + #print(length(x))
> +
> + x1<-data[,1]
> + x2<-x1+rnorm(100,0,2)
> + xdiff<-x2-x1
> + corx1x2minx1<-cor(x1,xdiff)
> +
> + y1<-data[,2]
> + y2<-y1+rnorm(100,10,2)
> + ydiff<-y2-y1
> + cory1y2miny1<-cor(y1,ydiff)
> +
> + return(c(mean(x1),mean(x2),corx1x2minx1,
> + mean(y1),mean(y2),cory1y2miny1))
> + }
>> mommy<-as.matrix(cbind(runif(100,0,100),runif(100,5,100)))
>> boot(data=mommy,statistic=AdjForBase2,R=10)
> Error in statistic(data, original, ...) : unused argument(s) ( ...)

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Aug 13 15:21:37 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:48 EST