Generate n random matrices, distributed according to the Wishart distribution with parameters Sigma and df, W_p(Sigma, df).

rNonsingularWishart(n, df, Sigma, covariance = FALSE,
  simplify = "array")

Arguments

n

integer: the number of replications.

df

numeric parameter, “degrees of freedom”.

Sigma

positive definite (\(p\times p\)) “scale” matrix, the matrix parameter of the distribution.

covariance

logical on whether a covariance matrix should be generated

simplify

logical or character string; should the result be simplified to a vector, matrix or higher dimensional array if possible? For sapply it must be named and not abbreviated. The default value, TRUE, returns a vector or matrix if appropriate, whereas if simplify = "array" the result may be an array of “rank” (\(=\)length(dim(.))) one higher than the result of FUN(X[[i]]).

Value

A numeric array of dimension p * p * n, where each array is a positive semidefinite matrix, a realization of the Wishart distribution W_p(Sigma, df)

Details

If X_1, ..., X_m is a sample of m independent multivariate Gaussians with mean vector 0, and covariance matrix Sigma, the distribution of M = X'X is W_p(Sigma, m).

Examples

rNonsingularWishart(2, 20, diag(1, 5))
#> , , 1 #> #> [,1] [,2] [,3] [,4] [,5] #> [1,] 15.374968 3.230006 2.8168006 -1.1836827 -2.108909 #> [2,] 3.230006 14.213374 2.5764396 -1.7046481 -2.649192 #> [3,] 2.816801 2.576440 17.3149711 0.5975208 4.092945 #> [4,] -1.183683 -1.704648 0.5975208 10.8716170 1.313598 #> [5,] -2.108909 -2.649192 4.0929451 1.3135976 16.620885 #> #> , , 2 #> #> [,1] [,2] [,3] [,4] [,5] #> [1,] 20.565613 -5.8468928 -2.525587 -4.363362 -4.3310172 #> [2,] -5.846893 26.4898886 2.224945 1.499786 -0.5019079 #> [3,] -2.525587 2.2249454 19.659257 4.501279 1.4150396 #> [4,] -4.363362 1.4997860 4.501279 19.020576 -1.3705010 #> [5,] -4.331017 -0.5019079 1.415040 -1.370501 14.3529960 #>