Re: [R] Unexpected failure of Cholesky docomposition
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 mailto:wdun...@tibco.com>> Date: Tuesday, November 13, 2018 at 12:31 PM To: Gabriel Hoffman mailto:gabriel.hoff...@mssm.edu>> Cc: "r-help@r-project.org<mailto:r-help@r-project.org>" mailto:r-help@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=DwMFaQ=shNJtf5dKgNcPZ6Yh64b-A=KdYcmw5SdXylMrTGSuNVkNJulowod64k0PTDC5BHZkk=Vq3YaG1EYDN2Fp8XpmcP8kVgEmHvlDEIwLveBpn4R4Q=1NN3MX73Jjmlphkfkm-NlTB-XWOrrMMN3zOGzX3y0RE=> On Tue, Nov 13, 2018 at 7:30 AM, Hoffman, Gabriel mailto:gabriel.hoff...@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@r-project.org<mailto:R-help@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=DwMFaQ=shNJtf5dKgNcPZ6Yh64b-A=KdYcmw5SdXylMrTGSuNVkNJulowod64k0PTDC5BHZkk=Vq3YaG1EYDN2Fp8XpmcP8kVgEmHvlDEIwLveBpn4R4Q=NwgJPwLPzWkHUywq-roE7bv0dcwMA2p5a3-ON2AbycQ=> 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=DwMFaQ=shNJtf5dKgNcPZ6Yh64b-A=KdYcmw5SdXylMrTGSuNVkNJulowod64k0PTDC5BHZkk=Vq3YaG1EYDN2Fp8XpmcP8kVgEmHvlDEIwLveBpn4R4Q=6s9m-E3Y4eRcJL-jWgz1Pbf4nQED9bgK0CB3r3KAhp8=> and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
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 On Tue, Nov 13, 2018 at 7:30 AM, Hoffman, Gabriel 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Unexpected failure of Cholesky docomposition
Your understanding is wrong. The eigenvalues, not singular values, must be positive, and they are not. Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Nov 13, 2018 at 7:39 AM Hoffman, Gabriel 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Unexpected failure of Cholesky docomposition
Eigen shows that the matrix is not positive definite (it has a negative eigenvalue). And isSymmetric() also shows it is not symmetric - compare (3,4) and (4,3) On Tue, Nov 13, 2018 at 5:39 PM Hoffman, Gabriel 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Unexpected failure of Cholesky docomposition
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@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.