Learn R Programming

LaplacesDemon (version 16.1.0)

dist.Matrix.Normal: Matrix Normal Distribution

Description

These functions provide the density and random number generation for the matrix normal distribution.

Usage

dmatrixnorm(X, M, U, V, log=FALSE) 
rmatrixnorm(M, U, V)

Arguments

X

This is data or parameters in the form of a matrix with \(n\) rows and \(k\) columns.

M

This is mean matrix with \(n\) rows and \(k\) columns.

U

This is a \(n \times n\) positive-definite scale matrix.

V

This is a \(k \times k\) positive-definite scale matrix.

log

Logical. If log=TRUE, then the logarithm of the density is returned.

Value

dmatrixnorm gives the density and rmatrixnorm generates random deviates.

Details

  • Application: Continuous Multivariate Matrix

  • Density: \(p(\theta) = \frac{\exp(-0.5tr[V^{-1}(X-M)'U^{-1}(X-M)])}{(2\pi)^{nk/2}|V|^{n/2}|U|^{k/2}}\)

  • Inventors: Unknown

  • Notation 1: \(\theta \sim \mathcal{MN}_{n \times k}(M, U, V)\)

  • Notation 2: \(p(\theta) = \mathcal{MN}_{n \times k}(\theta | M, U, V)\)

  • Parameter 1: location \(n \times k\) matrix \(M\)

  • Parameter 2: positive-definite \(n \times n\) scale matrix \(U\)

  • Parameter 3: positive-definite \(k \times k\) scale matrix \(V\)

  • Mean: \(E(\theta) = M\)

  • Variance: Unknown

  • Mode: Unknown

The matrix normal distribution is also called the matrix Gaussian, matrix-variate normal, or matrix-variate Gaussian distribution. It is a generalization of the multivariate normal distribution to matrix-valued random variables.

An example of the use of a matrix normal distribution is multivariate regression, in which there is a \(j \times k\) matrix of regression effects of \(j\) predictors for \(k\) dependent variables. For univariate regression, having only one dependent variable, the \(j\) regression effects may be multivariate normally distributed. For multivariate regression, this multivariate normal distribution may be extended to a matrix normal distribution to account for relationships of the regression effects across \(k\) dependent variables. In this example, the matrix normal distribution is the conjugate prior distribution for these regression effects.

The matrix normal distribution has two covariance matrices, one for the rows and one for the columns. When \(U\) is diagonal, the rows are independent. When \(V\) is diagonal, the columns are independent.

See Also

dinvmatrixgamma, dmatrixgamma, and dmvn.

Examples

Run this code
# NOT RUN {
library(LaplacesDemon)
N <- 10
K <- 4
U <- as.positive.definite(matrix(rnorm(N*N),N,N))
V <- as.positive.definite(matrix(rnorm(K*K),K,K))
x <- dmatrixnorm(matrix(0,N,K), matrix(0,N,K), U, V)
X <- rmatrixnorm(matrix(0,N,K), U, V)
joint.density.plot(X[,1], X[,2], color=TRUE)
# }

Run the code above in your browser using DataLab