Learn R Programming

hqreg (version 1.2)

hqreg-package: Regularization Paths for Huber Loss Regression and Quantile Regression Penalized by Lasso or Elastic-net

Description

Efficient algorithms for fitting coefficient paths for regression models with Huber loss, quantile loss or squared loss penalized by lasso or elastic-net.

Arguments

Details

ll{ Package: hqreg Type: Package Version: 0.9 Date: 2015-06-18 License: GPL-2 } Very simple to use. Accepts X,y data for regression models, and produces the regularization path over a grid of values for the tuning parameter lambda. Also provides methods for plotting, prediction and cross-validation.

Examples

Run this code
X = matrix(rnorm(1000*100), 1000, 100)
beta = rnorm(10)
eps = 4*rnorm(1000)
y = drop(X[,1:10] %*% beta + eps) 

# Huber loss
fit1 = hqreg(X, y)
coef(fit1, 0.01)
predict(fit1, X[1:5,], lambda = c(0.02, 0.01))

# Quantile loss
fit2 = hqreg(X, y, method = "quantile", tau = 0.2)
plot(fit2, xvar = "norm")

# Squared loss
fit3 = hqreg(X, y, method = "ls", preprocess = "rescale")
plot(fit3, xvar = "lambda", log.x = TRUE)

Run the code above in your browser using DataLab