Learn R Programming

spls (version 1.0-0)

cv.spls: Compute and plot the cross-validated error for SPLS regression

Description

Draw the heatmap-type plot of the v-fold cross-validated mean square prediction error and return the optimal eta (thresholding parameter) and K (number of hidden components).

Usage

cv.spls( x, y, fold=10, K, eta, kappa=0.5,
        select="pls2", fit="simpls",
        scale=TRUE, center=TRUE, scale.y=FALSE )

Arguments

x
Matrix of predictors.
y
Vector or matrix of responses.
fold
Number of cross-validation folds. Default is 10-folds.
K
Number of hidden components.
eta
Thresholding parameter. eta should be between 0 and 1.
kappa
Parameter to control the effect of the concavity of the objective function and the closeness of the original and surrogate direction vectors. kappa is relevant only when the responses are multivariate. kappa
select
PLS algorithm for variable selection. Alternatives are "pls2" or "simpls". Default is "pls2".
fit
PLS algorithm for model fitting. Alternatives are "kernelpls", "widekernelpls", "simpls", or "oscorespls". Default is "simpls".
scale
Scale the predictors by dividing each predictor variable by its sample standard deviation?
center
Center the predictors?
scale.y
Scale the responses by dividing each response variable by its sample standard deviation?

Value

  • Invisibly returns a list with components:
  • mspematMatrix of the cross-validated mean squared prediction error. Rows correspond to eta and columns correspond to the number of components (K).
  • etaoptOptimal eta.
  • KoptOptimal K.

References

Chun, H. and Keles, S. (2007). "Sparse partial least squares for simultaneous dimension reduction and variable selection", (http://www.stat.wisc.edu/~keles/Papers/SPLS_Nov07.pdf).

See Also

print, plot, predict, and coef methods for spls.

Examples

Run this code
data(yeast)
set.seed(1)
# MSPE plot. eta is searched between 0.1 and 0.9 and
# the number of hidden components is searched between 1 and 10
cv <- cv.spls( yeast$x, yeast$y, K = c(1:10), eta = seq(0.1,0.9,0.1) )
# Optimal eta and K
cv$etaopt
cv$Kopt

Run the code above in your browser using DataLab