Correlation Matrix Distributions
The correlation matrix distributions have support on the (Cholesky factors of) correlation matrices. A Cholesky factor
generated quantities {
corr_matrix[K] Sigma;
Sigma = multiply_lower_tri_self_transpose(L); }
LKJ correlation distribution
Probability density function
For
if
, then the density is uniform over correlation matrices of order ;if
, the identity matrix is the modal correlation matrix, with a sharper peak in the density at the identity matrix for larger ; andfor
, the density has a trough at the identity matrix.if
were an unknown parameter, the Jeffreys prior is proportional to , where is the trigamma function
See (Lewandowski, Kurowicka, and Joe 2009) for definitions. However, it is much better computationally to work directly with the Cholesky factor of
Distribution statement
y ~
lkj_corr
(eta)
Increment target log probability density with lkj_corr_lupdf(y | eta)
.
Stan functions
real
lkj_corr_lpdf
(matrix y | real eta)
The log of the LKJ density for the correlation matrix y given nonnegative shape eta. lkj_corr_cholesky_lpdf
is faster, more numerically stable, uses less memory, and should be preferred to this.
real
lkj_corr_lupdf
(matrix y | real eta)
The log of the LKJ density for the correlation matrix y given nonnegative shape eta dropping constant additive terms. lkj_corr_cholesky_lupdf
is faster, more numerically stable, uses less memory, and should be preferred to this.
matrix
lkj_corr_rng
(int K, real eta)
Generate a LKJ random correlation matrix of order K with shape eta; may only be used in transformed data and generated quantities blocks
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
2.0); # implies L * L' ~ lkj_corr(2.0); L ~ lkj_corr_cholesky(
Because Stan requires models to have support on all valid constrained parameters, L
will almost always1 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; // ...
Probability density function
For
A lower triangular
Distribution statement
L ~
lkj_corr_cholesky
(eta)
Increment target log probability density with lkj_corr_cholesky_lupdf(L | eta)
.
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
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
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
References
Footnotes
It is possible to build up a valid
L
within Stan, but that would then require Jacobian adjustments to imply the intended posterior.↩︎