Learn R Programming

glinternet (version 0.9.0)

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

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

## 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.

Value

  • A vector of predicted values.

Details

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

See Also

glinternet, glinternet.cv, predict.glinternet

Examples

Run this code
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)))

Run the code above in your browser using DataLab