
Set Options of Constrained Ridge Regularised Weighted Least Squares Regression Solvers
Source:R/controlSolverGen.R
controlSolverGen.RdThis functions generates a list with all the required parameters for the lmRidge
solver (controlSolverGen) & allows fine control over its options.
Usage
controlSolverGen(
solver,
method = NULL,
maxit = NULL,
standardize = NULL,
reltol = NULL,
tol = NULL,
abstol = NULL,
block_size = NULL,
precond = NULL,
pivot = NULL,
ordering = NULL,
NaturalOrdering = NULL,
threshold = NULL,
verbose = FALSE,
rowaug = NULL,
nonnegative.method = NULL,
max.memory = NULL
)Arguments
- solver
XXX
- method
Solver-specific method. For
solver="eigen", the exposed methods are1L=Cholesky LLT,2L=Cholesky LDLT,3L=CG with incomplete Cholesky preconditioning by default,4L=LSCG with incomplete Cholesky preconditioning by default,5L=column-pivoted QR, and6L=BDCSVD for dense systems or Jacobi SVD for sparse systems.- maxit
The maximum number of iterations.
- standardize
Whether
bigGlmstandardizes columns of the augmented working design. Returned coefficients retain the original scale.- reltol
Relative convergence tolerance for OSQP. The default is
1e-9.- tol
Relative convergence tolerance for Eigen iterative solvers. For CG the default is
1e-10; LSCG defaults to1e-12. LSCG checks the normal-equation residual for every right-hand side by recomputing it from the returned coefficients. A solve that does not reach the requested accuracy uses the Cholesky LLT fallback.- abstol
Absolute tolerance for OSQP (default
1e-9); coordinate-update stopping threshold forbigGlm. Tall and squarebigGlmworking systems also receive a Cholesky accuracy polish with a fresh projected-gradient check; seelmRidge.- block_size
Optional block size used by solvers that support blocked updates.
- precond
For Eigen CG and LSCG (
method=3Lormethod=4L),0Lselects no preconditioning,1Ldiagonal preconditioning and2Lincomplete Cholesky (the default for both dense and sparse systems). Dense CG retains its dense matrix operator; only the incomplete Cholesky preconditioner uses a sparse copy containing every nonzero entry. For fully populated systems this factorization can cost more time and memory than diagonal preconditioning. For LSCG, incomplete Cholesky factors the normal matrix of the working least-squares design;1Luses its least-squares diagonal instead. This argument also specifies the preconditioner code for Eigen Jacobi SVD.- pivot
Optional integer pivoting code for Eigen QR and Cholesky methods. Defaults are method-specific.
- ordering
Optional integer sparse ordering code for Eigen sparse QR and Cholesky methods. For sparse QR,
0L=AMD,1L=COLAMD and2L=NaturalOrdering, with1Lthe default. Rectangular sparse QR uses COLAMD when AMD is requested. For sparse Cholesky,0L=AMD and1L=NaturalOrdering, with0Lthe default.- NaturalOrdering
Optional logical flag for Eigen sparse Cholesky ordering. If
TRUE, sparse Cholesky LLT/LDLT use Eigen'sNaturalOrdering; ifFALSE, they useAMDOrdering. The default isFALSE. The integerorderingargument takes precedence when supplied.- threshold
Optional threshold for Eigen SVD rank decisions. If
NULL, Eigen's default threshold is used.- verbose
XXX
- rowaug
Whether to append diagonal ridge-penalty rows before solving the working least-squares problem. For Eigen LLT, LDLT and CG,
NULLchooses direct Gram construction for dense designs and sparse augmentation for sparse designs, including dense-stored matrices with at least one million entries and fewer than 10 percent nonzeros. ExplicitTRUEorFALSEoverrides this choice. Existing rectangular QR, SVD and LSCG defaults are unchanged. Eligible wide Eigen systems use the Woodbury route instead.- nonnegative.method
Nonnegative working-solve strategy:
"clamp"solves without coefficient bounds and then clips to them;"constrained"enforces bounds within the weighted ridge solve.NULLpreserves solver-specific defaults:"clamp"for Eigen and"constrained"for OSQP andbigGlm. For Eigen, constrained mode uses a checked active-set Cholesky polish. LLT, LDLT and CG reuse eligible predictor Gram matrices. LSCG also corrects rectangular and wide proposals, forming a predictor Gram matrix on demand when bounds are violated. This requires room undermax.memory; an insufficient budget is an error. Other rectangular and Woodbury routes retain clamping. An unsuccessful numerical polish retains the clamped proposal. Unrestricted intercepts remain free. Unconstrained OSQP steps use infeasibility tolerances of1e-12, unless explicitly supplied in the control list.- max.memory
Optional Gram/factor workspace budget in GiB, shared across concurrent native channels.
NULLuses 25 percent of currently available physical memory;Infdisables the guard. Estimates include working copies and factors; sparse fill depends on the design. Oversized incomplete Cholesky uses diagonal preconditioning. CG/LSCG can use matrix-free ridge products; direct solves and LLT fallbacks require their estimated workspace to fit. A failed coarse sparse check is refined using the unique structural Gram entries and symbolic Cholesky fill, with allowances for work arrays and copies. The probe is itself bounded by the budget. Repeated overlaps in a banded convolution design therefore do not count as separate Gram entries. The Poisson backend also excludes zero-scaled unpenalized columns from its Woodbury Gram estimate and includes their separate Schur-complement work. Allocation checks also cover dispersion pilots and serial special-family solver adapters.
Value
The function return a list with the required options to solve a linear
weighted least squares lmRidge ridge regression using the given solver
and method.
Details
For Eigen with nonnegative.method="constrained", the polish solves the current weighted
ridge quadratic on successive feasible coefficient sets. Bounds, prior means
and column normalization are retained, including an unrestricted binomial
intercept. Batched bound updates use Cholesky on the free set; cycling or an
unsuccessful batch uses a sequential active-set solve. A fresh equilibrated
box KKT residual must be at most 1e-10, and the quadratic must not
increase relative to the clipped proposal. An unsuccessful correction keeps
that proposal. Dense and sparse Gram matrices retain their storage type.
All native channel work remains compatible with OpenMP.
LLT, LDLT and CG reuse a Gram matrix from a tall or square active working
design. LSCG retains its least-squares operator for the initial solve and,
only when needed, constructs the equivalent weighted ridge Gram system for
the constrained correction. Its allocation is checked against the workspace
budget. A feasible unconstrained proposal needs no correction. Rectangular
QR/SVD and the other observation-space Woodbury paths keep their usual solves.
This optional correction can recover
peaks lost through clipping in correlated nonnegative designs, but can also
change the selected support and increase fitting time. Eigen defaults to "clamp".
OSQP working systems are diagonally equilibrated, with bounds and starting
coefficients transformed consistently. Returned coefficients retain their
original units. Tall and square working designs also receive the same checked
constrained Cholesky polish as bigGlm; an unsuccessful polish retains
the OSQP coefficients. See lmRidge.
LSCG retains the working least-squares operator \(A\), including any ridge rows, and uses incomplete Cholesky of \(A^T A\) as its default preconditioner. Every nonzero normal-matrix entry is retained when constructing the sparse preconditioner. For already formed Gram or Woodbury systems \(G\beta=h\), this setting uses CG directly on \(G\), avoiding a second squaring of the condition number.
Before each incomplete-Cholesky LSCG solve, the previous-solution guess is compared with zero. Zero is used when \(\|A^T(b-A\beta_{\mathrm{previous}})\|_2 > \|A^T b\|_2\). This guards against poorly scaled inner guesses when adaptive ridge weights change. The public starting coefficients still determine model initialization and feature eligibility; penalties and prior means retain their specified values.
Each LSCG right-hand side is checked using the freshly computed relative normal residual \(\|A^T(b-A\beta)\|_2/\|A^T b\|_2\). If recursive convergence fails this check, incomplete-Cholesky LSCG can restart once from its returned coefficients, reusing the same factorization and the remaining iteration budget. A zero normal right-hand side passes only with a zero normal residual. Inexact or nonfinite results use the Cholesky LLT fallback. Forming the normal matrix for incomplete Cholesky can require quadratic storage for fully populated designs; diagonal preconditioning avoids that allocation in rectangular LSCG solves.
Examples
controlSolverGen(solver="osqp")
# CG uses incomplete Cholesky for both dense and sparse systems.
controlSolverGen("eigen", method=3L)
# Diagonal preconditioning is a cheaper alternative for fully dense systems.
controlSolverGen("eigen", method=3L, precond=1L)
# LSCG also defaults to incomplete Cholesky, with checked residuals and an
# LLT fallback. Select diagonal preconditioning to avoid forming its normal
# matrix for a rectangular solve.
controlSolverGen("eigen", method=4L)
controlSolverGen("eigen", method=4L, precond=1L)
# Optional constrained polish of nonnegative working ridge steps. This reuses
# an existing predictor Gram matrix and is off by default.
controlSolverGen("eigen", method=1L, nonnegative.method="constrained")
controlSolverGen("eigen", method=2L, nonnegative.method="constrained")
# LSCG forms a memory-checked predictor Gram only when a bound correction
# is needed; its initial least-squares solve and LLT fallback are retained.
controlSolverGen("eigen", method=4L, nonnegative.method="constrained")
# Compare external backends using the same clamping strategy as default Eigen.
controlSolverGen("osqp", nonnegative.method="clamp")
controlSolverGen("bigGlm", nonnegative.method="clamp")