rwishart_chol {matrixsampling} | R Documentation |
Sampling Cholesky factor of a Wishart matrix
Description
Samples the lower triangular Cholesky factor of a Wishart random matrix.
Usage
rwishart_chol(n, nu, Sigma, epsilon = 0)
Arguments
n |
sample size, a positive integer |
nu |
degrees of freedom, a number strictly greater than |
Sigma |
scale matrix, a positive definite real matrix |
epsilon |
a number involved in the algorithm only if it positive; its role is to guarantee the invertibility of the sampled matrices; see Details |
Details
The argument epsilon
is a threshold whose role is to guarantee
that the algorithm samples invertible matrices.
The matrices sampled by the algorithm are theoretically invertible.
However, because of numerical precision, they are not always invertible when
nu
is close to p-1
, i.e. when nu-p+1
is small. In this case,
the simulations of chi-squared distributions involved in the algorithm can
generate zero values or values close to zero, yielding the non-invertibility
of the sampled matrices. These values are replaced with epsilon
if they are
smaller than epsilon
.
Value
A numeric three-dimensional array; simulations are stacked along the third dimension (see example).
Examples
nu <- 4
p <- 3
Sigma <- diag(p)
Wsims <- rwishart_chol(10000, nu, Sigma)
dim(Wsims) # 3 3 10000
Wsims[,,1]