[R] Unexpected failure of Cholesky docomposition
Hoffman, Gabriel
g@briel@hoffm@n @ending from m@@m@edu
Tue Nov 13 18:41:32 CET 2018
There was a typo in my example. Here is the fixed version:
# initialize matrix
values = c(1,0.725,0,0,0.725,1,0.692,0,0,0.692,1,0.664,0,0,0.664,1)
B = matrix(values, 4,4)
# show that singular values are positive
svd(B)$d
# show that matrix is symmetric
isSymmetric(B)
# B is symmetric positive definite, but Cholesky still fails
chol(B)
# It turns out the the *eigen* values are mixed sign.
# That explains the issue
eigen(B)$values
Thanks for you help, especially Bert.
- Gabriel
From: William Dunlap <wdunlap using tibco.com<mailto:wdunlap using tibco.com>>
Date: Tuesday, November 13, 2018 at 12:31 PM
To: Gabriel Hoffman <gabriel.hoffman using mssm.edu<mailto:gabriel.hoffman using mssm.edu>>
Cc: "r-help using r-project.org<mailto:r-help using r-project.org>" <r-help using r-project.org<mailto:r-help using r-project.org>>
Subject: Re: [R] Unexpected failure of Cholesky docomposition
Aren't singular values always positive or zero? Look at eigen(B)$values to check for positive definiteness.
Fix your example - your B is not symmetric.
Bill Dunlap
TIBCO Software
wdunlap tibco.com<https://urldefense.proofpoint.com/v2/url?u=http-3A__tibco.com&d=DwMFaQ&c=shNJtf5dKgNcPZ6Yh64b-A&r=KdYcmw5SdXylMrTGSuNVkNJulowod64k0PTDC5BHZkk&m=Vq3YaG1EYDN2Fp8XpmcP8kVgEmHvlDEIwLveBpn4R4Q&s=1NN3MX73Jjmlphkfkm-NlTB-XWOrrMMN3zOGzX3y0RE&e=>
On Tue, Nov 13, 2018 at 7:30 AM, Hoffman, Gabriel <gabriel.hoffman using mssm.edu<mailto:gabriel.hoffman using mssm.edu>> wrote:
My understanding is that a Cholesky decomposition should work on any square, positive definite matrix. I am encountering an issue where chol() fails and give the error: "the leading minor of order 3 is not positive definite"
This occurs on multiple machines and version of R.
Here is a minimal reproducible example:
# initialize matrix
values = c(1,0.725,0,0,0.725,1,0.692,0,0,0.692,1,0.644,0,0,0.664,1)
B = matrix(values, 4,4)
# show that singular values are positive
svd(B)$d
# show that matrix is symmetric
isSymmetric(B)
# B is symmetric positive definite, but Cholesky still fails
chol(B)
Is this a numerical stability issue? How can I predict which matrices will fail?
- Gabriel
[[alternative HTML version deleted]]
______________________________________________
R-help using r-project.org<mailto:R-help using r-project.org> mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help<https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwMFaQ&c=shNJtf5dKgNcPZ6Yh64b-A&r=KdYcmw5SdXylMrTGSuNVkNJulowod64k0PTDC5BHZkk&m=Vq3YaG1EYDN2Fp8XpmcP8kVgEmHvlDEIwLveBpn4R4Q&s=NwgJPwLPzWkHUywq-roE7bv0dcwMA2p5a3-ON2AbycQ&e=>
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwMFaQ&c=shNJtf5dKgNcPZ6Yh64b-A&r=KdYcmw5SdXylMrTGSuNVkNJulowod64k0PTDC5BHZkk&m=Vq3YaG1EYDN2Fp8XpmcP8kVgEmHvlDEIwLveBpn4R4Q&s=6s9m-E3Y4eRcJL-jWgz1Pbf4nQED9bgK0CB3r3KAhp8&e=>
and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help
mailing list