[R] How to solve A'A=S for A ?

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Thu Feb 13 19:56:03 CET 2003


Ralf Engelhorn wrote:
> Dear R helpers,
> 
> is there a function or way within R to solve A'A=S for A, where all
> matrices have p x p order and S is a variance-covariance matrix?
> 
> Thank you,
> Ralf Engelhorn
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 

See ?chol. Here's an example:

R> S = diag(4)
R> S[row(S) < col(S)] =
+  S[row(S) > col(S)] = 0.5
R> S
      [,1] [,2] [,3] [,4]
[1,]  1.0  0.5  0.5  0.5
[2,]  0.5  1.0  0.5  0.5
[3,]  0.5  0.5  1.0  0.5
[4,]  0.5  0.5  0.5  1.0
R> A = chol(S)
R> t(A) %*% A
      [,1] [,2] [,3] [,4]
[1,]  1.0  0.5  0.5  0.5
[2,]  0.5  1.0  0.5  0.5
[3,]  0.5  0.5  1.0  0.5
[4,]  0.5  0.5  0.5  1.0
R>

Sundar




More information about the R-help mailing list