penalization: Penalized Methods for Feature Selection

penalizationR Documentation

Penalized Methods for Feature Selection

Description

Penalized methods for feature selection. These functions are only designed for comparison of numerical simulations.

  • pen_glmnet(x, y, family): LASSO penalized models.

  • pen_ncvreg(x, y, family, penalty): Non-Convex penalized models.

  • pen_rq(x, y, tau, penalty): penalized quantile regression models.

  • pen_sar(x, y, rho, w, penalty): penalized spatial auto-regressive models.

Usage

pen_glmnet(x, y, family)

pen_ncvreg(x, y, family, penalty)

pen_rq(x, y, tau, penalty)

pen_sar(x, y, rho, w, penalty)

Arguments

x

Feature matrix

y

Response vector.

family

"gaussian", "binomial", or "cox".

penalty

"lasso", "SCAD" or "MCP".

tau

Quantiles to be modeled.

rho

Spatial autoregressive parameter. If missing or NULL, it will be estimated.

w

Weight matrix (row-sum scaled being one).

Value

Set of selected features.

Examples

library(survival)
set.seed(2026)
n <- 10
p <- 20

x <- replicate(p, rnorm(n))
b0 <- runif(3, 1.5, 2.0)
eta <- drop(x[, 1:3] %*% b0)

## ---------- linear ----------
y <- rnorm(n, eta)

pen_glmnet(x=x, y=y, family="gaussian") |> coef()
pen_ncvreg(x=x, y=y, family="gaussian", penalty="MCP") |> coef()
pen_ncvreg(x=x, y=y, family="gaussian", penalty="SCAD") |> coef()


## ---------- logistic ----------
y <- rbinom(n, 1, 1.0 / (1.0 + exp(-eta)))

pen_glmnet(x=x, y=y, family="binomial") |> coef()
pen_ncvreg(x=x, y=y, family="binomial", penalty="MCP") |> coef()
pen_ncvreg(x=x, y=y, family="binomial", penalty="SCAD") |> coef()


## ---------- cox ----------
h0 <- 0.01
censoringRate <- 0.3
survivalTime <- -log(runif(n)) / (h0 * exp(eta))
censoringTime <- rexp(n, rate = -log(1 - censoringRate)/median(survivalTime))
y <- cbind(
    time = pmin(survivalTime, censoringTime),
    status = as.numeric(survivalTime <= censoringTime)
)

pen_glmnet(x=x, y=y, family="cox") |> coef()
pen_ncvreg(x=x, y=y, family="cox", penalty="MCP") |> coef()
pen_ncvreg(x=x, y=y, family="cox", penalty="SCAD") |> coef()


## ---------- quantile ----------
y <- eta + rt(n, 2)

pen_rq(x=x, y=y, tau=0.5, penalty="lasso") |> coef()
pen_rq(x=x, y=y, tau=0.5, penalty="MCP") |> coef()
pen_rq(x=x, y=y, tau=0.5, penalty="SCAD") |> coef()


## ---------- sar ----------
w0 <- set_rook_matrix(5, n/5)
rho0 <- 0.5
y <- solve(diag(n) - rho0 * w0, rnorm(n, eta))

pen_sar(x=x, y=y, rho=rho0, w=w0, penalty="lasso") |> coef()
pen_sar(x=x, y=y, rho=rho0, w=w0, penalty="MCP") |> coef()
pen_sar(x=x, y=y, rho=rho0, w=w0, penalty="SCAD") |> coef()


pboost documentation built on May 24, 2026, 9:08 a.m.