See matrixlda
: quadratic discriminant analysis for matrix
variate observations.
matrixqda( x, grouping, prior, tol = 1e-04, method = "normal", nu = 10, ..., subset )
x | 3-D array of matrix data indexed by the third dimension |
---|---|
grouping | vector |
prior | a vector of prior probabilities of the same length as the number of classes |
tol | by default, |
method | whether to use the normal distribution ( |
nu | If using the t-distribution, the degrees of freedom parameter. By default, 10. |
... | Arguments passed to or from other methods, such
as additional parameters to pass to |
subset | An index vector specifying the cases to be used in the training sample. (NOTE: If given, this argument must be named.) |
Returns a list of class matrixqda
containing
the following components:
prior
the prior probabilities used.
counts
the counts of group membership
means
the group means.
U
the between-row covariance matrices
V
the between-column covariance matrices
lev
levels of the grouping factor
N
The number of observations used.
method
The method used.
nu
The degrees of freedom parameter if the t-distribution was used.
call
The (matched) function call.
This uses MLmatrixnorm
or MLmatrixt
to find the means and
variances for the case when different groups have different variances.
G Z Thompson, R Maitra, W Q Meeker, A Bastawros (2019), "Classification with the matrix-variate-t distribution", arXiv e-prints arXiv:1907.09565 <https://arxiv.org/abs/1907.09565>
Venables, W. N. & Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth Edition. Springer, New York. ISBN 0-387-95457-0
Pierre Dutilleul. The MLE algorithm for the matrix normal distribution. Journal of Statistical Computation and Simulation, (64):105–123, 1999.
set.seed(20180221) # construct two populations of 3x4 random matrices with different means A <- rmatrixnorm(30, mean = matrix(0, nrow = 3, ncol = 4)) B <- rmatrixnorm(30, mean = matrix(1, nrow = 3, ncol = 4)) C <- array(c(A, B), dim = c(3, 4, 60)) # combine together groups <- c(rep(1, 30), rep(2, 30)) # define groups prior <- c(.5, .5) # set prior D <- matrixqda(C, groups, prior) logLik(D) #> 'log Lik.' -958.9359 (df=54) print(D) #> $prior #> 1 2 #> 0.5 0.5 #> #> $counts #> 1 2 #> 30 30 #> #> $means #> , , 1 #> #> [,1] [,2] [,3] [,4] #> [1,] 0.07351694 -0.08704738 0.13826608 0.06657800 #> [2,] -0.05562527 -0.08631880 -0.12719766 -0.07388404 #> [3,] -0.12802865 -0.33410177 -0.05220913 -0.03813562 #> #> , , 2 #> #> [,1] [,2] [,3] [,4] #> [1,] 1.1213360 1.230815 0.9142843 1.082488 #> [2,] 1.3283770 1.244675 0.5694279 1.000457 #> [3,] 0.8961279 0.800175 1.1439663 1.048916 #> #> #> $U #> , , 1 #> #> [,1] [,2] [,3] #> [1,] 1.00000000 0.14788530 0.02800227 #> [2,] 0.14788530 0.86714312 0.02258292 #> [3,] 0.02800227 0.02258292 0.98364372 #> #> , , 2 #> #> [,1] [,2] [,3] #> [1,] 1.000000000 -0.0173930 -0.004498732 #> [2,] -0.017392997 0.9987747 -0.100860770 #> [3,] -0.004498732 -0.1008608 0.977978559 #> #> #> $V #> , , 1 #> #> [,1] [,2] [,3] [,4] #> [1,] 0.81179597 -0.13499901 0.07550758 -0.15466849 #> [2,] -0.13499901 0.82945236 -0.04492883 0.06490810 #> [3,] 0.07550758 -0.04492883 1.03826075 -0.09438137 #> [4,] -0.15466849 0.06490810 -0.09438137 0.97282616 #> #> , , 2 #> #> [,1] [,2] [,3] [,4] #> [1,] 0.76072995 0.01856625 0.03148175 -0.05903717 #> [2,] 0.01856625 0.67294239 0.05448755 0.10257451 #> [3,] 0.03148175 0.05448755 1.02451969 0.03848553 #> [4,] -0.05903717 0.10257451 0.03848553 1.03348309 #> #> #> $lev #> [1] "1" "2" #> #> $N #> [1] 60 #> #> $method #> [1] "normal" #> #> $nu #> NULL #> #> $call #> matrixqda(x = C, grouping = groups, prior = prior) #> #> attr(,"class") #> [1] "matrixqda"