Skip to content

R: Re: R: Re: chol( neg.def.matrix ) WAS: Re: Choleski and Choleski with pivoting of matrix fails

2 messages · simona.racioppi at libero.it, Ravi Varadhan

#
Dear Peter,
thank you very much for your answer.

My problem is that I need to calculate the following quantity:

solve(chol(A)%*%Y)

Y is a 3*3 diagonal matrix and A is a 3*3 matrix. Unfortunately one 
eigenvalue of A is negative. I can anyway take the square root of A but when I 
multiply it by Y, the imaginary part of the square root of A is dropped, and I 
do not get the right answer.

I tried to exploit the diagonal structure of Y by using 2*2 matrices for A 
and Y. In this way the problem mentioned above disappears (since all 
eigenvalues of A are positive) and when I perform the calculation above I get 
approximately the right answer. The approximation is quite good. However it is 
an approximation.

Any suggestion?
Thank you very much!
Simon
with pivoting of matrix fails
it
eigen
#
I do not understand what the problem is, as it works just fine for me:

A <- matrix(c(0.5401984,-0.3998675,-1.3785897,-0.3998675,1.0561872,  
0.8158639,-1.3785897, 0.8158639, 1.6073119), 3, 3, byrow=TRUE)

eA <- eigen(A)

chA <-  eA$vec %*% diag(sqrt(eA$val+0i)) %*% t(eA$vec)

all.equal(A, Re(chA %*% t(chA)))

Y <- diag(c(1,2,3))

solve(chA %*% Y)

Ravi.

-----------------------------------------------------------------------------------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.html



------------------------------------------------------------------------------------

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of simona.racioppi at libero.it
Sent: Wednesday, November 25, 2009 9:59 AM
To: P.Dalgaard at biostat.ku.dk
Cc: r-help at r-project.org
Subject: [R] R: Re: R: Re: chol( neg.def.matrix ) WAS: Re: Choleski and Choleski with pivoting of matrix fails

Dear Peter,
thank you very much for your answer.

My problem is that I need to calculate the following quantity:

solve(chol(A)%*%Y)

Y is a 3*3 diagonal matrix and A is a 3*3 matrix. Unfortunately one 
eigenvalue of A is negative. I can anyway take the square root of A but when I 
multiply it by Y, the imaginary part of the square root of A is dropped, and I 
do not get the right answer.

I tried to exploit the diagonal structure of Y by using 2*2 matrices for A 
and Y. In this way the problem mentioned above disappears (since all 
eigenvalues of A are positive) and when I perform the calculation above I get 
approximately the right answer. The approximation is quite good. However it is 
an approximation.

Any suggestion?
Thank you very much!
Simon
with pivoting of matrix fails
it
eigen
______________________________________________
R-help at 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.