% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tune_Lambda.R
\name{.compute_gcvu}
\alias{.compute_gcvu}
\title{Evaluate Modified GCV_u Criterion at a Given Penalty Configuration}
\usage{
.compute_gcvu(par, log_penalty_vec, env, ...)
}
\arguments{
\item{par}{Numeric vector; log-scale penalty parameters. First two elements
are log(wiggle_penalty) and log(flat_ridge_penalty). Remaining elements
(if any) are log-scale predictor/partition penalties.}

\item{log_penalty_vec}{Numeric vector; log-scale predictor/partition
penalties (passed separately for compatibility with the grid search).}

\item{env}{List; pre-computed objects and tuning configuration. Contains:
\describe{
  \item{X, y, X_gram, Xy}{Design matrices, response, Gram matrices,
    cross-products.}
  \item{A, R_constraints, K, p_expansions, N_obs}{Constraint matrix and
    dimensions.}
  \item{smoothing_spline_penalty}{Integrated second-derivative penalty
    matrix.}
  \item{custom_penalty_mat}{Optional custom penalty matrix.}
  \item{colnm_expansions}{Character vector of expansion column names.}
  \item{unique_penalty_per_predictor, unique_penalty_per_partition}{Logicals.}
  \item{family}{GLM family object.}
  \item{delta}{Pseudocount for link function stabilization.}
  \item{gcv_gamma}{Modified-GCV inflation factor applied to the
    effective-degrees-of-freedom term in the denominator.}
  \item{meta_penalty}{Meta-penalty coefficient.}
  \item{order_list}{List of observation indices per partition.}
  \item{observation_weights, homogenous_weights}{Observation weighting.}
  \item{parallel flags, cl, chunk_size, num_chunks, rem_chunks}{Parallel
    config.}
  \item{unconstrained_fit_fxn, keep_weighted_Lambda, iterate}{Fitting
    config.}
  \item{qp_score_function, quadprog, qp_Amat, qp_bvec, qp_meq}{QP config.}
  \item{tol, sd_y}{Convergence tolerance and response scale.}
  \item{constraint_value_vectors}{Constraint values.}
  \item{glm_weight_function, schur_correction_function}{GLM functions.}
  \item{need_dispersion_for_estimation, dispersion_function}{Dispersion.}
  \item{blockfit, just_linear_without_interactions}{Blockfit config.}
  \item{use_blockfit}{Logical; pre-computed dispatch flag for blockfit.}
  \item{flat_cols}{Integer vector; pre-computed flat column indices.}
  \item{Vhalf, VhalfInv}{Correlation structure matrices.}
  \item{verbose, include_warnings}{Output control.}
}}

\item{...}{Additional arguments passed to fitting functions.}
}
\value{
List containing:
\describe{
  \item{GCV_u}{Numeric; GCV_u criterion value including meta-penalty.}
  \item{B}{List; fitted coefficient vectors by partition.}
  \item{GXX}{List; \eqn{\mathbf{G}_{k} \mathbf{X}_{k}^{\top}\mathbf{X}_{k}}
    matrices.}
  \item{G_list}{List; eigendecomposition results from
    \code{compute_G_eigen}.}
  \item{mean_W}{Numeric; \eqn{\mathrm{tr}(\mathbf{H})/N}, the average
    leverage entering the denominator of \eqn{\mathrm{GCV}_u}.}
  \item{sum_W}{Numeric; \eqn{\mathrm{tr}(\mathbf{H})}, the effective
    degrees of freedom.}
  \item{Lambda}{Matrix; combined penalty matrix
    \eqn{\boldsymbol{\Lambda}}.}
  \item{L1}{Matrix; baseline smoothness penalty component.}
  \item{L2}{Matrix; baseline ridge penalty component.}
  \item{L_predictor_list}{List; predictor-specific penalty matrices.}
  \item{L_partition_list}{List; partition-specific penalty matrices.}
  \item{numerator}{Numeric; sum of squared residuals.}
  \item{denominator}{Numeric; modified-GCV denominator
    \eqn{N(1 - \gamma\bar{W})^{2}}.}
  \item{residuals}{List; residual vectors by partition.}
  \item{denom_sq}{Numeric; squared denominator.}
  \item{AGAInv}{Matrix; \eqn{(\mathbf{A}^{\top}\mathbf{G}\mathbf{A})^{-1}}.}
}
}
\description{
Computes the modified GCV_u criterion for a given set of penalty
parameters. This is the objective function minimized during penalty tuning;
\code{gcv_gamma = 1} recovers ordinary GCV.
}
\keyword{internal}
