Re: [R] Matrix question: obtaining the square root of a positive definite matrix?

From: Peter Dalgaard <P.Dalgaard_at_biostat.ku.dk>
Date: Wed 24 Jan 2007 - 08:50:46 GMT

Prof Brian Ripley wrote:
> On Wed, 24 Jan 2007, gallon li wrote:
>
>
>> I want to compute B=A^{1/2} such that B*B=A.
>>
>
> According to your subject line A is positive definite and hence
> symmetric? The usual definition of a matrix square root involves a
> transpose, e.g. B'B = A. There are many square roots: were you looking
> for a symmetric one?
>
>
If not, Choleski decomposition by chol() is often the expedient way.

> For such an A,
>
>
>> e <- eigen(A)
>> V <- e$vectors
>> V %*% diag(e$values) %*% t(V)
>>
>
> recovers A (up to rounding errors), and
>
>
>> B <- V %*% diag(sqrt(e$values)) %*% t(V)
>>
>
> is such that B %*% B = A. Even that is not unique, e.g. -B is an equally
> good answer.
>
>
>
and you can flip the sign of the individual root eigenvalues too, and if the eigenvalues are not unique, you can rotate the eigenspace coordinate systems at will and then flip signs.

-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch 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 Wed Jan 24 19:56:04 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 24 Jan 2007 - 09:30:33 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.