cv_snpls: Cross-validation for a sNPLS model

View source: R/sNPLS_fit.R

cv_snplsR Documentation

Cross-validation for a sNPLS model

Description

Performs cross-validation for a sNPLS model

Usage

cv_snpls(
  X_npls,
  Y_npls,
  ncomp = 1:3,
  samples = 20,
  threshold_j = c(0, 1),
  threshold_k = c(0, 1),
  keepJ = NULL,
  keepK = NULL,
  nfold = 10,
  parallel = TRUE,
  method = "sNPLS",
  metric = "RMSE",
  ...
)

Arguments

X_npls

A three-way array containing the predictors.

Y_npls

A matrix containing the response.

ncomp

A vector with the different number of components to test

samples

Number of samples for performing random search in continuous thresholding

threshold_j

Vector with threshold min and max values on Wj. Scaled between [0, 1)

threshold_k

Vector with threshold min and max values on Wk. Scaled between [0, 1)

keepJ

A vector with the different number of selected variables to test for discrete thresholding

keepK

A vector with the different number of selected 'times' to test for discrete thresholding

nfold

Number of folds for the cross-validation

parallel

Should the computations be performed in parallel? Set up strategy first with future::plan()

method

Select between sNPLS, sNPLS-SR or sNPLS-VIP

metric

Select between RMSE or AUC (for 0/1 response)

...

Further arguments passed to sNPLS

Value

A list with the best parameters for the model and the CV error

Examples

## Not run: 
X_npls<-array(rpois(7500, 10), dim=c(50, 50, 3))

Y_npls<-matrix(2+0.4*X_npls[,5,1]+0.7*X_npls[,10,1]-0.9*X_npls[,15,1]+
0.6*X_npls[,20,1]- 0.5*X_npls[,25,1]+rnorm(50), ncol=1)
#Grid search for discrete thresholding
cv1<- cv_snpls(X_npls, Y_npls, ncomp=1:2, keepJ = 1:3, keepK = 1:2, parallel = FALSE)
#Random search for continuous thresholding
cv2<- cv_snpls(X_npls, Y_npls, ncomp=1:2, samples=20, parallel = FALSE)

## End(Not run)

David-Hervas/sNPLS documentation built on Feb. 1, 2024, 6:30 a.m.