# Values (matrix) randomly drawn for Cholesky factor of correlation matrix do not have strictly positive diagonal entries

**URL:** <https://discourse.mc-stan.org/t/values-matrix-randomly-drawn-for-cholesky-factor-of-correlation-matrix-do-not-have-strictly-positive-diagonal-entries/22470>\
**Category:** General\
**Created:** [May 13, 2021, 3:26pm UTC](https://discourse.mc-stan.org/t/values-matrix-randomly-drawn-for-cholesky-factor-of-correlation-matrix-do-not-have-strictly-positive-diagonal-entries/22470 "2021-05-13T15:26:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![diyinhaitang](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@diyinhaitang](https://discourse.mc-stan.org/u/diyinhaitang)\
**Post date:** [May 13, 2021, 3:26pm UTC](https://discourse.mc-stan.org/t/values-matrix-randomly-drawn-for-cholesky-factor-of-correlation-matrix-do-not-have-strictly-positive-diagonal-entries/22470/1 "2021-05-13T15:26:49Z")

</div>

I declared the Cholesky factor of a correlation matrix by:

```
parameters{
...
cholesky_factor_corr[I] Cholesky_Omega;
...
}

```

In the transformed parameters block, I print it by using:

```
transformed parameters{
...
print(Cholesky_Omega);
...
}

```

However, the outputs of the print command show that some the values randomly drawn for Cholesky factor of correlation matrix (Cholesky\_Omega) are [[1,0],[1,0]], whose diagonal entries are not strictly positive. In this case, if [[1,0],[1,0]] is multiplied by its transpose, the outcome matrix(which should be the correlation matrix) is not positive definite. But correlation matrix must be positive definite.

My question is do I need to constrain some elements in the declaration of Cholesky factor of correlation matrix to ensure that the randomly drawn Cholesky factors have stricly positive diagonal entries?

Hope Stan developers can see this and give advisable suggestions.

---

<div class="post-metadata">

**Author:** ![mike-lawrence](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mike-lawrence/32/59_2.png) [@mike-lawrence](https://discourse.mc-stan.org/u/mike-lawrence)\
**Post date:** [May 13, 2021, 4:28pm UTC](https://discourse.mc-stan.org/t/values-matrix-randomly-drawn-for-cholesky-factor-of-correlation-matrix-do-not-have-strictly-positive-diagonal-entries/22470/2 "2021-05-13T16:28:17Z")

</div>

If `X` is of the variable type `cholesky_factor_corr`, it is constrained such that `multiply_lower_tri_self_transpose(X)` is positive definite. I’m not sure that `X` itself should be expected to be positive definite, but I’m not super familiar with cholesky factors of correlation matrices.

---

<div class="post-metadata">

**Author:** ![diyinhaitang](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@diyinhaitang](https://discourse.mc-stan.org/u/diyinhaitang)\
**Post date:** [May 13, 2021, 4:41pm UTC](https://discourse.mc-stan.org/t/values-matrix-randomly-drawn-for-cholesky-factor-of-correlation-matrix-do-not-have-strictly-positive-diagonal-entries/22470/3 "2021-05-13T16:41:57Z")

</div>

Sorry, I double checked the properties of Cholesky factor and found that it is not required to be positive definite. But it is required that its diagonal entries must be strictly positive so that the corresponding correlation matrix is positive definite.

---

<div class="post-metadata">

**Author:** ![mike-lawrence](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mike-lawrence/32/59_2.png) [@mike-lawrence](https://discourse.mc-stan.org/u/mike-lawrence)\
**Post date:** [May 13, 2021, 4:58pm UTC](https://discourse.mc-stan.org/t/values-matrix-randomly-drawn-for-cholesky-factor-of-correlation-matrix-do-not-have-strictly-positive-diagonal-entries/22470/4 "2021-05-13T16:58:27Z")

</div>

Can you give a bit more context as to when you’re encountering errors resulting from the correlation matrix implied by the cholesky\_factor\_corr variable not being positive definite? If in the initial stages of warmup, that’s common (caused by numeric instabilities) and can be ignored if they don’t outright cause warmup to halt.

---

<div class="post-metadata">

**Author:** ![diyinhaitang](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@diyinhaitang](https://discourse.mc-stan.org/u/diyinhaitang)\
**Post date:** [May 13, 2021, 5:14pm UTC](https://discourse.mc-stan.org/t/values-matrix-randomly-drawn-for-cholesky-factor-of-correlation-matrix-do-not-have-strictly-positive-diagonal-entries/22470/5 "2021-05-13T17:14:30Z")

</div>

Yeah, it indeed happened in initial stages of warmups.
