predict.mpda: Classify based on an mpda object

View source: R/mpda.R

predict.mpdaR Documentation

Classify based on an mpda object

Description

Classify new data based on a trained mpda model.

Usage

## S3 method for class 'mpda'
predict(object, newdata = NULL, ...)

Arguments

object

A fitted mpda model.

newdata

Matrix of predictor values.

...

Additional arguments to lda.

Details

Based on the trained mpda model, new data objects (rows of newdata) are classified, i.e. assigned to a level of the response factor. Remember that mpda does not scale the predictor matrix, make certain your newdata are treated identically to the predictor matrix used to train the mpda model. If no newdata are available, the training data in the mpda object are used.

Notice: Only the largest dimension of each pairwise pda model is used for prediction. When training the mpda you would normally use the regularization argument reg and pdaDim to estimate the dimension for each pariwise model, see mpda. Thus, different pairwise pda are trained to their optimal dimensionality.

Value

A list with two elements, Classifications and Post.means.

The vector Classifications are the suggested factor level for each sample in newdata.

The matrix Post.means contains the posterior mean values for each factor level. For L factor levels, each level is competing' against the other in (L-1) 'matches'. Each match results in posterior probabilities for the two competing levels. The Post.mean scores of level k is simply the average of these (L-1) posterior probabilities. If a sample has a Post.means value close to 1 for level k, it means this level is the clear winner in all pairwise 'matches'.

Author(s)

Lars Snipen.

See Also

mpda.

Examples

data(poems)
y <- poems[,1]
X <- as.matrix(poems[,-1])
mp.trn <- mpda(y, X, reg = 0.5, prior = c(1,1,1), max.dim = 3)
lst <- predict(mp.trn)
print(table(y, lst$Classifications))


larssnip/mpda documentation built on March 28, 2022, 3:37 p.m.