% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stats_cv_extract.R
\name{.oplsComponentCv}
\alias{.oplsComponentCv}
\title{OPLS Component Estimation via Cross-Validation}
\usage{
.oplsComponentCv(X, Ycs_fold, cv.set, nc, mod.cv, acc)
}
\arguments{
\item{X}{Numeric matrix. Input data matrix (samples x features); only
required for \code{nc = 1}.}

\item{Ycs_fold}{List containing the response values (\code{Y}) for each
cross-validation split.}

\item{cv.set}{List of integer vectors. Each element contains training indices
for one CV round.
These indices are adjusted internally by -1 due to 0-based indexing in the
underlying C++ (Rcpp) routines.}

\item{nc}{Integer. Component number currently being estimated (\code{nc = 1}
for first orthogonal component).}

\item{mod.cv}{List. Model state to be updated with results from each CV iteration.}
}
\value{
A list of the same length as \code{cv.set}. Each list element contains:
\itemize{
\item \code{t_xo}: Orthogonal component scores (matrix, samples x components).
\item \code{t_xp}: Predictive component scores (matrix, samples x 1).
\item \code{y_pred_train}: Predicted responses for training samples.
\item \code{y_pred_test}: Predicted responses for held-out test samples.
\item \code{x_res}: Residual matrix after filtering out orthogonal structure.
}
}
\description{
Performs orthogonal projections to latent structures (OPLS) modeling on
training folds of a cross-validation (CV) scheme.
The function fits one orthogonal and one predictive component per fold,
tracking scores, predictions, and residuals.
For the first orthogonal component (\code{nc = 1}), the full model structure
is initialized.
For later components (\code{nc > 1}), modeling proceeds on residual matrices
carried over from previous iterations.
}
\note{
Training indices in \code{cv.set} are internally adjusted by -1 before
being passed to Rcpp routines.
This is required because C++ uses zero-based indexing.
}
\keyword{internal}
