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

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Oct 31 23:45:55 CET 2007


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,]    4    6
[2,]    6    9
 > chol(B, pivot=TRUE)
     [,1] [,2]
[1,]    3    2
[2,]    0    0
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
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-help mailing list