predict.cv.ernet {SALES}R Documentation

Make predictions from a cv.ernet object

Description

This function makes predictions from a cross-validated ernet model, using the fitted cv.ernet object, and the optimal value chosen for lambda.

Usage

## S3 method for class 'cv.ernet'
predict(object, newx, s = c("lambda.1se", "lambda.min"), ...)

Arguments

object

fitted cv.ernet object.

newx

matrix of new values for x at which predictions are to be made. Must be a matrix. See documentation for predict.ernet.

s

value(s) of the penalty parameter lambda at which predictions are to be made. Default is the value s = "lambda.1se" stored on the CV object. Alternatively s = "lambda.min" can be used. If s is numeric, it is taken as the value(s) of lambda to be used.

...

not used. Other arguments to predict.

Details

This function makes it easier to use the results of cross-validation to make a prediction.

Value

The object returned depends the ... argument which is passed on to the predict method for ernet objects.

Author(s)

Yuwen Gu and Hui Zou

Maintainer: Yuwen Gu <yuwen.gu@uconn.edu>

See Also

cv.ernet, coef.cv.ernet, plot.cv.ernet

Examples


set.seed(1)
n <- 100
p <- 400
x <- matrix(rnorm(n * p), n, p)
y <- rnorm(n)
tau <- 0.90
pf <- abs(rnorm(p))
pf2 <- abs(rnorm(p))
lambda2 <- 1
m1.cv <- cv.ernet(y = y, x = x, tau = tau, eps = 1e-8, pf = pf,
                  pf2 = pf2, standardize = FALSE, intercept = FALSE,
                  lambda2 = lambda2)
as.vector(predict(m1.cv, newx = x, s = "lambda.min"))


[Package SALES version 1.0.2 Index]