# [S] symmetric matrix in chol()

Lin, Shang (slin@nki.rfmh.org)
Wed, 13 May 1998 13:57:21 -0400

Hi, Splus Users,

In the following code, I have defined both std and corm as symmetric
matrix. I then compute covm=std*corm*std where '*' is matrix product.
Theoretically covm is a symmetric matrix. This is so as seen in the
output. However, when I try to do cholesky decomposition
on covm by chol(covm), I got an error message that matrix must
be symmetric. This is strange! I would appreciate hearing from you
if you have encountered the same problem or if you know how to solve
the problem. Thanks for your help.

Shang Lin
Nathan Kline Institute
Orangeburg, NY 10962

> std <- diag(c(5000, 1, 5500, 1.2)/sqrt(2))
> corm <- matrix(c(1, -0.3, 0.5, -0.3, -0.3, 1, -0.3, 0.5, 0.5,
-0.3, 1, -0.2, -0.3, 0.5, -0.2, 1), 4, 4)
> corm
[,1] [,2] [,3] [,4]
[1,] 1.0 -0.3 0.5 -0.3
[2,] -0.3 1.0 -0.3 0.5
[3,] 0.5 -0.3 1.0 -0.2
[4,] -0.3 0.5 -0.2 1.0
> covm <- std %*% corm %*% std
> covm
[,1] [,2] [,3] [,4]
[1,] 12500000 -750.0 6875000 -900.00
[2,] -750 0.5 -825 0.30
[3,] 6875000 -825.0 15125000 -660.00
[4,] -900 0.3 -660 0.72
> chol(covm)
Error in chol(covm): Matrix must be symmetric
Dumped

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news