LKJ inverse transform for correlation matrices (incorrect documentation?)

That is all correct and basically the motivation for why we have promoted using the Cholesky factor of a correlation matrix rather than the correlation matrix itself (also things are more numerically stable).

If \boldsymbol{\Sigma} =\mathbf{L} \mathbf{L}^\top is a correlation matrix and \mathbf{L} is its lower-triangular Cholesky factor, then as @bbbales2 mentioned, its rows must have unit length in order for the diagonal elements of \boldsymbol{\Sigma} to be 1. Since the i-th row of \mathbf{L} has unit-length, its elements can be expressed in unit-hyperspherical coordinates (i.e. in terms of \theta_{ij} \in \left(0,\pi\right)) as
\begin{eqnarray*} L\left(\boldsymbol{\theta}\right)_{ij} & = & \begin{cases} 1 & 1=i=j\\ \prod_{k=1}^{j-1}\sin\left(\theta_{kj}\right) & 1<i=j\\ \cos\left(\theta_{i1}\right) & 1=i<j\\ \cos\left(\theta_{ij}\right)\prod_{k=1}^{j-1}\sin\left(\theta_{kj}\right) & 1<i<j\\ 0 & i> j \end{cases} \end{eqnarray*}
Let \omega_{ij} = \cos\left(\theta_{ij}\right) be a partial correlation on a canonical vine, then 0 < \sin\left(\theta_{ij}\right) = \sqrt{1 - \cos\left(\theta_{ij}\right)^2} = \sqrt{1 - \omega_{ij}^2}. Then, the elements of the Cholesky factor in terms of partial correlations on a canonical vine become
\begin{eqnarray*} L\left(\boldsymbol{\omega}\right)_{ij} & = & \begin{cases} 1 & 1=i=j\\ \prod_{k=1}^{j-1}\sqrt{1 - \omega_{kj}^2} & 1<i=j\\ \omega_{i1} & 1=i<j\\ \omega_{ij}\prod_{k=1}^{j-1}\sqrt{1 - \omega_{kj}^2} & 1<i<j\\ 0 & i > j \end{cases} \end{eqnarray*}

That is what the code at


does and the documentation butchers. It sort of remains to be shown that \omega_{ij} “is” a partial correlation on a canonical vine, but you can get a hint that is true from the relation in the LKJ paper that \left|\boldsymbol{\Sigma}\right| = \prod_{i = 1}^{K - 1} \prod_{j = i + 1}^K \left(1 - \omega_{ij}^2\right), which is also equal to 1 \times \prod_{j = 2}^K L\left(\boldsymbol{\omega}\right)_{jj}^2 = 1 \times \prod_{j = 2}^K \prod_{k=1}^{j-1}\left(1 - \omega_{kj}^2\right) since all {K \choose 2} elements of \boldsymbol{\omega} appear exactly once in both expressions.
1 Like