predict.grpnet | R Documentation |
Similar to other predict methods, this functions predicts linear predictors,
coefficients and more from a fitted "grpnet"
object. Note that if the default standardize=TRUEE
was used in fitting the grpnet
object, the coefficients reported are for the standardized inputs.
However, the predict
function will apply the stored standardization to newx
and give the correct predictions.
## S3 method for class 'grpnet'
predict(
object,
newx,
lambda = NULL,
type = c("link", "response", "coefficients", "nonzero"),
newoffsets = NULL,
n_threads = 1,
...
)
## S3 method for class 'grpnet'
coef(object, lambda = NULL, ...)
object |
Fitted |
newx |
Matrix of new values for |
lambda |
Value(s) of the penalty parameter |
type |
Type of prediction required. Type |
newoffsets |
If an offset is used in the fit, then one must be supplied
for making predictions (except for |
n_threads |
Number of threads, default |
... |
Currently ignored. |
The shape of the objects returned are different for "multinomial"
and "multigaussian"
objects.
coef(...)
is equivalent to predict(type="coefficients",...)
The object returned depends on type.
James Yang, Trevor Hastie, and Balasubramanian Narasimhan
Maintainer: Trevor Hastie
hastie@stanford.edu
Yang, James and Hastie, Trevor. (2024) A Fast and Scalable Pathwise-Solver for Group Lasso
and Elastic Net Penalized Regression via Block-Coordinate Descent. arXiv \Sexpr[results=rd]{tools:::Rd_expr_doi("10.48550/arXiv.2405.08631")}.
Adelie Python user guide https://jamesyang007.github.io/adelie/
grpnet
, and print
, and coef
methods, and
cv.grpnet
.
set.seed(0)
n <- 100
p <- 200
X <- matrix(rnorm(n * p), n, p)
y <- X[,1] * rnorm(1) + rnorm(n)
groups <- c(1, sample(2:199, 60, replace = FALSE))
groups <- sort(groups)
fit <- grpnet(X, glm.gaussian(y), groups = groups)
coef(fit)
predict(fit,newx = X[1:5,], lambda = c(0.1, 0.05))
predict(fit, type="nonzero", lambda = c(0.1, 0.05))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.