MNIW | R Documentation |
Generate samples from the Matrix-Normal Inverse-Wishart distribution.
rMNIW(n, Lambda, Sigma, Psi, nu, prec = FALSE) rmniw(n, Lambda, Omega, Psi, nu)
n |
number of samples. |
Lambda |
A mean matrix of size |
Sigma |
A row-wise variance or precision matrix of size |
Psi |
A scale matrix of size |
nu |
Scalar degrees-of-freedom parameter. |
prec |
Logical; whether or not |
Omega |
A between-row precision matrix of size |
The Matrix-Normal Inverse-Wishart (MNIW) distribution (X, V) ~ MNIW(Λ, Σ, Ψ, ν) on random matrices X_(p x q) and symmetric positive-definite V_(q x q) is defined as
V ~ Inverse-Wishart(Ψ, ν) X | V ~ Matrix-Normal(Λ, Σ, V),
where the Matrix-Normal distribution is defined as the multivariate normal
vec(X) ~ N(vec(Λ), V %x% Σ),
where vec(X) is a vector stacking the columns of X, and V %x% Σ 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.
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.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.