# \-nan results with lkj\_corr\_cholesky

**URL:** https://discourse.mc-stan.org/t/nan-results-with-lkj-corr-cholesky/16832
**Category:** Developers
**Created:** [July 21, 2020, 8:41pm UTC](https://discourse.mc-stan.org/t/nan-results-with-lkj-corr-cholesky/16832 "2020-07-21T20:41:56Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)
#### Post date: [July 22, 2020, 12:56am UTC](https://discourse.mc-stan.org/t/nan-results-with-lkj-corr-cholesky/16832/2 "2020-07-22T00:56:46Z")

</div>

For Cholesky factors that big, it is possible that the diagonal elements result in the square root of a slightly negative number when symbolically they should be slightly positive. If you search for the “onion method” on the Stan-users Google group, there is some code for a more numerically stable way to construct a Cholesky factor of a large correlation matrix.

---

_[View the full topic](https://discourse.mc-stan.org/t/nan-results-with-lkj-corr-cholesky/16832)._
