\name{combss_cv}
\alias{combss_cv}
\title{Select the ridge penalty for COMBSS by leave-one-out cross-validation.}
\usage{
combss_cv(
  x,
  y,
  family = c("gaussian", "binomial", "multinomial"),
  q,
  lambda_grid = NULL,
  Niter = 25,
  verbose = FALSE
)
}
\arguments{
\item{x}{Numeric design matrix \verb{(n, p)}.}

\item{y}{Response (numeric / binary / factor depending on \code{family}).}

\item{family}{One of \code{"gaussian"} (alias \code{"linear"}), \code{"binomial"},
\code{"multinomial"}.}

\item{q}{Maximum subset size.}

\item{lambda_grid}{Candidate ridge penalties. Defaults to
\code{c(0, 10^seq(-3, 1, length.out = 10))}.}

\item{Niter}{Number of homotopy iterations passed to \code{combss()}.}

\item{verbose}{Print progress.}
}
\value{
List with:
\itemize{
\item \code{best_lambda}: ridge penalty with best mean LOOCV metric across \code{k}
\item \code{best_lambda_per_k}: numeric vector, length \code{q}
\item \code{results}: data frame \verb{(lambda, k, loocv_metric)}
}
}
\description{
Mirrors \code{combss.cv.select_lambda} in the Python \code{combss} package. For each
candidate \code{lambda} and each subset size \verb{k = 1, ..., q}, runs COMBSS to
obtain a subset and evaluates LOOCV error of a refit. Returns the best
\code{lambda} overall and the best \code{lambda} per \code{k}.
}
