1+ # #' Solving Elastic Net Regularized Quantile Regression
2+ # #'
3+ # #' @description
4+ # #' This function solves the elastic net regularized quantile regression
5+ # #' (ElasticQR) of the following form:
6+ # #' \deqn{
7+ # #' \min_{\beta}\ \frac{1}{n}\sum_{i=1}^n \rho_\kappa(y_i-x_i^T\beta_{1:d}-\beta_{d+1})+
8+ # #' \lambda_1\Vert\beta\Vert_1 + \frac{\lambda_2}{2}\Vert\beta\Vert_2^2
9+ # #' }
10+ # #' where \eqn{\rho_\kappa(u)=u\cdot(\kappa-I(u<0))} is the check loss,
11+ # #' \eqn{\beta\in\mathbb{R}^{d+1}} is a length-\eqn{(d+1)} vector,
12+ # #' \eqn{x_i\in\mathbb{R}^d} is the feature vector for the \eqn{i}-th observation,
13+ # #' \eqn{y_i\in\mathbb{R}} is the \eqn{i}-th response variable value,
14+ # #' and \eqn{\lambda_1,\lambda_2>0} are weights of lasso and ridge penalties,
15+ # #' respectively.
16+ # #'
17+ # #' @param x The data matrix \eqn{X=(x_1,\ldots,x_n)^T} of size
18+ # #' \eqn{n\times d}, representing \eqn{n} observations
19+ # #' and \eqn{d} features.
20+ # #' @param y The length-\eqn{n} response vector.
21+ # #' @param kappa Parameter of the check loss.
22+ # #' @param lam1,lam2 Weights of lasso and ridge penalties, respectively.
23+ # #' @param max_iter Maximum number of iterations.
24+ # #' @param tol Tolerance parameter for convergence test.
25+ # #' @param shrink Whether to use the shrinkage algorithm.
26+ # #' @param verbose Level of verbosity.
27+ # #'
28+ # #' @return A list of the following components:
29+ # #' \item{beta}{Optimized value of the \eqn{\beta} vector.}
30+ # #' \item{xi,Lambda,Gamma}{Values of dual variables.}
31+ # #' \item{niter}{Number of iterations used.}
32+ # #' \item{dual_objfns}{Dual objective function values during the optimization process.}
33+ # #'
34+ # #' @author Yixuan Qiu \url{https://statr.me}
35+ # #'
36+ # #' Ben Dai \url{https://bendai.org}
37+ # #'
138elasticqr = function (x , y , kappa = 0.5 , lam1 = 0.1 , lam2 = 0.1 ,
2- max_iter = 1000 , tol = 1e-5 , verbose = 0 )
39+ max_iter = 1000 , tol = 1e-5 , shrink = TRUE , verbose = 0 )
340{
441 n = nrow(x )
542 d = ncol(x )
@@ -19,6 +56,6 @@ elasticqr = function(x, y, kappa = 0.5, lam1 = 0.1, lam2 = 0.1,
1956 Vmat = rbind(Vr1 , Vr2 , Vr34 )
2057
2158 res = rehline(Xmat , Umat , Vmat , max_iter = max_iter ,
22- tol = tol , verbose = verbose )
59+ tol = tol , shrink = shrink , verbose = verbose )
2360 res $ beta
2461}
0 commit comments