MNIW {mniw}R Documentation

Generate samples from the Matrix-Normal Inverse-Wishart distribution.

Description

Generate samples from the Matrix-Normal Inverse-Wishart distribution.

Usage

rMNIW(n, Lambda, Sigma, Psi, nu, prec = FALSE)

rmniw(n, Lambda, Omega, Psi, nu)

Arguments

n

number of samples.

Lambda

A mean matrix of size p x q or an array of size p x q x n. Defaults to matrix of zeros when missing.

Sigma

A row-wise variance or precision matrix of size p x p, or an array of size p x p x n. Defaults to the identity matrix when missing.

Psi

A scale matrix of size q x q, or an array of size q x q x n. Defaults to identity matrix when missing.

nu

Scalar degrees-of-freedom parameter.

prec

Logical; whether or not Sigma is on the variance or precision scale.

Omega

A between-row precision matrix of size p x p, or an array of size p x p x n. Defaults to the identity matrix when missing.

Details

The Matrix-Normal Inverse-Wishart (MNIW) distribution (\boldsymbol{X}, \boldsymbol{V}) \sim \textrm{MNIW}(\boldsymbol{\Lambda}, \boldsymbol{\Sigma}, \boldsymbol{\Psi}, \nu) on random matrices \boldsymbol{X}_{p \times q} and symmetric positive-definite \boldsymbol{V}_{q\times q} is defined as

\begin{array}{rcl} \boldsymbol{V} & \sim & \textrm{Inverse-Wishart}(\boldsymbol{\Psi}, \nu) \\ \boldsymbol{X} \mid \boldsymbol{V} & \sim & \textrm{Matrix-Normal}(\boldsymbol{\Lambda}, \boldsymbol{\Sigma}, \boldsymbol{V}), \end{array}

where the Matrix-Normal distribution is defined as the multivariate normal

\textrm{vec}(\boldsymbol{X}) \sim \mathcal{N}(\textrm{vec}(\boldsymbol{\Lambda}), \boldsymbol{V} \otimes \boldsymbol{\Sigma}),

where \textrm{vec}(\boldsymbol{X}) is a vector stacking the columns of \boldsymbol{X}, and \boldsymbol{V} \otimes \boldsymbol{\Sigma} denotes the Kronecker product.

rmniw is a convenience wrapper to rMNIW(Sigma = Omega, prec = TRUE), for the common situation in Bayesian inference with conjugate priors when between-row variances are naturally parametrized on the precision scale.

Value

A list with elements:

X

Array of size p x q x n random samples from the Matrix-Normal component (see Details).

V

Array of size q x q x n of random samples from the Inverse-Wishart component.

Examples

# problem dimensions
p <- 2
q <- 3
n <- 10 # number of samples
# parameter specification
Lambda <- matrix(rnorm(p*q),p,q) # single argument
Sigma <- rwish(n, Psi = diag(p), nu = p + rexp(1)) # vectorized argument
Psi <- rwish(n = 1, Psi = diag(q), nu = q + rexp(1)) # single argument
nu <- q + rexp(1)
# simulate n draws
rMNIW(n, Lambda = Lambda, Sigma = Sigma, Psi = Psi, nu = nu)

[Package mniw version 1.0.1 Index]