Partial Least Squares (PLS) classification and regression for test set from training set.
pls (Xtrain,
Ytrain,
Xtest = NULL,
Ytest = NULL,
ncomp=min(5,c(ncol(Xtrain),nrow(Xtrain))),
scaling = c("centering", "autoscaling","none"),
method = c("plssvd", "simpls"),
svd.method = c("irlba", "dc"),
fit = FALSE,
proj = FALSE,
perm.test = FALSE,
times = 100)A list with the following components:
the (p x m x length(ncomp)) matrix containing the regression coefficients. Each row corresponds to a predictor variable and each column to a response variable. The third dimension of the matrix B corresponds to the number of PLS components used to compute the regression coefficients. If ncomp has length 1, B is just a (p x m) matrix.
the (m x max(ncomp)) matrix containing the Y-loadings.
the (ntrain x max(ncomp)) matrix containing the X-scores (latent components)
the (p x max(ncomp)) matrix containing the weights used to construct the latent components.
mean X.
variance X.
mean Y.
matrix for the independent variable X. This indicates how the original data relates to the latent components.
number of predictor variables
number of components used in the PLS model
the prediction values based on the PLS model
proportion of variance in Y
a boolgean output is given indicating if the response variable is a classification
level of response variable Y
the (ntest x m x length(ncomp)) containing the predicted values of the response variables for the observations from Xtest. The third dimension of the matrix Ypred corresponds to the number of PLS components used to compute the regression coefficients.
the (p x max(ncomp)) matrix containing the X-loadings.
...
a matrix of training set cases.
a classification vector.
a matrix of test set cases.
a classification vector.
the number of components to consider.
the scaling method to be used. Choices are "centering", "autoscaling", or "none" (by default = "centering"). A partial string sufficient to uniquely identify the choice is permitted.
the algorithm to be used to perform the PLS. Choices are "plssvd" or "simpls" (by default = "plssvd"). A partial string sufficient to uniquely identify the choice is permitted.
the SVD method to be used to perform the PLS. Choices are "irlba" or "dc" (by default = "irlba"). A partial string sufficient to uniquely identify the choice is permitted.
a boolean value to perform the fit.
a boolean value to perform the fit.
a classification vector.
a classification vector.
Dupe Ojo, Alessia Vignoli, Stefano Cacciatore, Leonardo Tenori
optim.pls.cv,pls.double.cv
data(iris)
data=iris[,-5]
labels=iris[,5]
ss=sample(150,15)
ncomponent=3
z=pls(data[-ss,], labels[-ss], data[ss,], ncomp=ncomponent)
Run the code above in your browser using DataLab