% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stats_fit_pls.r
\name{pls}
\alias{pls}
\title{Fit a Partial Least Squares (PLS) model}
\usage{
pls(X, Y, scaling, validation_strategy, maxPCo = 5)
}
\arguments{
\item{X}{Numeric matrix of predictors (rows = samples, columns = variables).}

\item{Y}{Numeric matrix or factor vector of responses.}

\item{scaling}{A scaling strategy object (e.g., \code{uv_scaling(center = TRUE)}),
specifying model-internal centering and/or scaling applied during fitting.
This does not modify the original spectral matrix.}

\item{validation_strategy}{A cross-validation strategy object defining how
resampling is performed (e.g., k-fold, Monte Carlo).}

\item{maxPCo}{Integer. Maximum number of predictive components to evaluate.}
}
\value{
An object of class \code{m8_model} containing the fitted PLS model,
cross-validation results, and performance statistics.
}
\description{
Fits a supervised Partial Least Squares (PLS) model using a NIPALS-based
algorithm with optional cross-validation and automatic component selection.
}
\details{
Model components are estimated sequentially using a NIPALS-based algorithm.
For each component, cross-validated performance metrics (e.g., Q², R²,
classification AUC) are computed according to the supplied
\code{validation_strategy}. Component extraction stops when the
\code{stopRule} indicates overfitting or when \code{maxPCo} is reached.

Scaling specified via \code{scaling} is applied internally during model
fitting and does not alter the input matrix \code{X}. Spectral preprocessing
steps (e.g., alignment, baseline correction) should be performed prior to
model fitting.

The returned model object stores:
\itemize{
\item Fitted component models
\item Cross-validation results
\item Performance metrics (R², Q², AUC)
\item Model control parameters
\item Input data provenance metadata
\item Session information for reproducibility
}
}
\examples{
data(covid)

cv <- balanced_mc(k=5, split=2/3)
scaling <- uv_scaling(center=TRUE)
model <-pls(X=covid$X, Y=covid$an$type, scaling, cv)

show(model)
summary(model)

Tp <- scores(model)
Pp <- loadings(model)
}
\seealso{
\code{\link{opls}}, \code{\link{uv_scaling}}

Other modelling: 
\code{\link{opls}()},
\code{\link{pca}()}
}
\concept{modelling}
