This function computes the optimal model parameter using cross-validation.
pls.cv(
X,
y,
k = 10,
groups = NULL,
m = ncol(X),
use.kernel = FALSE,
compute.covariance = FALSE,
method.cor = "pearson"
)
matrix of cross-validated errors based on mean squared error. A row corresponds to one cross-validation split.
vector of cross-validated errors based on mean squared error
optimal number of components based on mean squared error
intercept of the optimal model, based on mean squared error
vector of regression coefficients of the optimal model, based on mean squared error
matrix of cross-validated errors based on correlation. A row corresponds to one cross-validation split.
vector of cross-validated errors based on correlation
optimal number of components based on correlation
intercept of the optimal model, based on correlation
vector of regression coefficients of the optimal model, based on mean squared error
If
TRUE
and use.kernel=FALSE
, the covariance of the cv-optimal
regression coefficients (based on mean squared error) is returned.
matrix of predictor observations.
vector of response observations. The length of y
is the same
as the number of rows of X
.
number of cross-validation splits. Default is 10.
an optional vector with the same length as y
. It
encodes a partitioning of the data into distinct subgroups. If groups
is provided, k=10
is ignored and instead, cross-validation is
performed based on the partioning. Default is NULL
.
maximal number of Partial Least Squares components. Default is
m=ncol(X)
.
Use kernel representation? Default is
use.kernel=FALSE
.
If TRUE
, the function computes the
covariance for the cv-optimal regression coefficients.
How should the correlation to the response be computed? Default is ''pearson''.
Nicole Kraemer, Mikio L. Braun
The data are centered and scaled to unit variance prior to the PLS
algorithm. It is possible to estimate the covariance matrix of the
cv-optimal regression coefficients (compute.covariance=TRUE
).
Currently, this is only implemented if use.kernel=FALSE
.
Kraemer, N., Sugiyama M. (2011). "The Degrees of Freedom of Partial Least Squares Regression". Journal of the American Statistical Association 106 (494) https://www.tandfonline.com/doi/abs/10.1198/jasa.2011.tm10107
Kraemer, N., Braun, M.L. (2007) "Kernelizing PLS, Degrees of Freedom, and Efficient Model Selection", Proceedings of the 24th International Conference on Machine Learning, Omni Press, 441 - 448
pls.model
, pls.ic
n<-50 # number of observations
p<-5 # number of variables
X<-matrix(rnorm(n*p),ncol=p)
y<-rnorm(n)
# compute linear PLS
pls.object<-pls.cv(X,y,m=ncol(X))
# define random partioning
groups<-sample(c("a","b","c"),n,replace=TRUE)
pls.object1<-pls.cv(X,y,groups=groups)
Run the code above in your browser using DataLab