Re: [R] Find A, given B where B=A'A
On Wednesday 31 October 2007 22:45, Peter Dalgaard wrote: > Michael Gormley wrote: > > 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. mgcv::mroot will do this for you, using pivoted Choleski decomposition or svd. You can specify the rank of B (which must be positive semi-definite of course), which will then determine the dimension of A, alternatively the routine will attempt to determine the rank of B (and usually over-estimate it slightly). -- > Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK > +44 1225 386603 www.maths.bath.ac.uk/~sw283 __ R-help@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.
Re: [R] Find A, given B where B=A'A
Michael Gormley wrote: > 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. > B would have rank 1 then, and a pivoted Choleski decomposition has zero rows e.g. > B <- outer(c(2,3),c(2,3)) > B [,1] [,2] [1,]46 [2,]69 > chol(B, pivot=TRUE) [,1] [,2] [1,]32 [2,]00 attr(,"pivot") [1] 2 1 attr(,"rank") [1] 1 Warning message: In chol.default(B, pivot = TRUE) : matrix not positive definite an eigen() decomposition could also be used. -- 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 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@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.
Re: [R] Find A, given B where B=A'A
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" <[EMAIL PROTECTED]> To: "Rolf Turner" <[EMAIL PROTECTED]> Cc: "Michael Gormley" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> 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@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:[EMAIL PROTECTED] UC San Diego > http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 > > > __ R-help@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.
Re: [R] Find A, given B where B=A'A
On 31-Oct-07 22:19:22, Lucke, Joseph F wrote: > chol(B) doesn't give the original A, which I believe is > what Mike wants. No-one can tell what this was, from B alone. If A is any solution to t(A)%*%A = B, and if T is any unitary matrix -- i.e. t(T)%*%T = I, the unit diagonal matrix (and there are infinitely many of these), then T%*%A is also a solution: t(T%*%A)%*%(T%*%A) = t(A)%*%t(T)%*%T%*%A = t(A)%*%A For 2x2 matrices, matrix(c(cos(u),-sin(u),sin(u),cos(u)),nrow=2) is a unitary matrix, for any real value of u. Etc. Best wishes, Ted. > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > On Behalf Of Katharine Mullen > Sent: Wednesday, October 31, 2007 4:08 PM > To: Michael Gormley > Cc: [EMAIL PROTECTED] > Subject: Re: [R] Find A, given B where B=A'A > > B is symmetric by definition; if it's also real positive-definite then > A > is the upper triangular factor of the Choleski decomposition, and you > can use >> chol(B) > to get A. > > On Wed, 31 Oct 2007, 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? >> >> Thanks, >> Mike >> >> __ >> R-help@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. >> > > __ > R-help@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. > > __ > R-help@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. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 31-Oct-07 Time: 22:02:41 -- XFMail -- __ R-help@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.
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@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:[EMAIL PROTECTED] UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@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.
Re: [R] Find A, given B where B=A'A
chol(B) doesn't give the original A, which I believe is what Mike wants. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Katharine Mullen Sent: Wednesday, October 31, 2007 4:08 PM To: Michael Gormley Cc: [EMAIL PROTECTED] Subject: Re: [R] Find A, given B where B=A'A B is symmetric by definition; if it's also real positive-definite then A is the upper triangular factor of the Choleski decomposition, and you can use > chol(B) to get A. On Wed, 31 Oct 2007, 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? > > Thanks, > Mike > > __ > R-help@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. > __ R-help@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. __ R-help@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.
Re: [R] Find A, given B where B=A'A
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) 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@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.
Re: [R] Find A, given B where B=A'A
B is symmetric by definition; if it's also real positive-definite then A is the upper triangular factor of the Choleski decomposition, and you can use > chol(B) to get A. On Wed, 31 Oct 2007, 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? > > Thanks, > Mike > > __ > R-help@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. > __ R-help@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.
Re: [R] Find A, given B where B=A'A
On 2007-10-31, Michael Gormley <[EMAIL PROTECTED]> 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 want to look for Cholesky decomposition, if your matrix is hermitesh. If it is complex and symmetric only, there are solutions as well, but not for any case. -- Dipl.-Math. Wilhelm Bernhard Kloke Institut fuer Arbeitsphysiologie an der Universitaet Dortmund Ardeystrasse 67, D-44139 Dortmund, Tel. 0231-1084-257 PGP: http://vestein.arb-phys.uni-dortmund.de/~wb/mypublic.key __ R-help@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.