Re: [R] matrix power

2009-08-11 Thread Nordlund, Dan (DSHS/RDA)
[mailto:cindy.g...@gmail.com] Sent: Monday, August 10, 2009 7:05 PM To: Nordlund, Dan (DSHS/RDA) Cc: r-help@r-project.org Subject: Re: [R] matrix power Hi, Dan, Yes, this is what I want. Is there better way to solve this? Cindy On Mon, Aug 10, 2009 at 2:52 PM, Nordlund, Dan (DSHS/RDA

Re: [R] matrix power

2009-08-10 Thread cindy Guo
I think it may be important, but I am not sure. Actually I am trying to program the adaptive nearest neighbor method proposed by Hastie and Tibshirani. I am following the steps in the book 'The elements of statistical learning' by Hastie, Tibshirani and Friedman, in which the local metric is define

Re: [R] matrix power

2009-08-10 Thread cindy Guo
> On > > Behalf Of cindy Guo > > Sent: Monday, August 10, 2009 2:32 PM > > To: r-help@r-project.org > > Subject: [R] matrix power > > > > Hi, All, > > > > If I have a symmetric matrix, how can I get the negative square root of > the > > mat

Re: [R] matrix power

2009-08-10 Thread Gabor Grothendieck
If its not important which of many solutions you use then the generalized inverse can be used, say. Just use 0 for each small eigenvalue and 1/sqrt(x) for the others. On Mon, Aug 10, 2009 at 6:36 PM, cindy Guo wrote: > Hi, Ted, > > Thanks for the sample code. It is exactly what I want. But can I

Re: [R] matrix power

2009-08-10 Thread cindy Guo
Hi, Ted, Now I understand the problem. Thank you for the explanation. It's very helpful. I appreciate it. Cindy On Mon, Aug 10, 2009 at 3:58 PM, Ted Harding wrote: > On 10-Aug-09 22:36:03, cindy Guo wrote: > > Hi, Ted, > > Thanks for the sample code. It is exactly what I want. But can > > I ask

Re: [R] matrix power

2009-08-10 Thread Ted Harding
On 10-Aug-09 22:36:03, cindy Guo wrote: > Hi, Ted, > Thanks for the sample code. It is exactly what I want. But can > I ask another question? The matrix for which I want the negative > square root is a covariance matrix. I suppose it should be positive > definite, so I can do 1/sqrt(V) as you wrote

Re: [R] matrix power

2009-08-10 Thread cindy Guo
Hi, Ted, Thanks for the sample code. It is exactly what I want. But can I ask another question? The matrix for which I want the negative square root is a covariance matrix. I suppose it should be positive definite, so I can do 1/sqrt(V) as you wrote. But the covariance matrix I got in R using the

Re: [R] matrix power

2009-08-10 Thread Ted Harding
On 10-Aug-09 21:31:30, cindy Guo wrote: > Hi, All, > If I have a symmetric matrix, how can I get the negative square root > of the matrx, ie. X^(-1/2) ? > > Thanks, > > Cindy X <- matrix(c(2,1,1,2),nrow=2) X # [,1] [,2] # [1,]21 # [2,]12 E <- eigen(X) V <- E$values

Re: [R] matrix power

2009-08-10 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of cindy Guo > Sent: Monday, August 10, 2009 2:32 PM > To: r-help@r-project.org > Subject: [R] matrix power > > Hi, All, > > If I have a symme

[R] matrix power

2009-08-10 Thread cindy Guo
Hi, All, If I have a symmetric matrix, how can I get the negative square root of the matrx, ie. X^(-1/2) ? Thanks, Cindy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help P