R/trainPLS_general_multipleY.R

#' @export
trainPLS_general_multipleY <- function(x, y, cvsegments = 10, ncomp = "auto", threshold = 0.02, plotting = FALSE){
    n <- ncol(y)
    result <- list()
    for (i in 1:n){
        each_result <- trainPLS_general(x, y[,i], cvsegments = cvsegments, ncomp = ncomp, threshold = threshold, plotting = plotting)
        best_index <- which.max(each_result$R2CV)
        result[[i]] <- each_result[best_index,]
    }
    
    result <- do.call(rbind.data.frame, result)
    cbind(data.frame(y = names(y)), result)
}
chengvt/cheng documentation built on May 13, 2019, 3:52 p.m.