predict,opls-method {ropls} | R Documentation

## Predict method for (O)PLS models

### Description

Returns predictions of the (O)PLS(-DA) model on a new dataset

### Usage

    ## S4 method for signature 'opls'
    predict(object, newdata, ...)

### Arguments

`object` | An S4 object of class `opls`, created by `opls` function.
`newdata` | Either a data frame or a matrix, containing numeric columns only, with the same number of columns (variables) as the 'x' used for model training with 'opls'.
`...` | Currently not used.

### Value

Predictions (either a vector, factor, or matrix depending on the y response used for training the model)

### Author(s)

Etienne Thevenot, etienne.thevenot@cea.fr

### Examples

    data(sacurine)
    attach(sacurine)

    predictorMN <- dataMatrix
    responseFc <- sampleMetadata[, "gender"]

    sacurine.plsda <- opls(predictorMN,
                           responseFc,
                           subset = "odd")

    trainVi <- getSubsetVi(sacurine.plsda)

    table(responseFc[trainVi], fitted(sacurine.plsda))

    table(responseFc[-trainVi],
          predict(sacurine.plsda, predictorMN[-trainVi, ]))

    detach(sacurine)

[Package ropls version 1.16.0 Index]