rwishart_chol: Sampling Cholesky factor of a Wishart matrix

Description Usage Arguments Details Value Examples

View source: R/wishart.R

Description

Samples the lower triangular Cholesky factor of a Wishart random matrix.

Usage

1
rwishart_chol(n, nu, Sigma, epsilon = 0)

Arguments

n

sample size, a positive integer

nu

degrees of freedom, a number strictly greater than p-1, where p is the dimension (the order of Sigma)

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

1
2
3
4
5
6
nu <- 4
p <- 3
Sigma <- diag(p)
Wsims <- rwishart_chol(10000, nu, Sigma)
dim(Wsims) # 3 3 10000
Wsims[,,1]

stla/matrixsampling documentation built on Aug. 27, 2019, 3:03 a.m.