# dist.Inverse.Wishart: Inverse Wishart Distribution In LaplacesDemonR/LaplacesDemon: Complete Environment for Bayesian Inference

## Description

These functions provide the density and random number generation for the inverse Wishart distribution.

## Usage

 ```1 2``` ``` dinvwishart(Sigma, nu, S, log=FALSE) rinvwishart(nu, S) ```

## Arguments

 `Sigma` This is the symmetric, positive-definite k x k matrix Sigma. `nu` This is the scalar degrees of freedom, nu. `S` This is the symmetric, positive-semidefinite k x k scale matrix S. `log` Logical. If `log=TRUE`, then the logarithm of the density is returned.

## Details

• Application: Continuous Multivariate

• Density: p(theta) = (2^(nu*k/2) * pi^(k(k-1)/4) * [Gamma((nu+1-i)/2) * ... * Gamma((nu+1-k)/2)])^(-1) * |S|^(nu/2) * |Omega|^(-(nu-k-1)/2) * exp(-(1/2) * tr(S Omega^(-1)))

• Inventor: John Wishart (1928)

• Notation 1: Sigma ~ W^(-1)[nu](S^(-1))

• Notation 2: p(Sigma) = W^-1[nu](Sigma | S^(-1))

• Parameter 1: degrees of freedom nu

• Parameter 2: symmetric, positive-semidefinite k x k scale matrix S

• Mean: E(Sigma) = S / (nu - k - 1)

• Variance:

• Mode: mode(Sigma) = S / (nu + k + 1)

The inverse Wishart distribution is a probability distribution defined on real-valued, symmetric, positive-definite matrices, and is used as the conjugate prior for the covariance matrix, Sigma, of a multivariate normal distribution. The inverse-Wishart density is always finite, and the integral is always finite. A degenerate form occurs when nu < k.

When applicable, the alternative Cholesky parameterization should be preferred. For more information, see `dinvwishartc`.

The inverse Wishart prior lacks flexibility, having only one parameter, nu, to control the variability for all k(k + 1)/2 elements. Popular choices for the scale matrix S include an identity matrix or sample covariance matrix. When the model sample size is small, the specification of the scale matrix can be influential.

The inverse Wishart distribution has a dependency between variance and correlation, although its relative for a precision matrix (inverse covariance matrix), the Wishart distribution, does not have this dependency. This relationship becomes weaker with more degrees of freedom.

Due to these limitations (lack of flexibility, and dependence between variance and correlation), alternative distributions have been developed. Alternative distributions that are available here include Huang-Wand (`dhuangwand`), inverse matrix gamma (`dinvmatrixgamma`), Scaled Inverse Wishart (`dsiw`), and Yang-Berger (`dyangberger`).

These functions are parameterized as per Gelman et al. (2004).

## Value

`dinvwishart` gives the density and `rinvwishart` generates random deviates.

## References

Gelman, A., Carlin, J., Stern, H., and Rubin, D. (2004). "Bayesian Data Analysis, Texts in Statistical Science, 2nd ed.". Chapman and Hall, London.

Wishart, J. (1928). "The Generalised Product Moment Distribution in Samples from a Normal Multivariate Population". Biometrika, 20A(1-2), p. 32–52.

`dhuangwand`, `dinvmatrixgamma`, `dinvwishartc`, `dmvn`, `dsiw`, `dwishart`, and `dyangberger`.
 ```1 2 3``` ```library(LaplacesDemon) x <- dinvwishart(matrix(c(2,-.3,-.3,4),2,2), 3, matrix(c(1,.1,.1,1),2,2)) x <- rinvwishart(3, matrix(c(1,.1,.1,1),2,2)) ```