coef.cv.sparsegl {sparsegl} | R Documentation |
Extract coefficients from a cv.sparsegl
object.
Description
This function etracts coefficients from a
cross-validated sparsegl()
model, using the stored "sparsegl.fit"
object, and the optimal value chosen for lambda
.
Usage
## S3 method for class 'cv.sparsegl'
coef(object, s = c("lambda.1se", "lambda.min"), ...)
Arguments
object |
Fitted |
s |
Value(s) of the penalty parameter |
... |
Not used. |
Value
The coefficients at the requested value(s) for lambda
.
See Also
cv.sparsegl()
and predict.cv.sparsegl()
.
Examples
n <- 100
p <- 20
X <- matrix(rnorm(n * p), nrow = n)
eps <- rnorm(n)
beta_star <- c(rep(5, 5), c(5, -5, 2, 0, 0), rep(-5, 5), rep(0, (p - 15)))
y <- X %*% beta_star + eps
groups <- rep(1:(p / 5), each = 5)
fit1 <- sparsegl(X, y, group = groups)
cv_fit <- cv.sparsegl(X, y, groups)
coef(cv_fit, s = c(0.02, 0.03))
[Package sparsegl version 1.1.0 Index]