View source: R/predict.cv.glmnet.R
predict.cv.glmnet | R Documentation |
This function makes predictions from a cross-validated glmnet model, using
the stored "glmnet.fit"
object, and the optimal value chosen for
lambda
(and gamma
for a 'relaxed' fit.
## S3 method for class 'cv.glmnet'
predict(object, newx, s = c("lambda.1se", "lambda.min"), ...)
## S3 method for class 'cv.relaxed'
predict(
object,
newx,
s = c("lambda.1se", "lambda.min"),
gamma = c("gamma.1se", "gamma.min"),
...
)
object |
Fitted |
newx |
Matrix of new values for |
s |
Value(s) of the penalty parameter |
... |
Not used. Other arguments to predict. |
gamma |
Value (single) of 'gamma' at which predictions are to be made |
This function makes it easier to use the results of cross-validation to make a prediction.
The object returned depends on the ... argument which is passed
on to the predict
method for glmnet
objects.
Jerome Friedman, Trevor Hastie and Rob Tibshirani
Maintainer:
Trevor Hastie hastie@stanford.edu
Friedman, J., Hastie, T. and Tibshirani, R. (2008)
Regularization Paths for Generalized Linear Models via Coordinate
Descent (2010), Journal of Statistical Software, Vol. 33(1), 1-22,
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v033.i01")}.
Simon, N., Friedman, J., Hastie, T. and Tibshirani, R. (2011)
Regularization Paths for Cox's Proportional
Hazards Model via Coordinate Descent, Journal of Statistical Software, Vol.
39(5), 1-13,
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v039.i05")}.
Hastie, T., Tibshirani, Robert and Tibshirani, Ryan (2020) Best Subset,
Forward Stepwise or Lasso? Analysis and Recommendations Based on Extensive Comparisons,
Statist. Sc. Vol. 35(4), 579-592,
https://arxiv.org/abs/1707.08692.
Glmnet webpage with four vignettes, https://glmnet.stanford.edu.
glmnet
, and print
, and coef
methods, and
cv.glmnet
.
x = matrix(rnorm(100 * 20), 100, 20)
y = rnorm(100)
cv.fit = cv.glmnet(x, y)
predict(cv.fit, newx = x[1:5, ])
coef(cv.fit)
coef(cv.fit, s = "lambda.min")
predict(cv.fit, newx = x[1:5, ], s = c(0.001, 0.002))
cv.fitr = cv.glmnet(x, y, relax = TRUE)
predict(cv.fit, newx = x[1:5, ])
coef(cv.fit)
coef(cv.fit, s = "lambda.min", gamma = "gamma.min")
predict(cv.fit, newx = x[1:5, ], s = c(0.001, 0.002), gamma = "gamma.min")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.