# [R] Find A, given B where B=A'A

Michael Gormley mpg33 at drexel.edu
Wed Oct 31 23:02:55 CET 2007

```Thanks for your help, all those who submitted responses.  I do not need a
specific matrix A, any solution will do.  With this said, is it possible to
specify the dimensions of the A matrix in the decompostion?  For example, if
A is a 2X1 matrix then A'A=B would be a 2X2 as well.

----- Original Message -----
From: "Charles C. Berry" <cberry at tajo.ucsd.edu>
To: "Rolf Turner" <r.turner at auckland.ac.nz>
Cc: "Michael Gormley" <mpg33 at drexel.edu>; <r-help at stat.math.ethz.ch>
Sent: Wednesday, October 31, 2007 5:33 PM
Subject: Re: [R] Find A, given B where B=A'A

> On Thu, 1 Nov 2007, Rolf Turner wrote:
>
>>
>> On 1/11/2007, at 9:13 AM, Michael Gormley wrote:
>>
>>> Given a matrix B, where B=A'A, how can I find A?
>>> In other words, if I have a matrix B which I know is another matrix
>>> A times
>>> its transpose, can I find matrix A?
>>
>> You can't, because A is not unique.  You can easily find ***a***
>> solution.
>>
>> E.g. A1 <- matrix(1:4,ncol=2)
>>      B  <- t(A1)%*%A1
>>      A2 <- msqrt(B)
>
> Also, see
>
>  ?chol
>
> Chuck
>
>>
>> A2 != A1 (A2 is symmetric), yet t(A2)%*%A2 == B.
>>
>> The function msqrt() above is a simple-minded calculation of the
>> square root of a positive semi-definite real matrix, the code of
>> which I just cribbed from an old posting by Prof. Brian Ripley:
>>
>> msqrt <- function(X) {
>> e <- eigen(X)
>> V <- e\$vectors
>> V%*%diag(sqrt(e\$values))%*%t(V)
>> }
>>
>> The problem of finding ***all possible*** solutions A to A'A = B
>> (for B symmetric positive semi-definite) is likely to be hard,
>> but may have been solved by the linear algebraists.  I dunno.
>>
>> cheers,
>>
>> Rolf Turner
>>
>> ######################################################################
>> Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> 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
>
>
>

```