Dear list, I understand that to raise matrix A to power (-1/2) we should use something like this: eigen(A)$vectors%*%diag(1/sqrt(eigen(A)$values))%*%t(eigen(A)$vectors) [from previous discussions: http://r.789695.n4.nabble.com/matrix-power-td900335.html] But this will only do it for negative sqrt of the matrix not for other fraction powers like (-3/2). Seeing that these things be can done seamlessly in Matlab, I am wondering if I am missing something in R. Examples in Matlab: A 1 1 1 1 2 3 1 3 6 A^(-1/2 ) 1.5099 -0.8262 0.1937 -0.8262 1.9586 -0.6937 0.1937 -0.6937 0.6937 A^(-3/2) 7.2020 -9.0481 3.3560 -9.0481 13.6591 -5.4371 3.3560 -5.4371 2.2749 Thank you in advance. -- Ebrahim Jahanshiri [[alternative HTML version deleted]]
On Sun, Mar 11, 2012 at 1:46 AM, Ebrahim Jahanshiri <e.jahanshiri at gmail.com> wrote:> Dear list, > > I understand that to raise matrix A to power (-1/2) we should use something > like this: > > eigen(A)$vectors%*%diag(1/sqrt(eigen(A)$values))%*%t(eigen(A)$vectors) > > [from previous discussions: > http://r.789695.n4.nabble.com/matrix-power-td900335.html] > > But this will only do it for negative sqrt of the matrix not for other > fraction powers like (-3/2).Not sure why you think this won't work for -3/2 - simply use eigen(A)$values^(-3/2) instead of the 1/sqrt(eigen(A)$values) and you're good to go. Generalizations to other powers are left as exercise for the reader :) Peter
Thank you very much Peter, Indeed this should be left to the reader/practitioner. But I think -at least for the sake of comparison with matlab- we could have it in the core R. I would definitely try to learn more about R and implement it later. Cheers, Ebrahim On Sun, Mar 11, 2012 at 11:56 PM, Peter Langfelder < peter.langfelder@gmail.com> wrote:> On Sun, Mar 11, 2012 at 1:46 AM, Ebrahim Jahanshiri > <e.jahanshiri@gmail.com> wrote: > > Dear list, > > > > I understand that to raise matrix A to power (-1/2) we should use > something > > like this: > > > > eigen(A)$vectors%*%diag(1/sqrt(eigen(A)$values))%*%t(eigen(A)$vectors) > > > > [from previous discussions: > > http://r.789695.n4.nabble.com/matrix-power-td900335.html] > > > > But this will only do it for negative sqrt of the matrix not for other > > fraction powers like (-3/2). > > Not sure why you think this won't work for -3/2 - simply use > eigen(A)$values^(-3/2) instead of the 1/sqrt(eigen(A)$values) and > you're good to go. Generalizations to other powers are left as > exercise for the reader :) > > Peter >-- Ebrahim Jahanshiri Spatial and Numerical lab ITMA Universiti Putra Malaysia 43300, Selangor, Malaysia +60172002427 e.jahanshiri@gmail.com -- Ebrahim Jahanshiri Spatial and Numerical lab ITMA Universiti Putra Malaysia 43300, Selangor, Malaysia +60172002427 e.jahanshiri@gmail.com [[alternative HTML version deleted]]