cv.hdqr {hdqr}R Documentation

Cross-validation for Selecting the Tuning Parameter in Penalized Quantile Regression

Description

Performs k-fold cross-validation for hdqr.

Usage

cv.hdqr(x, y, lambda = NULL, tau, nfolds = 5L, foldid, ...)

Arguments

x

A numerical matrix with n rows (observations) and p columns (variables).

y

Response variable.

lambda

Optional; a user-supplied sequence of lambda values. If NULL, hdqr selects its own sequence.

tau

Quantile level (tau) used in the loss function.

nfolds

Number of folds for cross-validation. Defaults to 5.

foldid

Optional vector specifying the indices of observations in each fold. If provided, it overrides nfolds.

...

Additional arguments passed to hdqr.

Details

This function computes the average cross-validation error and provides the standard error.

Value

An object with S3 class cv.hdqr consisting of

lambda

Candidate lambda values.

cvm

Mean cross-validation error.

cvsd

Standard error of the mean cross-validation error.

cvup

Upper confidence curve: cvm + cvsd.

cvlo

Lower confidence curve: cvm - cvsd.

lambda.min

lambda achieving the minimum cross-validation error.

lambda.1se

Largest lambda within one standard error of the minimum error.

cv.min

Cross-validation error at lambda.min.

cv.1se

Cross-validation error at lambda.1se.

hdqr.fit

a fitted hdqr object for the full data.

nzero

Number of non-zero coefficients at each lambda.

Examples

set.seed(315)
n <- 100
p <- 400
x <- matrix(data = rnorm(n * p, mean = 0, sd = 1), nrow = n, ncol = p)
beta_star <- c(c(2, 1.5, 0.8, 1, 1.75, 0.75, 0.3), rep(0, (p - 7)))
eps <- rnorm(n, mean = 0, sd = 1)
y <- x %*% beta_star + eps
tau <- 0.5
cv.fit <- cv.hdqr(x = x, y = y, tau = tau)

[Package hdqr version 1.0.1 Index]