[R] Can boot return matrix?

Thomas W Blackwell tblackw at umich.edu
Fri Apr 4 00:45:32 CEST 2003


You're certainly very close.  I observe that you have interchanged
positions for the function which calculates the statistic (f2) and
the number of replicates (R) in the third line of your example below.
Swap positions, or assign arguments by name instead of by position,
and I would expect this example to work.  Probably, you've spotted
this already.  Details are in  help("boot").

And, a matrix is also a vector, so perhaps f1() can return a matrix
without causing any problems.  If not, use

f2 <- function(nxm.matrix, i)  as.vector(f1(nxm.matrix[i, ]))

The confidence intervals will require a separate call to boot.ci()
for each entry in the matrix, changing the value of boot.ci(index= )
each time.

-  tom blackwell  -  u michigan medical school  -  ann arbor  -

On Wed, 2 Apr 2003, Katalin  Csillery wrote:

> Dear All,
>
> I have a function which takes a n x m matrix as an argument and returns
> an n x n matrix. I want to take bootstrap samples form the input matrix
> in the way as each row represent a multivariate observation, so each
> bootstrap sample would be an n x m matrix, and on each sample I want to
> calculate the n x n matrix.
>
> f1 <- function(nxm.matrix){...; return(nxn.matrix)}
> f2 <- function(nxm.matrix, i) f1(nxm.matrix[i,])
> boot.out <- boot(nxm.matrix, R, f2)
> Error: incorrect number of subscripts on matrix
>
> Since the final goal would be to put a confidence interval on the
> statistics in each cell of the matrix I would like to use the boot.ci.
> Even if I do the resampling with the sample function and I just use the
> boot.ci by artificially putting togethet an boot.out type of list I run
> into problems. Any idea how to set it up?
>
> Katalin Csillery
> Division of Biological Sciences
> University of Montana, Missoula MT 59801
> Phone: 406 243 6106, E-mail: csillery at selway.umt.edu
> ----------------------------------------------------



More information about the R-help mailing list