Re: [R] Raising a matrix to the (-1/2) power.

From: Charles C. Berry <cberry_at_tajo.ucsd.edu>
Date: Sun, 27 Apr 2008 10:00:34 -0700

On Sun, 27 Apr 2008, jmrossbach wrote:

>
> Hi, I need to raise a correlation matrix; R; to the negative one half power.
> i.e. I need to find R^(-1/2)
>
> eg: if R=[{1,.4},{.4,1}], then R^(-1/2)=[{1.0681,-.2229},
> {-.2229,1.0681}]where matrix=[{row1},{row2}]
>
>
> And are there any built in functions to do this? mtx.exp doesn't work
> because it's not raised to a positive integer

         ?eigen

as in

  	emat <- eigen( R )
  	emat$vectors %*%diag(emat$values^(-1/2)) %*% t(emat$vectors)

Or if you do not need a symmetric result

 	?chol
 	?backsolve

The usual advice given to a question along these lines (inverting a matrix) is to be sure you really needed to do it explicitly. If you are solving a system of equations there are often better methods to do it involving matrix decompositions.

HTH, Chuck

>
> Thank you so much.
> --
> View this message in context: http://www.nabble.com/Raising-a-matrix-to-the-%28-1-2%29-power.-tp16923522p16923522.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry_at_tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 27 Apr 2008 - 17:03:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 27 Apr 2008 - 18:30:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive