Learn R Programming

mixOmics (version 2.8-1)

predict: Predict Method for PLS, sparse PLS, PLSDA Regression or Sparse PLSDA

Description

Predicted values based on PLS, sparse PLS, PLSDA Regression or Sparse PLSDA models. New responses and variates are predicted using a fitted model and a new matrix of observations.

Usage

## S3 method for class 'pls':
predict(object, newdata, ...)
## S3 method for class 'spls':
predict(object, newdata, ...)
## S3 method for class 'splsda':
predict(object, newdata, method = c("class.dist", "centroids.dist", "Sr.dist", "max.dist"), ...)
## S3 method for class 'plsda':
predict(object, newdata, method = c("class.dist", "centroids.dist", "Sr.dist", "max.dist"), ...)

Arguments

object
object of class inheriting from "splsda" or "plsda".
newdata
data matrix in which to look for for explanatory variables to be used for prediction.
method
method to be applied for "splsda" or "plsda" to predict the class of new data. It can be either "max.dist", "centroids.dist", "class.dist", or "Sr.dist", see details.
...
other arguments to be passed predict.default.

Value

  • predict produces a list with the following components:
  • predicta three dimensional array of predicted response values. The dimensions correspond to the observations, the response variables and the model dimension, respectively.
  • variatesmatrix of predicted variates.
  • B.hatmatrix of regression coefficients (without the intercept).
  • classpredicted class of the newdata observation for each PLS dimension.
  • centroid

encoding

latin1

Details

predict produces predicted values, obtained by evaluating the PLS/sPLS/PLSDA or sparse PLSDA model returned by pls, spls, plsda or splsda in the frame newdata. Variates for newdata are also returned. Different prediction methods are proposed: -max.dist is the naive method to predict the class. It is based on the predicted Y matrix (object$predict) which can be seen as a probability matrix to assign each test data to a class.

References

Tenenhaus, M. (1998). La r�gression PLS: th�orie et pratique. Paris: Editions Technic.

See Also

pls, spls, plsda, splsda.

Examples

Run this code
## First example with plsda
data(liver.toxicity)
X = as.matrix(liver.toxicity$gene)
Y = as.factor(liver.toxicity$treatment[,4] )

# if training is perfomed on 4/5th of the original data
samp = sample(1:5, nrow(X), replace = TRUE)  
test = which(samp == 1)   # testing on the first fold
train = setdiff(1:nrow(X), test)

plsda.train = plsda(X[train,], Y[train], ncomp = 1,  mode = 'regression')
test.predict = predict(plsda.train, X[test,], method = "class.dist")
test.predict$cl

## Second example with splsda
data(liver.toxicity)
X = as.matrix(liver.toxicity$gene)
Y = as.factor(liver.toxicity$treatment[,4])  # time points

# if training is perfomed on 4/5th of the original data
samp = sample(1:5, nrow(X), replace = TRUE)  
test = which(samp == 1)   # testing on the first fold
train = setdiff(1:nrow(X), test)


splsda.train = splsda(X[train,], Y[train], ncomp = 1, keepX = 20, mode = 'regression')
test.predict = predict(splsda.train, X[test,], method = "class.dist")
test.predict$cl

Run the code above in your browser using DataLab