This is an old version, view current version.

25.2 Cholesky LKJ correlation distribution

Stan provides an implicit parameterization of the LKJ correlation matrix density in terms of its Cholesky factor, which you should use rather than the explicit parameterization in the previous section. For example, if L is a Cholesky factor of a correlation matrix, then

 L ~ lkj_corr_cholesky(2.0); # implies L * L' ~ lkj_corr(2.0);

Because Stan requires models to have support on all valid constrained parameters, L will almost always4 be a parameter declared with the type of a Cholesky factor for a correlation matrix; for example,

 parameters {   cholesky_factor_corr[K] L;   # rather than corr_matrix[K] Sigma;   // ...

25.2.1 Probability density function

For \(\eta > 0\), if \(L\) is a \(K \times K\) lower-triangular Cholesky factor of a symmetric positive-definite matrix with unit diagonal (i.e., a correlation matrix), then \[ \text{LkjCholesky}(L|\eta) \propto \left|J\right|\det(L L^\top)^{(\eta - 1)} = \prod_{k=2}^K L_{kk}^{K-k+2\eta-2}. \] See the previous section for details on interpreting the shape parameter \(\eta\). Note that even if \(\eta=1\), it is still essential to evaluate the density function because the density of \(L\) is not constant, regardless of the value of \(\eta\), even though the density of \(LL^\top\) is constant iff \(\eta=1\).

A lower triangular \(L\) is a Cholesky factor for a correlation matrix if and only if \(L_{k,k} > 0\) for \(k \in 1{:}K\) and each row \(L_k\) has unit Euclidean length.

25.2.2 Sampling statement

L ~ lkj_corr_cholesky(eta)

Increment target log probability density with lkj_corr_cholesky_lupdf(L | eta).
Available since 2.4

25.2.3 Stan functions

real lkj_corr_cholesky_lpdf(matrix L | real eta)
The log of the LKJ density for the lower-triangular Cholesky factor L of a correlation matrix given shape eta
Available since 2.12

real lkj_corr_cholesky_lupdf(matrix L | real eta)
The log of the LKJ density for the lower-triangular Cholesky factor L of a correlation matrix given shape eta dropping constant additive terms
Available since 2.25

matrix lkj_corr_cholesky_rng(int K, real eta)
Generate a random Cholesky factor of a correlation matrix of order K that is distributed LKJ with shape eta; may only be used in transformed data and generated quantities blocks
Available since 2.4


  1. It is possible to build up a valid L within Stan, but that would then require Jacobian adjustments to imply the intended posterior.↩︎