Learn R Programming

hdqr (version 1.0.2)

coef.cv.nc.hdqr: Extract Coefficients from a cv.nc.hdqr Object

Description

Retrieves coefficients at specified values of lambda from a fitted cv.nc.hdqr model. Utilizes the stored nchdqr.fit object and the optimal lambda values determined during the cross-validation process.

Usage

# S3 method for cv.nc.hdqr
coef(object, s = c("lambda.1se", "lambda.min"), ...)

Value

Returns a vector or matrix of coefficients corresponding to the specified `lambda` values.

Arguments

object

A fitted cv.nc.hdqr object from which coefficients are to be extracted.

s

Specifies the lambda values at which coefficients are requested. The default is s = "lambda.1se", representing the largest lambda such that the cross-validation error estimate is within one standard error of the minimum. Alternatively, s = "lambda.min" corresponds to the lambda yielding the minimum cross-validation error. If s is numeric, these values are directly used as the lambda values for coefficient extraction.

...

Not used.

See Also

cv.nc.hdqr, predict.cv.nc.hdqr

Examples

Run this code
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=30))
cv.nc.fit <- cv.nc.hdqr(x = x, y = y, tau = tau, lambda = lambda, lam2 = lam2)
coef(cv.nc.fit, s = c(0.02, 0.03))

Run the code above in your browser using DataLab