Determination of the number of components based on cross-validated method or Bayesian information criterion (BIC)
ncompsearch(
X,
Y = NULL,
Z = NULL,
comps = 1:3,
lambdaX = NULL,
lambdaY = NULL,
lambdaXsup = NULL,
lambdaYsup = NULL,
eta = 1,
type = "lasso",
inX = NULL,
inY = NULL,
inXsup = NULL,
inYsup = NULL,
muX = 0,
muY = 0,
nfold = 5,
regpara = FALSE,
maxrep = 3,
minpct = 0,
maxpct = 1,
criterion = c("CV", "BIC")[1],
whichselect = NULL,
intseed = 1
)# S3 method for ncompsearch
print(x, ...)
# S3 method for ncompsearch
plot(x, cidx = 1, ...)
numbers of components
minimum criterion values
criterion values
optimal number of components based on minimum cross-validation error
a matrix or list of matrices indicating the explanatory variable(s). This parameter is required.
a matrix or list of matrices indicating objective variable(s). This is optional. If there is no input for Y, then PCA is implemented.
a vector, response variable(s) for implementing the supervised version of (multiblock) PCA or PLS. This is optional. The length of Z is the number of subjects. If there is no input for Z, then unsupervised PLS/PCA is implemented.
numeric vector for the maximum numbers of componets to be considered.
numeric vector of regularized parameters for X, with a length equal to the number of blocks. If lambdaX is omitted, no regularization is conducted.
numeric vector of regularized parameters for Y, with a length equal to the number of blocks. If lambdaY is omitted, no regularization is conducted.
numeric vector of regularized parameters for the super weight of X with length equal to the number of blocks. If omitted, no regularization is conducted.
numeric vector of regularized parameters for the super weight of Y with length equal to the number of blocks. If omitted, no regularization is conducted.
numeric scalar indicating the parameter indexing the penalty family. This version contains only choice 1.
a character, indicating the penalty family. In this version, only one choice is available: "lasso."
a (list of) numeric vector to specify the variables of X which are always in the model.
a (list of) numeric vector to specify the variables of X which are always in the model.
a (list of) numeric vector to specify the blocks of X which are always in the model.
a (list of) numeric vector to specify the blocks of Y which are always in the model.
a numeric scalar for the weight of X for the supervised case. 0 <= muX <= 1.
a numeric scalar for the weight of Y for the supervised case. 0 <= muY <= 1.
number of folds - default is 5.
logical, If TRUE, the regularized parameters search is also conducted simultaneously.
numeric scalar for the number of iteration.
minimum candidate parameters defined as a percentile of automatically determined (possible) candidates.
maximum candidate parameters defined as a percentile of automatically determined (possible) candidates.
a character, the evaluation criterion, "CV" for cross-validation, based on a matrix element-wise error, and "BIC" for Bayesian information criteria. The "BIC" is the default.
which blocks selected.
seed number for the random number in the parameter estimation algorithm.
an object of class "ncompsearch", usually, a result of a call to ncompsearch
further arguments passed to or from other methods.
Parameters used in the plot function to specify whether block or super is used. 1=block (default), 2=super.
This function searches for the optimal number of components.
##### data #####
tmpdata = simdata(n = 50, rho = 0.8, Yps = c(10, 12, 15), Xps = 20, seed=1)
X = tmpdata$X; Y = tmpdata$Y
##### number of components search #####
ncomp1 = ncompsearch(X, Y, comps = c(1, 5, 10*(1:2)), nfold=5)
#plot(ncomp1)
Run the code above in your browser using DataLab