Run cross-validation for the quantile generalized lasso on a tau by lambda grid. For each tau, the lambda value minimizing the cross-validation error is reported.

cv_quantile_genlasso(
  x,
  y,
  d,
  tau,
  lambda = NULL,
  nlambda = 30,
  lambda_min_ratio = 0.001,
  weights = NULL,
  nfolds = 5,
  train_test_inds = NULL,
  intercept = TRUE,
  standardize = TRUE,
  lb = -Inf,
  ub = Inf,
  noncross = FALSE,
  x0 = NULL,
  lp_solver = c("glpk", "gurobi"),
  time_limit = NULL,
  warm_starts = TRUE,
  params = list(),
  transform = NULL,
  inv_trans = NULL,
  jitter = NULL,
  verbose = FALSE,
  sort = FALSE,
  iso = FALSE,
  nonneg = FALSE,
  round = FALSE
)

Arguments

nfolds

Number of cross-validation folds. Default is 5.

train_test_inds

List of length two, with components named train and test. Each of train and test are themselves lists, of the same length; for each i, we will consider train[[i]] the indices (which index the rows of x and elements of y) to use for training, and test[[i]] as the indices to use for testing (validation). The validation error will then be summed up over all i. This allows for fine control of the "cross-validation" process (in quotes, because there need not be any crossing going on here). Default is NULL; if specified, takes priority over nfolds.

Value

A list with the following components:

qgl_obj

A quantile_genlasso object obtained by fitting on the full training set, at all quantile levels and their corresponding optimal lambda values

cv_mat

Matrix of cross-validation errors (as measured by quantile loss), of dimension (number of tuning parameter values) x (number of quantile levels)

lambda_min

Vector of optimum lambda values, one per quantile level

tau,lambda

Vectors of tau and lambda values used

Details

All arguments through verbose (except for nfolds and train_test_inds) are as in quantile_genlasso_grid and quantile_genlasso. Note that the noncross and x0 arguments are not passed to quantile_genlasso_grid for the calculation of cross-validation errors and optimal lambda values; they are only passed to quantile_genlasso for the final object that is fit to the full training set. Past verbose, the arguments are as in predict.quantile_genlasso, and control what happens with the predictions made on the validation sets.