Learn R Programming

LaplacesDemon (version 16.1.6)

dist.Wishart: Wishart Distribution

Description

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

Usage

dwishart(Omega, nu, S, log=FALSE)
   rwishart(nu, S)

Arguments

Omega

This is the symmetric, positive-definite \(k \times k\) matrix \(\Omega\).

nu

This is the scalar degrees of freedom \(\nu\).

S

This is the symmetric, positive-semidefinite, \(k \times k\) scale matrix \(\textbf{S}\).

log

Logical. If log=TRUE, then the logarithm of the density is returned.

Value

dwishart gives the density and rwishart generates random deviates.

Details

  • Application: Continuous Multivariate

  • Density: \(p(\theta) = (2^{\nu k/2} \pi^{k(k-1)/4} \prod^k_{i=1} \Gamma(\frac{\nu+1-i}{2}))^{-1} |\textbf{S}|^{-nu/2} |\Omega|^{(nu-k-1)/2} \exp(-\frac{1}{2} tr(\textbf{S}^{-1} \Omega))\)

  • Inventor: John Wishart (1928)

  • Notation 1: \(\Omega \sim \mathcal{W}_{\nu}(\textbf{S})\)

  • Notation 2: \(p(\Omega) = \mathcal{W}_{\nu}(\Omega | \textbf{S})\)

  • Parameter 1: degrees of freedom \(\nu \ge k\)

  • Parameter 2: symmetric, positive-semidefinite \(k \times k\) scale matrix \(\textbf{S}\)

  • Mean: \(E(\Omega) = \nu \textbf{S}\)

  • Variance: \(var(\Omega) = \nu (\textbf{S}^2_{i,j} + \textbf{S}_{i,i} \textbf{S}_{j,j})\)

  • Mode: \(mode(\Omega) = (\nu - k - 1) \textbf{S}\), for \(\nu \ge k + 1\)

The Wishart distribution is a generalization to multiple dimensions of the chi-square distribution, or, in the case of non-integer degrees of freedom, of the gamma distribution. However, the Wishart distribution is not called the multivariate chi-squared distribution because the marginal distribution of the off-diagonal elements is not chi-squared.

The Wishart is the conjugate prior distribution for the precision matrix \(\Omega\), the inverse of which (covariance matrix \(\Sigma\)) is used in a multivariate normal distribution.

The integral is finite when \(\nu \ge k\), where \(\nu\) is the scalar degrees of freedom parameter, and \(k\) is the dimension of scale matrix \(\textbf{S}\). The density is finite when \(\nu ge k + 1\), which is recommended.

The degrees of freedom, \(\nu\), is equivalent to specifying a prior sample size, indicating the confidence in \(\textbf{S}\), where \(\textbf{S}\) is a prior guess at the order of covariance matrix \(\Sigma\). A flat prior distribution is obtained as \(\nu \rightarrow 0\).

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

The 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 \(\textbf{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.

Although the related inverse Wishart distribution has a dependency between variance and correlation, the Wishart distribution does not have this dependency.

The matrix gamma (dmatrixgamma) distribution is a more general version of the Wishart distribution, and the Yang-Berger (dyangberger) distribution is an alterative that is a least informative prior (LIP).

References

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

See Also

dchisq, dgamma, dinvwishart, dmatrixgamma, dmvnp, dwishartc, Prec2Cov, and dyangberger.

Examples

Run this code
# NOT RUN {
library(LaplacesDemon)
x <- dwishart(matrix(c(2,-.3,-.3,4),2,2), 3, matrix(c(1,.1,.1,1),2,2))
x <- rwishart(3, matrix(c(1,.1,.1,1),2,2))
# }

Run the code above in your browser using DataLab