[R] help with bootstrap

Roger Peng rpeng at stat.ucla.edu
Tue Sep 24 22:09:30 CEST 2002


The `boot' library works differently from what you think.  For ordinary
bootstrapping you need to pass it a function which takes the data and a
vector of indices (it is in fact the indices that get resamples).  So
something like the following may work:

boot.func <- function(x, i) {
  var(eigen(cov(x[i,]), symmetric = T, only.values = T)$values)
}

The argument `i' represents the resampled indices.  Here I'm assuming you
want to resample rows.  Then,

> matrix <- read.table("matrix.txt", header=T)
> boot(matrix, boot.func, R = 100)

-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng

On Tue, 24 Sep 2002, Marcio Pie wrote:

> 
> Hi there,
> 
> I'm stuck, but since I just started learning R, this might be a trivial 
> problem. I need to do a bootstrap on the variance among the eigenvalues 
> of a matrix. I can get this variance doing this:
> 
>  >var.eigenvalues=function(x)
>  >var(eigen(cov(x), symmetric = T, only.values = T)$values)
> 
> 
> but if I try to run:
>  >matrix=read.table("matrix.txt", header=T)
>  >boot(matrix, var.eigenvalues, 100)
> 
> I get: "Error in statistic(data, original, ...) : unused 
> argument(s) ( ...)".
> 
> Any idea of what I might be doing wrong?
> 
> Any help with be really appreciated.
> 
> Marcio
> 
> p.s.: Since I'm not subscribed, please reply to my e-mail address: 
> pie at bu.edu.spam (don't forget to remove the .spam from the address).
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list