Learn R Programming

lgspline (version 0.2.0)

tune_Lambda: Tune Smoothing and Ridge Penalties via Generalized Cross Validation

Description

Optimizes smoothing spline and ridge regression penalties by minimizing GCV criterion. Uses BFGS optimization with analytical gradients or finite differences.

Usage

tune_Lambda(
  y,
  X,
  X_gram,
  smoothing_spline_penalty,
  A,
  K,
  nc,
  nr,
  opt,
  use_custom_bfgs,
  C,
  colnm_expansions,
  wiggle_penalty,
  flat_ridge_penalty,
  invsoftplus_initial_wiggle,
  invsoftplus_initial_flat,
  unique_penalty_per_predictor,
  unique_penalty_per_partition,
  invsoftplus_penalty_vec,
  meta_penalty,
  family,
  unconstrained_fit_fxn,
  keep_weighted_Lambda,
  iterate,
  qp_score_function,
  quadprog,
  qp_Amat,
  qp_bvec,
  qp_meq,
  tol,
  sd_y,
  delta,
  constraint_value_vectors,
  parallel,
  parallel_eigen,
  parallel_trace,
  parallel_aga,
  parallel_matmult,
  parallel_unconstrained,
  cl,
  chunk_size,
  num_chunks,
  rem_chunks,
  shared_env,
  custom_penalty_mat,
  order_list,
  glm_weight_function,
  shur_correction_function,
  need_dispersion_for_estimation,
  dispersion_function,
  observation_weights,
  homogenous_weights,
  blockfit,
  just_linear_without_interactions,
  Vhalf,
  VhalfInv,
  verbose,
  include_warnings,
  ...
)

Value

List containing:

  • Lambda - Final combined penalty matrix

  • flat_ridge_penalty - Optimized ridge penalty

  • wiggle_penalty - Optimized smoothing penalty

  • other_penalties - Optimized predictor/partition penalties

  • L_predictor_list - Predictor-specific penalty matrices

  • L_partition_list - Partition-specific penalty matrices

Arguments

y

List; response vectors by partition

X

List; design matrices by partition

X_gram

List; Gram matrices by partition

smoothing_spline_penalty

Matrix; integrated squared second derivative penalty

A

Matrix; smoothness constraints at knots

K

Integer; number of interior knots in 1-D, number of partitions - 1 in higher dimensions

nc

Integer; columns per partition

nr

Integer; total sample size

opt

Logical; TRUE to optimize penalties, FALSE to use initial values

use_custom_bfgs

Logical; TRUE for analytic gradient BFGS as natively implemented, FALSE for finite differences as implemented by stats::optim().

wiggle_penalty, flat_ridge_penalty

Initial penalty values

invsoftplus_initial_wiggle, invsoftplus_initial_flat

Initial grid search values (log scale)

unique_penalty_per_predictor, unique_penalty_per_partition

Logical; allow predictor/partition-specific penalties

invsoftplus_penalty_vec

Initial values for predictor/partition penalties (log scale)

meta_penalty

The "meta" ridge penalty, a regularization for predictor/partition penalties to pull them on log-scale towards 0 (1 on raw scale)

family

GLM family with optional custom tuning loss

keep_weighted_Lambda, iterate

Logical controlling GLM fitting

qp_score_function, quadprog, qp_Amat, qp_bvec, qp_meq

Quadratic programming parameters (see arguments of lgspline)

tol

Numeric; convergence tolerance

sd_y, delta

Response standardization parameters

constraint_value_vectors

List; constraint values

parallel

Logical; enable parallel computation

cl, chunk_size, num_chunks, rem_chunks

Parallel computation parameters

custom_penalty_mat

Optional custom penalty matrix

order_list

List; observation ordering by partition

glm_weight_function, shur_correction_function

Functions for GLM weights and corrections

need_dispersion_for_estimation, dispersion_function

Control dispersion estimation

observation_weights

Optional observation weights

homogenous_weights

Logical; TRUE if all weights equal

blockfit

Logical; when TRUE, block-fitting (not per-partition fitting) approach is used, analogous to quadratic programming.

just_linear_without_interactions

Numeric; vector of columns of input predictor matrix that correspond to non-spline effects without interactions, used for block-fitting.

Vhalf, VhalfInv,

Square root and inverse square root correlation structures for fitting GEEs.

verbose

Logical; print progress

include_warnings

Logical; print warnings/try-errors

...

Additional arguments passed to fitting functions

Details

Uses BFGS optimization to minimize GCV criterion for penalty selection. Supports analytical gradients for efficiency with standard GLM families. Can optimize unique penalties per predictor/partition. Handles custom loss functions and GLM weights. Parallel computation available for large problems.

See Also

  • optim for Hessian-free optimization