Performs linear discriminant analysis on matrix variate data.
This works slightly differently from the LDA function in MASS:
it does not sphere the data or otherwise normalize it. It presumes
equal variance matrices and probabilities are given as if
the data are from a matrix variate normal distribution.
The estimated variance matrices are weighted by the prior. However,
if there are not enough members of a class to estimate a variance,
this may be a problem.
The function does not take the formula interface. If method = 't'
is selected, this performs discrimination using the matrix variate t
distribution, presuming equal covariances between classes.
matrixlda(
x,
grouping,
prior,
tol = 1e-04,
method = "normal",
nu = 10,
...,
subset
)
3-D array of matrix data indexed by the third dimension
vector
a vector of prior probabilities of the same length as the number of classes
by default, 1e-4
. Tolerance parameter checks
for 0 variance.
whether to use the normal distribution (normal
) or the
t distribution (t
). By default, normal.
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 MLmatrixnorm
(e.g.,
row.mean
)
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 matrixlda
containing
the following components:
prior
the prior probabilities used.
counts
the counts of group membership
means
the group means.
scaling
the scalar variance parameter
U
the between-row covariance matrix
V
the between-column covariance matrix
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.
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>
Ming Li, Baozong Yuan, "2D-LDA: A statistical linear discriminant
analysis for image matrix", Pattern Recognition Letters, Volume 26,
Issue 5, 2005, Pages 527-532, ISSN 0167-8655.
Aaron Molstad & Adam J. Rothman (2019), "A Penalized Likelihood Method for Classification With Matrix-Valued Predictors", Journal of Computational and Graphical Statistics, 28:1, 11-22, doi:10.1080/10618600.2018.1476249 MatrixLDA
Venables, W. N. & Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth Edition. Springer, New York. ISBN 0-387-95457-0 MASS
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 <- matrixlda(C, groups, prior) # fit model
logLik(D)
#> 'log Lik.' -962.6539 (df=39)
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
#>
#>
#> $scaling
#> [1] 0.793638
#>
#> $U
#> [,1] [,2] [,3]
#> [1,] 1.000000000 0.06898319 0.007912669
#> [2,] 0.068983195 0.93223418 -0.033466058
#> [3,] 0.007912669 -0.03346606 0.967866385
#>
#> $V
#> [,1] [,2] [,3] [,4]
#> [1,] 1.00000000 -0.071847232 0.065658541 -0.12269956
#> [2,] -0.07184723 0.949290705 0.006997484 0.09237596
#> [3,] 0.06565854 0.006997484 1.306664921 -0.02648614
#> [4,] -0.12269956 0.092375955 -0.026486138 1.25434970
#>
#> $lev
#> [1] "1" "2"
#>
#> $N
#> [1] 60
#>
#> $method
#> [1] "normal"
#>
#> $nu
#> NULL
#>
#> $call
#> matrixlda(x = C, grouping = groups, prior = prior)
#>
#> attr(,"class")
#> [1] "matrixlda"