predict.matrixlda: Classify Matrix Variate Observations by Linear Discrimination

Description Usage Arguments Details Value See Also Examples

View source: R/matnormlda.R

Description

Classify matrix variate observations in conjunction with matrixlda.

Usage

1
2
## S3 method for class 'matrixlda'
predict(object, newdata, prior = object$prior, ...)

Arguments

object

object of class matrixlda

newdata

array or list of new observations to be classified. If newdata is missing, an attempt will be made to retrieve the data used to fit the matrixlda object.

prior

The prior probabilities of the classes, by default the proportions in the training set or what was set in the call to matrixlda.

...

arguments based from or to other methods

Details

This function is a method for the generic function predict() for class "matrixlda". It can be invoked by calling predict(x) for an object x of the appropriate class.

Value

Returns a list containing the following components:

class

The MAP classification (a factor)

posterior

posterior probabilities for the classes

See Also

matrixlda(), matrixqda(), and matrixmixture()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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)
predict(D)$posterior[1:10, ]

## S3 method for class 'matrixlda'

MixMatrix documentation built on Nov. 16, 2021, 9:25 a.m.