[R] Can boot return matrix?

Katalin Csillery csillery at selway.umt.edu
Wed Apr 2 22:02:15 CEST 2003


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.  

This task can be done with the sample function, but I would like to use
the boot() function. I hope that it is going to be faster.
Something like this:
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?

Also a note, the examples at the end of the boot.ci documentation, for the
city and gravity data set I get error messages for boot.ci() call. Did
anyone else noticed that? E.g.
> boot.ci(grav1.boot, type=c("stud","norm"))
[1] "odd number of coulumns"
     [,1]         [,2]
[1,] "95/-5.803"  "0.123/-6.929"
Error in paste("(", ints1[, 2 * (1:n1)], ",", sep = "") :
     subscript out of bounds

Thanks for any help in advance!

Katalin

___
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