% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/penalization.R, R/penalty-glmnet.R,
%   R/penalty-ncvreg.R, R/penalty-rq.R, R/penalty-sar.R
\name{penalization}
\alias{penalization}
\alias{pen_glmnet}
\alias{pen_ncvreg}
\alias{pen_rq}
\alias{pen_sar}
\title{Penalized Methods for Feature Selection}
\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{
\item{x}{Feature matrix}

\item{y}{Response vector.}

\item{family}{"gaussian", "binomial", or "cox".}

\item{penalty}{"lasso", "SCAD" or "MCP".}

\item{tau}{Quantiles to be modeled.}

\item{rho}{Spatial autoregressive parameter. If missing or NULL, it will be estimated.}

\item{w}{Weight matrix (row-sum scaled being one).}
}
\value{
Set of selected features.
}
\description{
Penalized methods for feature selection.
These functions are only designed for comparison of numerical simulations.

\itemize{
\item \code{pen_glmnet(x, y, family)}: LASSO penalized models.
}

\itemize{
\item \code{pen_ncvreg(x, y, family, penalty)}: Non-Convex penalized models.
}

\itemize{
\item \code{pen_rq(x, y, tau, penalty)}: penalized quantile regression models.
}

\itemize{
\item \code{pen_sar(x, y, rho, w, penalty)}: penalized spatial auto-regressive models.
}
}
\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()

}
