## 28.4 Inverse Wishart distribution, Cholesky Parameterization

The Cholesky parameterization of the inverse Wishart distribution uses a Cholesky factor for both the variate and the parameter. If $$S$$ and $$W$$ are positive definite matrices with Cholesky factors $$L_S$$ and $$L_W$$ (i.e., $$S = L_S L_S^{\top}$$ and $$W = L_W L_W^{\top}$$), then the Cholesky parameterization is defined so that $L_W \sim \textrm{InvWishartCholesky}(\nu, L_S)$ if and only if $W \sim \textrm{InvWishart}(\nu, S).$

### 28.4.1 Probability density function

If $$K \in \mathbb{N}$$, $$\nu \in (K-1, \infty)$$, and $$L_S, L_W \in \mathbb{R}^{K \times K}$$ are lower triangular matrixes with positive diagonal elements, then the Cholesky parameterized inverse Wishart density is $\text{InvWishartCholesky}(L_W \mid \nu,L_S) = \text{InvWishart}(L_WL_W^{\top} \mid \nu, L_S L_S^{\top}) \, \left| J_{f^{-1}} \right|,$ where $$J_{f^{-1}}$$ is the Jacobian of the (inverse) transform of the variate, $$f^{-1}(L_W) = L_W L_W^{\top}$$. The log absolute determinant is $\log \left| J_{f^{-1}} \right| = K \log(2) \sum_{k=1}^K (K - k + 1) \log {L_{W_{k,\, k}}}.$

The probability functions will raise errors if $$\nu \leq K - 1$$ or if $$L_S$$ and $$L_W$$ are not Cholesky factors (square, lower-triangular matrices with positive diagonal elements) of the same size.

### 28.4.2 Stan functions

real inv_wishart_cholesky_lpdf(matrix L_W | real nu, matrix L_S)
Return the log of the inverse Wishart density for lower-triangular Cholesky factor L_W given degrees of freedom nu and lower-triangular Cholesky factor of the scale matrix L_S.
Available since 2.30

real inv_wishart_cholesky_lupdf(matrix L_W | real nu, matrix L_S)
Return the log of the inverse Wishart density for lower-triangular Cholesky factor of L_W given degrees of freedom nu and lower-triangular Cholesky factor of the scale matrix L_S dropping constant additive terms.
Available since 2.30

matrix inv_wishart_cholesky_rng(real nu, matrix L_S)
Generate the Cholesky factor of an inverse Wishart variate with degrees of freedom nu and lower-triangular Cholesky factor of the scale matrix L_S; may only be used in transformed data and generated quantities blocks.
Available since 2.30