cv.nc.hdqr {hdqr}R Documentation

Cross-validation for Selecting the Tuning Parameter of Nonconvex Penalized Quantile Regression

Description

Conducts k-fold cross-validation for the 'nc.hdqr()' function.

Usage

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

Arguments

x

A numerical matrix with dimensions (n rows and p columns), where each row represents an observation.

y

Response variable.

lambda

Optional user-supplied sequence of lambda values.

tau

The quantile level (tau) used in the error calculation. Default value is typically 0.5 unless specified.

nfolds

Number of folds in the cross-validation, default is 5.

foldid

An optional vector that assigns each observation to a specific fold. If provided, this parameter overrides nfolds.

...

Additional arguments passed to nc.hdqr.

Details

This function estimates the average cross-validation error and its standard error across folds. It is primarily used to identify the optimal lambda value for fitting nonconvex penalized quantile regression models.

Value

An object of class cv.nc.hdqr is returned, which is a list with the ingredients of the cross-validated fit.

lambda

the values of lambda used in the fits.

cvm

the mean cross-validated error - a vector of length length(lambda).

cvsd

estimate of standard error of cvm.

cvupper

upper curve = cvm+cvsd.

cvlower

lower curve = cvm-cvsd.

nzero

number of non-zero coefficients at each lambda.

name

a text string indicating type of measure (for plotting purposes).

nchdqr.fit

a fitted nc.hdqr object for the full data.

lambda.min

The optimal value of lambda that gives minimum cross validation error cvm.

lambda.1se

The largest value of lambda such that error is within 1 standard error of the minimum.

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
lam2 <- 0.01
lambda <- 10^(seq(1,-4, length.out=10))
cv.nc.fit <- cv.nc.hdqr(y=y, x=x, tau=tau, lambda=lambda, lam2=lam2, pen="scad")

[Package hdqr version 1.0.1 Index]