MyNixOS website logo
Description

Classification with Matrix Variate Normal and t Distributions.

Provides sampling and density functions for matrix variate normal, t, and inverted t distributions; ML estimation for matrix variate normal and t distributions using the EM algorithm, including some restrictions on the parameters; and classification by linear and quadratic discriminant analysis for matrix variate normal and t distributions described in Thompson et al. (2019) <doi:10.1080/10618600.2019.1696208>. Performs clustering with matrix variate normal and t mixture models.

R buildstatus AppVeyor BuildStatus CoverageStatus packageversion CRAN_Status_Badge

MixMatrix

Provides sampling and density functions for matrix variate normal, t, and inverted t distributions; ML estimation
using the EM algorithm for matrix variate normal and t distributions including some restrictions on the parameters; and classification by linear and quadratic discriminant analysis for matrix variate normal and t distributions. Performs clustering with matrix variate normal and t mixture models.

See the vignettes for an example of how it works.

It is currently possible to constrain the mean matrices for normal and t distributed matrices to have a common mean across rows, columns, or both, as well as AR(1), compound symmetric, on identity covariance matrices across rows, columns, or both in the maximum likelihood estimation functions and the LDA and QDA functions. In the mixture model function, it is possible to have a common mean within groups across rows, columns, or both.

There are some other R packages you may be interested in if you are working with matrix-variate distributions. The excellent matrixsampling package has sampling and distribution functions for these and many other matrix distributions, as does LaplacesDemon. The MatrixLDA package performs LDA for normal distributions with penalized likelihood.

Install from CRAN by running:

install.packages('MixMatrix')

The development version of the software can be installed by running:

devtools::install_github("gzt/MixMatrix")

Usage

The various r* and d* functions return or take as input an array indexed by the third dimension.

meanmatrix = matrix(1:12, nrow = 3)
A = rmatrixnorm(n = 10, mean = meanmatrix, U = diag(3), V = diag(4))
A[,,1:2]
dmatrixnorm(A, mean = meanmatrix, U = diag(3), V = diag(4), log = TRUE)

The package presents a method of maximum likelihood estimation of the parameters of the matrix variate t distribution using ECME.

X = rmatrixt(n = 100, mean = meanmatrix, U = diag(3), V = diag(4), df = 10)
MLmatrixt(X, fixed = FALSE) # fixed = FALSE indicates to estimate the DF parameter

Because it might be useful in conjunction with the r* and d* functions, the package also includes some convenience functions for generating AR(1) and compound symmetry correlation matrices.

ARgenerate(5, .5)
CSgenerate(5, .5)

The package also presents linear discriminant analysis and quadratic discriminant analysis for matrix variate distributions in the case of the normal and the t-distribution. In the case of the t, linear and quadratic refer whether the covariance matrices are constrained to be the same between classes rather than the form of the classifier.

 A <- rmatrixnorm(30,mean=matrix(0,nrow=3,ncol=4))
 B <- rmatrixnorm(30,mean=matrix(1,nrow=3,ncol=4), U = 2 * ARgenerate(3, .8))
 C <- array(c(A,B), dim=c(3,4,60))
 groups <- c(rep(1,30),rep(2,30))
 prior <- c(.5,.5)
 D <- matrixqda(C, groups, prior)
 predict(D)$posterior[1:10,]

In the future, this will include a more comprehensive treatment of matrix variate mixture modeling, including complete specification of covariance matrices in mixture modeling after the style of Mclust, t-Eigen, and other similar work.

    ### set two different matrix variate populations and combine into one array
 A <- rmatrixnorm(30,mean=matrix(0,nrow=3,ncol=4))
 B <- rmatrixnorm(30,mean=matrix(1,nrow=3,ncol=4), U = 2 * ARgenerate(3, .8))
 C <- array(c(A,B), dim=c(3,4,60))
 groups <- c(rep(1,30),rep(2,30))
 prior <- c(.5,.5)
    ### set up the mixture model
 D <- matrixmixture(C, prior, row.mean = TRUE, tolerance = 1e-2)
    ### print the results, the final mixing proportion, the log-likelihood,
    ### the BIC, and a plot of the log-likelihood.
 print(D$centers) # the final centers
 print(D$pi) # the final mixing proportion
 logLik(D)
 BIC(logLik(D))
 plot(D) # the log likelihood by iteration

Contribution and contact information

Please let me know if you have any issues or suggestions here: https://github.com/gzt/MixMatrix/issues

Please note that the MixMatrix project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Metadata

Version

0.2.6

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows