predict.glinternet.cv: Make predictions from a "glinternetCV" object.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/predict.glinternet.cv.r

Description

Similar to other predict methods, this function returns fitted values on the response scale. Also gives the option to return the link function.

Usage

1
2
3
## S3 method for class 'glinternet.cv'
predict(object, X, type = c("response", "link"),
lambdaType=c("lambdaHat", "lambdaHat1Std"), ...)

Arguments

object

"glinternetCV" object.

X

Matrix of new values for which to make predictions. Must have the same number of variables as during training the model, and all the variables must have the same number of levels.

type

Return fitted Y values or the link function.

lambdaType

lambdaHat corresponds to the lambda value that gives the minimum CV error. lambdaHat1Std picks the largest value of lambda for which the CV error is within 1 standard error of the minimum.

...

Not used.

Details

Makes predictions using the model fitted at the appropriate lambda value.

Value

A vector of predicted values.

Author(s)

Michael Lim and Trevor Hastie
Maintainer: Michael Lim michael626@gmail.com

See Also

glinternet, glinternet.cv, predict.glinternet

Examples

1
2
3
4
5
6
Y = rnorm(100)
numLevels = sample(1:5, 10, replace=TRUE)
X = sapply(numLevels, function(x) if (x==1)
rnorm(100) else sample(0:(x-1), 100, replace=TRUE))
fit = glinternet.cv(X, Y, numLevels, nFolds=3)
max(abs(fit$fitted - predict(fit, X)))

Example output

Loaded glinternet 1.0.8

[1] 0

glinternet documentation built on Sept. 5, 2021, 5:28 p.m.