| Title: | Ridge Selection Operator for Sparse Linear Regression |
|---|---|
| Description: | Implements the Ridge Selection Operator (RSO) for variable selection in linear regression as proposed by Wu (2021) <doi:10.1080/00401706.2020.1791254>. The RSO method extends classical ridge regression by using individually penalized ridge parameters, inducing sparsity through reciprocal penalty parameters. This package provides a fast C++ implementation ('RSOFast') using 'Armadillo' linear algebra routines. The fast implementation precomputes matrix products, uses Cholesky factorization with primal/dual switching, and performs golden-section search for coordinate optimization. |
| Authors: | Murat Genc [aut, cre], Adewale Lukman [aut] |
| Maintainer: | Murat Genc <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.0 |
| Built: | 2026-07-06 16:24:42 UTC |
| Source: | https://github.com/cran/RSO |
Computes the sum of squared residuals (SSR) for individually penalized ridge regression without explicitly forming the hat matrix. Uses Cholesky decomposition for speed and numerical stability.
ridgereg(x, y, gam, penalty.factor = rep(1, length(gam)))ridgereg(x, y, gam, penalty.factor = rep(1, length(gam)))
x |
Centered predictor matrix (n x p) |
y |
Centered response vector (n x 1) |
gam |
Ridge penalty parameters vector (p x 1) where gam_j = 1/nu_j |
penalty.factor |
Adaptive penalty factors (p x 1), default = 1 for RSO |
Sum of squared residuals (SSR)
n <- 100; p <- 10 x <- matrix(rnorm(n*p), n, p) x <- scale(x, scale = FALSE) y <- rnorm(n) y <- y - mean(y) gam <- runif(p) result <- ridgereg(x, y, gam, rep(1, p))n <- 100; p <- 10 x <- matrix(rnorm(n*p), n, p) x <- scale(x, scale = FALSE) y <- rnorm(n) y <- y - mean(y) gam <- runif(p) result <- ridgereg(x, y, gam, rep(1, p))
Computes the sum of squared residuals (SSR), degrees of freedom (trace of hat matrix), and coefficient estimates for ridge regression. Uses Cholesky decomposition for speed and numerical stability.
ridgereg_df(x, y, gam, penalty.factor = rep(1, length(gam)))ridgereg_df(x, y, gam, penalty.factor = rep(1, length(gam)))
x |
Centered predictor matrix (n x p) |
y |
Centered response vector (n x 1) |
gam |
Ridge penalty parameters vector (p x 1) where gam_j = 1/nu_j |
penalty.factor |
Adaptive penalty factors (p x 1), default = 1 for RSO |
A list containing:
ssr |
Sum of squared residuals |
df |
Degrees of freedom (trace of hat matrix) |
coef |
Coefficient estimates (p x 1) |
n <- 100; p <- 10 x <- matrix(rnorm(n*p), n, p) x <- scale(x, scale = FALSE) y <- rnorm(n) y <- y - mean(y) gam <- runif(p) result <- ridgereg_df(x, y, gam, rep(1, p))n <- 100; p <- 10 x <- matrix(rnorm(n*p), n, p) x <- scale(x, scale = FALSE) y <- rnorm(n) y <- y - mean(y) gam <- runif(p) result <- ridgereg_df(x, y, gam, rep(1, p))
Computes the sum of squared residuals (SSR) for individually penalized ridge regression using precomputed X'X and X'y matrices. This is optimized for repeated calls with the same x matrix but different gam parameters (e.g., during grid search).
ridgeRegPrecomp(x, y, gam, penalty.factor = rep(1, length(gam)), precomp)ridgeRegPrecomp(x, y, gam, penalty.factor = rep(1, length(gam)), precomp)
x |
Centered predictor matrix (n x p) |
y |
Centered response vector (n x 1) |
gam |
Ridge penalty parameters vector (p x 1) where gam_j = 1/nu_j |
penalty.factor |
Adaptive penalty factors (p x 1), default = 1 for RSO |
precomp |
List containing precomputed values:
|
Sum of squared residuals (SSR)
n <- 100; p <- 10 x <- matrix(rnorm(n*p), n, p) x <- scale(x, scale = FALSE) y <- rnorm(n) y <- y - mean(y) precomp <- list(xtx = crossprod(x), xty = crossprod(x,y)) gam <- runif(p) result <- ridgeRegPrecomp(x, y, gam, rep(1, p), precomp)n <- 100; p <- 10 x <- matrix(rnorm(n*p), n, p) x <- scale(x, scale = FALSE) y <- rnorm(n) y <- y - mean(y) precomp <- list(xtx = crossprod(x), xty = crossprod(x,y)) gam <- runif(p) result <- ridgeRegPrecomp(x, y, gam, rep(1, p), precomp)
Implements the modified coordinate descent algorithm for RSO as described in Wu (2021). Solves for optimal lambda parameters that minimize SSR subject to sum(lambda) = tau and lambda >= 0.
RSOFast(x, y, tau, penalty.factor = rep(1, ncol(x)), gaminit = NULL)RSOFast(x, y, tau, penalty.factor = rep(1, ncol(x)), gaminit = NULL)
x |
Centered predictor matrix (n x p) |
y |
Centered response vector (n x 1) |
tau |
Regularization parameter (sum of lambda) |
penalty.factor |
Adaptive penalty factors (p x 1), default = 1 for RSO |
gaminit |
Initial lambda values. If NULL, uses tau/p for all. |
A list containing:
gamma |
Optimal lambda vector (p x 1) |
lambda |
Alias for gamma |
coefficients |
Coefficient estimates (p x 1) |
coef |
Alias for coefficients |
df |
Degrees of freedom |
ssr |
Sum of squared residuals |
iterations |
Number of iterations |
converged |
Convergence status |
n_selected |
Number of selected variables |
tau |
Original tau parameter |
Wu, Y. (2021). Can't ridge regression perform variable selection?. Technometrics, 63(2), 263-271. doi:10.1080/00401706.2020.1791254
n <- 100; p <- 10 x <- matrix(rnorm(n*p), n, p) x <- scale(x, scale = FALSE) y <- rnorm(n) y <- y - mean(y) result <- RSOFast(x, y, tau = 1.0, rep(1, p))n <- 100; p <- 10 x <- matrix(rnorm(n*p), n, p) x <- scale(x, scale = FALSE) y <- rnorm(n) y <- y - mean(y) result <- RSOFast(x, y, tau = 1.0, rep(1, p))