I am looking for a quick way to do a non-negative quantile and Huber regression in R (i.e. with the restriction that all coefficients are> 0). I tried using CVXR for quantile and Huber regression and quantreg for quantile regression, but CVXR very slow and quantreg seems to be wrong when I use non-negativity constraints. Does anyone know a good and quick solution in R, for example. using the Rcplex package or the gurobi R API , thereby using the faster CPLEX or gurobi optimizers?
Note that I need to run the problem size, for example, below 80,000 times, as a result of which I need to update the vector y at each iteration, but still use the same X predictor matrix. In this sense, I consider it inefficient that in CVXR I need to do obj <- sum(quant_loss(y - X %*% beta, tau=0.01)); prob <- Problem(Minimize(obj), constraints = list(beta >= 0)) obj <- sum(quant_loss(y - X %*% beta, tau=0.01)); prob <- Problem(Minimize(obj), constraints = list(beta >= 0)) in each iteration, when the problem actually remains unchanged, and all I want to update is y . Any thoughts on making it all better / faster?
Minimal example:
#
Non-negative regression of quantiles using CVXR:
#
The syntax for Huber's non-negative regression is the same, but will use
M <- 1
Non-negative regression of quantiles using the quantreg package:
### Solve nonnegative quantile regression problem using quantreg package with method="fnc" require(quantreg) R <- rbind(diag(n),-diag(n)) r <- c(rep(0,n),-rep(1E10,n)) # specify bounds of coefficients, I want them to be nonnegative, and 1E10 should ideally be Inf system.time(beta_rq <- coef(rq(y~0+X, R=R, r=r, tau=0.5, method="fnc"))) # estimated coefficients # 0.12s cor(beta_true,beta_rq) # correlation=-0.477, no good, and even worse with tau=0.01...