# plsda

From caret v2.27
by Max Kuhn

##### Partial Least Squares Discriminant Analysis

`plsda`

is used to fit PLS models for classification.

- Keywords
- models

##### Usage

`plsda(x, ...)`## S3 method for class 'default':
plsda(x, y, ncomp = 2, ...)

predict.plsda(object, newdata = NULL, ncomp = NULL, type = "class", ...)

##### Arguments

- x
- a matrix or data frame of predictors
- y
- a factor or indicator matrix for the discrete outcome. If a matrix, the entries must be either 0 or 1 and rows must add to one
- ncomp
- the number of components to include in the model
- ...
- arguments to pass to
`plsr`

(code{plsda} only) - object
- an object produced by
`plsda`

- newdata
- a matrix or data frame of predictors
- type
- either
`"class"`

,`"prob"`

or`"raw"`

to produce the predicted class, class probabilities or the raw model scores, respectively.

##### Details

If a factor is supplied, the appropriate indicator matrix is created by `plsda`

.

A multivariate PLS model is fit to the indicator matrix using the `plsr`

function.

To predict, the softmax function is used to normalize the model output into probability-like scores. The class with the largest score is the assigned output class.

##### Value

- For
`plsda`

, an object of class "plsda" and "mvr". The predict method produces either a vector, matrix or three-dimensional array, depending on the values of`type`

of`ncomp`

. For example, specifying more than one value of`ncomp`

with`type = "class"`

with produce a three dimensional array but the default specification would produce a factor vector.

##### See Also

##### Examples

```
data(mdrr)
tmpX <- scale(mdrrDescr)
plsFit <- plsda(tmpX, mdrrClass, ncomp = 3)
table(predict(plsFit), mdrrClass)
```

*Documentation reproduced from package caret, version 2.27, License: GPL 2.0*

### Community examples

Looks like there are no examples yet.