MatrixNormal | R Documentation |
Density and random sampling for the Matrix-Normal distribution.
dMNorm(X, Lambda, SigmaR, SigmaC, log = FALSE) rMNorm(n, Lambda, SigmaR, SigmaC)
X |
Argument to the density function. Either a |
Lambda |
Mean parameter Either a |
SigmaR |
Between-row covariance matrix. Either a |
SigmaC |
Between-column covariance matrix Either a |
log |
Logical; whether or not to compute the log-density. |
n |
Integer number of random samples to generate. |
The Matrix-Normal distribution X ~ Matrix-Normal(Λ, Σ_R, Σ_C) on the random matrix X_(p x q) is defined as
vec(X) ~ N(vec(Λ), Σ_C %x% Σ_R),
where vec(X) is a vector stacking the columns of X, and Σ_C %x% Σ_R denotes the Kronecker product.
A vector length n
for density evaluation, or an array of size p x q x n
for random sampling.
# problem dimensions p <- 4 q <- 2 n <- 10 # number of observations # parameter values Lambda <- matrix(rnorm(p*q),p,q) # mean matrix # row-wise variance matrix (positive definite) SigmaR <- crossprod(matrix(rnorm(p*p), p, p)) SigmaC <- rwish(n, Psi = diag(q), nu = q + 1) # column-wise variance (vectorized) # random sample X <- rMNorm(n, Lambda = Lambda, SigmaR = SigmaR, SigmaC = SigmaC) # log-density at each sampled value dMNorm(X, Lambda = Lambda, SigmaR = SigmaR, SigmaC = SigmaC, log = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.