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 |
y |
Response variable. |
lambda |
Optional; a user-supplied sequence of |
tau |
Quantile level ( |
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 |
... |
Additional arguments passed to |
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 |
cvm |
Mean cross-validation error. |
cvsd |
Standard error of the mean cross-validation error. |
cvup |
Upper confidence curve: |
cvlo |
Lower confidence curve: |
lambda.min |
|
lambda.1se |
Largest |
cv.min |
Cross-validation error at |
cv.1se |
Cross-validation error at |
hdqr.fit |
a fitted |
nzero |
Number of non-zero coefficients at each |
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)