The current fit functions for models using the rqPen package ("rqlasso" and "rqnc" are using the rqPen 3.0 fitting method:
# From rqlasso.R
fit = function(x, y, wts, param, lev, last, classProbs, ...) {
rqPen::rq.lasso.fit(as.matrix(x), y, lambda = param$lambda, ...)
}
# From rqnc.R
fit = function(x, y, wts, param, lev, last, classProbs, ...) {
rqPen::rq.nc.fit(as.matrix(x), y,
lambda = param$lambda,
penalty = as.character(param$penalty), ...)
}
(From rqPen NEWS, 2023-02-20):
Older functions that were deprecated in rqPen 3.0 are no longer exported. Big changes are rq.pen() should be used instead of rq.lasso.fit() or rq.nc.fit(). Similarly rq.group.pen() should be used instead of rq.group.fit(). Finally rq.pen.cv() and rq.group.pen.cv() should be used instead of cv.rq.pen() and cv.rq.group.pen().
Reproducible Example:
set.seed(123) # for reproducibility
# Create data
n <- 100 # number of observations
p <- 5 # number of predictors
# Generate predictors
X <- matrix(rnorm(n*p), n, p)
colnames(X) <- paste0("X", 1:p)
# Generate response variable
beta <- rnorm(p)
y <- X %*% beta + rnorm(n)
# Combine predictors and response into a data.frame
df <- data.frame(y = y, X)
# Fit using quantile regression with LASSO regularization
fit <- caret::train(
y ~ .,
data = df,
method = "rqlasso", # Also "rqnc", which also uses `rqPen::rq.pen`
trControl = caret::trainControl(method="cv", number=5),
preProcess = c("center", "scale"),
metric = "RMSE"
)
## 1: `rq.lasso.fit()` was deprecated in rqPen 3.0.
## ℹ Please use `rq.pen()` instead.
Either install an older version of rqPen (i.e., devtools::install_version("rqPen", version = "3.0.1", repos = "http://cran.us.r-project.org")), or else update rqPen::rq.lasso.fit() and rqPen::rq.nc.fit() to rqPen::rq.pen():
fit = function(x, y, wts, param, lev, last, classProbs, ...) {
rqPen::rq.pen(as.matrix(x), y, lambda = param$lambda, ...)
}
Error sources:
Error description:
The current
fit
functions for models using therqPen
package ("rqlasso" and "rqnc" are using therqPen
3.0 fitting method:(From
rqPen
NEWS, 2023-02-20): Older functions that were deprecated inrqPen
3.0 are no longer exported. Big changes arerq.pen()
should be used instead ofrq.lasso.fit()
orrq.nc.fit()
. Similarlyrq.group.pen()
should be used instead ofrq.group.fit()
. Finallyrq.pen.cv()
andrq.group.pen.cv()
should be used instead ofcv.rq.pen()
andcv.rq.group.pen()
.Reproducible Example:
Solution
Either install an older version of
rqPen
(i.e.,devtools::install_version("rqPen", version = "3.0.1", repos = "http://cran.us.r-project.org")
), or else updaterqPen::rq.lasso.fit()
andrqPen::rq.nc.fit()
torqPen::rq.pen()
: