% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/QC.R
\name{computeLambda}
\alias{computeLambda}
\title{computeLambda}
\usage{
computeLambda(trainDF, modelFormula)
}
\arguments{
\item{trainDF}{`data.frame`
A data frame for QS model training that must include:
  Predictor columns: All columns referenced in the formula returned by `getModelFormula()`.
  `QScore_train` or historical `qcscore_train`, containing the binary
  (0/1) response to be modeled.}

\item{modelFormula}{A one-sided formula or character string describing the
supported predictor terms.}
}
\value{
`numeric`
  The value of \eqn{\lambda} (i.e., `lambda.min`) from
  `cv.glmnet` that minimizes the cross-validation error.
}
\description{
Computes optimal ridge regularization parameter \eqn{\lambda} via
k-fold cross-validation.

\code{computeLambda} performs ridge (L2) logistic regression with
k-fold cross-validation to identify the optimal regularization parameter
\eqn{\lambda} for Quality Score (QS) model training.
}
\details{
Complete cases for the formula variables and response are retained. The
function constructs a model matrix and passes it to an internal
matrix-based implementation that runs ridge logistic-regression
cross-validation using `cv.glmnet` with `alpha = 0`.
}
\examples{
example(computeTrainDF)
modform <- getModelFormula(names(metadata(spe)$formula_variables))
best_lambda <- computeLambda(df_train, modform)
print(best_lambda)


}
