% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stats_model_helpers.R
\name{.evalFit}
\alias{.evalFit}
\title{Evaluate model fit progression based on cross-validated performance}
\usage{
.evalFit(
  type,
  q2s,
  cv_auc,
  pc_max = 5,
  min_delta = 0.05,
  sat_q2 = 0.98,
  sat_auc = 0.97,
  min_q2 = 0.05,
  min_auc = 0.6
)
}
\arguments{
\item{type}{Character. Model type: \code{"R"} for regression or \code{"DA"} for
discriminant analysis. The value may optionally include a suffix
such as \code{"-mY"} to indicate multi-response models.}

\item{q2s}{Numeric vector of \eqn{Q^2} values for the fitted
components (used for regression models).}

\item{cv_auc}{Numeric vector of cross-validated AUROC values for
the fitted components (used for classification models).}

\item{pc_max}{Integer. Maximum number of components allowed.}

\item{min_delta}{Numeric. Minimum improvement in the cross-validated
performance metric required to justify fitting an additional
component.}

\item{sat_q2}{Numeric. Saturation threshold for \eqn{Q^2} in
regression models.}

\item{sat_auc}{Numeric. Saturation threshold for cross-validated
AUROC in discriminant analysis models.}

\item{min_q2}{Numeric. Minimum acceptable \eqn{Q^2} value for the
first component.}

\item{min_auc}{Numeric. Minimum acceptable cross-validated AUROC for
the first component.}
}
\value{
A list containing:
\describe{
\item{stop}{Logical indicating whether model fitting should stop.}
\item{reason}{Character string describing the stopping condition
(e.g., \code{"pc_max"}, \code{"cv_decreased"}, \code{"cv_improvement_negligible"}).}
\item{metric}{The current cross-validated performance value.}
\item{delta}{Improvement relative to the previous component.}
}
}
\description{
Determines whether an additional component should be fitted based on
cross-validated generalization performance. For regression models
(\code{type = "R"}), the decision is based on the \eqn{Q^2} statistic.
For discriminant analysis models (\code{type = "DA"}), the decision is
based on the cross-validated AUROC (area under the ROC curve).
}
\details{
AUROC is computed on cross-validation test folds to ensure that it
reflects out-of-sample classification performance, analogous to the
use of \eqn{Q^2} in regression.
}
\keyword{internal}
