predict.grpnet {adelie} | R Documentation |
make predictions from a "grpnet" object.
Description
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.
Usage
## 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, ...)
Arguments
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. |
Details
The shape of the objects returned are different for "multinomial"
and "multigaussian"
objects.
coef(...)
is equivalent to predict(type="coefficients",...)
Value
The object returned depends on type.
Author(s)
James Yang, Trevor Hastie, and Balasubramanian Narasimhan
Maintainer: Trevor Hastie
hastie@stanford.edu
References
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 doi:10.48550/arXiv.2405.08631.
Adelie Python user guide https://jamesyang007.github.io/adelie/
See Also
grpnet
, and print
, and coef
methods, and
cv.grpnet
.
Examples
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))