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).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 742 bytes
Desc: not available
Url :
https://stat.ethz.ch/pipermail/r-help/attachments/20020924/4ae36f76/attachment.bin
If you read the boot help page, you will note that you need to use a wrapper
function:
boot.var.eig <- function( x, ind) var.eigenvalues(x[ind])
Then
boot(matrix, boot.var.eig, 100)
should do the trick.
-Greg
-----Original Message-----
From: Marcio Pie [mailto:pie at bu.edu]
Sent: Tuesday, September 24, 2002 8:04 AM
To: r-help at stat.math.ethz.ch
Subject: [R] help with bootstrap
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).
LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be
privileged. It is intended for the addressee(s) only. Access to this E-mail by
anyone else is unauthorized. If you are not an addressee, any disclosure or
copying of the contents of this E-mail or any action taken (or not taken) in
reliance on it is unauthorized and may be unlawful. If you are not an addressee,
please inform the sender immediately.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._