Generate n random matrices, distributed according to the generalized inverse Wishart distribution with parameters Sigma and df, \(W_p(\Sigma, df)\), with sample size df less than the dimension p.

Let \(X_i\), \(i = 1, 2, ..., df\) be df observations of a multivariate normal distribution with mean 0 and covariance Sigma. Then \(\sum X_i X_i'\) is distributed as a pseudo Wishart \(W_p(\Sigma, df)\). Sometimes this is called a singular Wishart distribution, however, that can be confused with the case where \(\Sigma\) itself is singular. Then the generalized inverse Wishart distribution is the natural extension of the inverse Wishart using the Moore-Penrose pseudo-inverse. This can generate samples for positive semi-definite \(\Sigma\) however, a function dedicated to generating singular normal random distributions or singular pseudo Wishart distributions should be used if that is desired.

Note there are different ways of parameterizing the Inverse Wishart distribution, so check which one you need. Here, if \(X \sim IW_p(\Sigma, \nu)\) then \(X^{-1} \sim W_p(\Sigma^{-1}, \nu)\). Dawid (1981) has a different definition: if \(X \sim W_p(\Sigma^{-1}, \nu)\) and \(\nu > p - 1\), then \(X^{-1} = Y \sim IW(\Sigma, \delta)\), where \(\delta = \nu - p + 1\).

rGenInvWishart(n, df, Sigma)

Arguments

n

integer sample size.

df

integer parameter, "degrees of freedom", should be less than the dimension of p

Sigma

positive semi-definite \(p \times p\) "scale" matrix, the matrix parameter of the distribution.

Value

a numeric array, say R, of dimension \(p \times p \times n\), where each R[,,i] is a realization of the pseudo Wishart distribution \(W_p(Sigma, df)\).

References

Diaz-Garcia, Jose A, Ramon Gutierrez Jaimez, and Kanti V Mardia. 1997. “Wishart and Pseudo-Wishart Distributions and Some Applications to Shape Theory.” Journal of Multivariate Analysis 63 (1): 73–87. doi: 10.1006/jmva.1997.1689 .

Bodnar, T., Mazur, S., Podgórski, K. "Singular inverse Wishart distribution and its application to portfolio theory", Journal of Multivariate Analysis, Volume 143, 2016, Pages 314-326, ISSN 0047-259X, doi: 10.1016/j.jmva.2015.09.021 .

Bodnar, T., Okhrin, Y., "Properties of the singular, inverse and generalized inverse partitioned Wishart distributions", Journal of Multivariate Analysis, Volume 99, Issue 10, 2008, Pages 2389-2405, ISSN 0047-259X, doi: 10.1016/j.jmva.2008.02.024 .

Uhlig, Harald. "On Singular Wishart and Singular Multivariate Beta Distributions." Ann. Statist. 22 (1994), no. 1, 395--405. doi: 10.1214/aos/1176325375 .

See also

Examples

set.seed(20181228)
A <- rGenInvWishart(1L, 4L, 5.0 * diag(5L))[, , 1]
A
#>             [,1]         [,2]         [,3]         [,4]         [,5]
#> [1,]  0.03316896 -0.084864096  0.003831550  0.031486573  0.060802330
#> [2,] -0.08486410  0.265497148  0.003410527 -0.059750288 -0.159210057
#> [3,]  0.00383155  0.003410527  0.025737818 -0.002461811  0.005335016
#> [4,]  0.03148657 -0.059750288 -0.002461811  0.045360861  0.054727822
#> [5,]  0.06080233 -0.159210057  0.005335016  0.054727822  0.139802644
# A should be singular
eigen(A)$values
#> [1]  4.227578e-01  4.247200e-02  2.813051e-02  1.620710e-02 -4.758659e-17
set.seed(20181228)
B <- rPseudoWishart(1L, 4L, 5.0 * diag(5L))[, , 1]

# A should be a Moore-Penrose pseudo-inverse of B
B
#>            [,1]      [,2]      [,3]       [,4]       [,5]
#> [1,]   6.855443 -1.979593  9.123138  12.366797 -10.283094
#> [2,]  -1.979593 11.310039 -2.313472   1.767831  13.168709
#> [3,]   9.123138 -2.313472 38.453046   1.981594  -8.875384
#> [4,]  12.366797  1.767831  1.981594  33.137945 -16.467918
#> [5,] -10.283094 13.168709 -8.875384 -16.467918  33.403804
# this should be equal to B
B %*% A %*% B
#>            [,1]      [,2]      [,3]       [,4]       [,5]
#> [1,]   6.855443 -1.979593  9.123138  12.366797 -10.283094
#> [2,]  -1.979593 11.310039 -2.313472   1.767831  13.168709
#> [3,]   9.123138 -2.313472 38.453046   1.981594  -8.875384
#> [4,]  12.366797  1.767831  1.981594  33.137945 -16.467918
#> [5,] -10.283094 13.168709 -8.875384 -16.467918  33.403804
# this should be equal to A
A %*% B %*% A
#>             [,1]         [,2]         [,3]         [,4]         [,5]
#> [1,]  0.03316896 -0.084864096  0.003831550  0.031486573  0.060802330
#> [2,] -0.08486410  0.265497148  0.003410527 -0.059750288 -0.159210057
#> [3,]  0.00383155  0.003410527  0.025737818 -0.002461811  0.005335016
#> [4,]  0.03148657 -0.059750288 -0.002461811  0.045360861  0.054727822
#> [5,]  0.06080233 -0.159210057  0.005335016  0.054727822  0.139802644