Package 'MN'

Title: Matrix Normal Distribution
Description: Density computation, random matrix generation and maximum likelihood estimation of the matrix normal distribution. References: Pocuca N., Gallaugher M. P., Clark K. M. & McNicholas P. D. (2019). Assessing and Visualizing Matrix Variate Normality. <doi:10.48550/arXiv.1910.02859> and the relevant wikipedia page.
Authors: Michail Tsagris [aut, cre], Alzeley Omar [ctb]
Maintainer: Michail Tsagris <[email protected]>
License: GPL (>= 2)
Version: 1.0
Built: 2024-12-04 07:31:22 UTC
Source: CRAN

Help Index


Matrix Normal Distribution

Description

Density computation, random matrix generation and maximum likelihood estimation of the matrix normal distribution. For references see: Pocuca N., Gallaugher M. P., Clark K. M. & McNicholas P. D. (2019). Assessing and Visualizing Matrix Variate Normality. arXiv:1910.02859 and the relevant wikipedia page.

Details

Package: MN
Type: Package
Version: 1.0
Date: 2024-05-21

Maintainers

Michail Tsagris <[email protected]>.

Author(s)

Michail Tsagris [email protected] and Omar Alzeley [email protected]

References

Pocuca, N., Gallaugher, M. P., Clark, K. M., & McNicholas, P. D. (2019). Assessing and Visualizing Matrix Variate Normality. arXiv:1910.02859.


Density of the matrix normal distribution

Description

Density of the matrix normal distribution.

Usage

dmn(X, M, U, V, logged = FALSE)

Arguments

X

A list with k elements, k matrices of dimension n timespn \ times p each. In the case of one matrix only, this may be given as a numerical matrix and not as an element in a list.

M

The mean matrix of the distribution, a numerical matrix of dimensions n×pn \times p.

U

The covariance matrix associated with the rows, a numerical matrix of dimensions n×nn \times n.

V

The covariance matrix associated with the columns, a numerical matrix of dimensions p×pp \times p.

logged

Should the logarithm of the density be computed?

Value

A numeric vector with the (logged) density values.

Author(s)

Omar Alzeley.

R implementation and documentation: Omar Alzeley [email protected].

References

https://en.wikipedia.org/wiki/Matrix_normal_distribution#Definition

Pocuca, N., Gallaugher, M. P., Clark, K. M., & McNicholas, P. D. (2019). Assessing and Visualizing Matrix Variate Normality. arXiv:1910.02859.

See Also

rmn, mn.mle, ddplot

Examples

M <- as.matrix(iris[1:8, 1:4])
U <- cov( matrix( rnorm(100 * 8), ncol = 8 ) )
V <- cov( iris[1:50, 1:4] )
X <- rmn(10, M, U, V)
dmn(X, M, U, V, TRUE)

Distance-Distance Plot

Description

Distance-Distance Plot

Usage

ddplot(X, M, U, V)

Arguments

X

A list with k elements, k matrices of dimension n timespn \ times p each. In the case of one matrix only, this may be given as a numerical matrix and not as an element in a list.

M

The mean matrix of the distribution, a numerical matrix of dimensions n×pn \times p.

U

The covariance matrix associated with the rows, a numerical matrix of dimensions n×nn \times n.

V

The covariance matrix associated with the columns, a numerical matrix of dimensions p×pp \times p.

Details

The distance-distance plot is produced. This is a scatter plot of the Mahalanobis distances computed using the estimated parameters from the multivariate normal and matrix normal distribution. See Pocuca et al. (2019) for more details.

Value

A scatter plot of the Mahalanobis distances.

Author(s)

Michail Tsagris and Omar Alzeley.

R implementation and documentation: Michail Tsagris [email protected] and Omar Alzeley [email protected].

References

Pocuca N., Gallaugher M. P., Clark K. M. & McNicholas P. D. (2019). Assessing and Visualizing Matrix Variate Normality. arXiv:1910.02859.

See Also

rmn, mn.mle, dmn, ddkstest

Examples

M <- as.matrix(iris[1:8, 1:4])
U <- cov( matrix( rnorm(100 * 8), ncol = 8 ) )
V <- cov( iris[1:50, 1:4] )
X <- rmn(100, M, U, V)
ddplot(X, M, U, V)

Kolmogorov-Smirnov test for matrix normality

Description

Kolmogorov-Smirnov test for matrix normality

Usage

ddkstest(X, M, U, V, alpha = 0.05)

Arguments

X

A list with k elements, k matrices of dimension n timespn \ times p each. In the case of one matrix only, this may be given as a numerical matrix and not as an element in a list.

M

The mean matrix of the distribution, a numerical matrix of dimensions n×pn \times p.

U

The covariance matrix associated with the rows, a numerical matrix of dimensions n×nn \times n.

V

The covariance matrix associated with the columns, a numerical matrix of dimensions p×pp \times p.

alpha

The significance level for the test, set by default equal to 0.05.

Details

The Kolmogorov-Smirnov test for matrix normality is performed. See Pocuca (2019) for more details.

Value

A message. If the Kronecker product covariance structure is not present, the message reads "Reject" and "Not reject otherwise".

Author(s)

Michail Tsagris.

R implementation and documentation: Michail Tsagris [email protected].

References

Pocuca N., Gallaugher M. P., Clark K. M. & McNicholas P. D. (2019). Assessing and Visualizing Matrix Variate Normality. arXiv:1910.02859.

See Also

rmn, mn.mle, dmn, ddplot

Examples

M <- as.matrix(iris[1:8, 1:4])
U <- cov( matrix( rnorm(100 * 8), ncol = 8 ) )
V <- cov( iris[1:50, 1:4] )
X <- rmn(200, M, U, V)
ddkstest(X, M, U, V)

Maximum likelihood estimation of the the matrix normal distribution

Description

Maximum likelihood estimation of the the matrix normal distribution.

Usage

mn.mle(X)

Arguments

X

A list with k elements (k is the sample size), k matrices of dimension n timespn \ times p each.

Value

A list including:

runtime

The runtime required for the whole fitting procedure.

iters

The number of iterations required for the estimation of the U and V matrices.

M

The estimated mean matrix of the distribution, a numerical matrix of dimensions n×pn \times p.

U

The estimated covariance matrix associated with the rows, a numerical matrix of dimensions n×nn \times n.

V

The estimated covariance matrix associated with the columns, a numerical matrix of dimensions p×pp \times p.

Author(s)

Michail Tsagris.

R implementation and documentation: Michail Tsagris [email protected].

References

https://en.wikipedia.org/wiki/Matrix_normal_distribution#Definition

Pocuca N., Gallaugher M. P., Clark K. M. & McNicholas P. D. (2019). Assessing and Visualizing Matrix Variate Normality. arXiv:1910.02859.

See Also

dmn, rmn, ddplot

Examples

M <- as.matrix(iris[1:8, 1:4])
U <- cov( matrix( rnorm(100 * 8), ncol = 8 ) )
V <- cov( iris[1:50, 1:4] )
X <- rmn(200, M, U, V)
mod <- mn.mle(X)

Random matrices simulation from the matrix normal distribution

Description

Random matrices simulation from the matrix normal distribution.

Usage

rmn(k, M, U, V)

Arguments

k

The sample size, the number of matrices to simulate.

M

The mean matrix of the distribution, a numerical matrix of dimensions n×pn \times p.

U

The covariance matrix associated with the rows, a numerical matrix of dimensions n×nn \times n.

V

The covariance matrix associated with the columns, a numerical matrix of dimensions p×pp \times p.

Value

A list with k elements, k matrices of dimension n timespn \ times p each. These are the random matrices drawn from a matrix normal distribution.

Author(s)

Michail Tsagris.

R implementation and documentation: Michail Tsagris [email protected].

References

https://en.wikipedia.org/wiki/Matrix_normal_distribution#Definition

See Also

dmn, mn.mle, ddplot

Examples

M <- as.matrix(iris[1:8, 1:4])
U <- cov( matrix( rnorm(100 * 8), ncol = 8 ) )
V <- cov( iris[1:50, 1:4] )
X <- rmn(10, M, U, V)