mpda: Multi-level pattern recognition with PLS+LDA

View source: R/mpda.R

mpdaR Documentation

Multi-level pattern recognition with PLS+LDA

Description

A multi-level classification method that fits one pda-model to every pair of factor levels.

Usage

mpda(
  y,
  X,
  reg = 0.5,
  prior = NULL,
  selected = NULL,
  max.dim = NULL,
  n.seg = 10,
  verbose = TRUE
)

Arguments

y

Vector of responses, must be a factor with 3 or more levels.

X

Numeric matrix of predictor values.

reg

The regularization parameter used by pdaDim, see below.

prior

Vector of prior probabilities, one value for each factor level in y.

selected

Matrix of logicals, indicating selected predictor variables, see below.

max.dim

Integer, the maximum number of dimensions to consider in PLS.

n.seg

Integer, the number of cross-validation segments in pdaDim.

verbose

Logical, turns on/off output during computations.

Details

A multi-level problem means the response y is a factor with at least 3 levels, i.e. there are at least 3 distinct class labels (texts, integers, etc) in y. If you have a 2-level problem, use pda.

For each pair of factor levels, a pda model is fitted, using the subset of elements in y containing these two levels, and the corresponding rows of X as predictors. If there are L factor levels, there are N=L*(L-1)/2 such model-pairs.

If the argument reg is positive (between 0 and 1) it means the pdaDim function is used to estimate the dimensionality of each model. See pdaDim for details on this. If reg is negative, all models will be fitted with max.dim dimensions.

The argument prior, if specified, indicates the prior probability of each factor level. There must be one value for each factor level, and in the exact same order as the factor levels. By default, all factor levels have equal prior.

The matrix selected is used to indicate variable selection. For each pair of factor levels, a pda model is fitted, and only a selection of the predictor variables (columns) in X may be used. In row k of selected is a logical vector, one TRUE/FALSE value for each column in X. The TRUE elements indicate which columns of X to use (X[,which(selected[k,])]). PLEASE NOTE: The rows of selected must be ordered according to the factor level pairs:

Row 1: Factor level 1 versus 2

Row 2: Factor level 1 versus 3

...<all unique pairs of ordered levels>...

Row N: Factor level (L-1) versus L

Value

An mpda object, which is a list of the pairwise pda objects. In addition, the mpda object has two attributes: A copy of the full predictor matrix X (attr(mpda.obj,"X"))and the factor levels of y (attr(mpda.obj,"Levels")).

Author(s)

Lars Snipen.

See Also

predict.mpda, pdaDim.

Examples

data(poems)
y <- poems[,1]
X <- as.matrix(poems[,-1])
mp.trn <- mpda(y, X, prior = c(1,1,1), max.dim = 10)


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