[R] Matrix negative fraction power

Peter Langfelder peter.langfelder at gmail.com
Sun Mar 11 16:56:54 CET 2012


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



More information about the R-help mailing list