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

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

View source: R/predict.glinternet.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
## S3 method for class 'glinternet'
predict(object, X, type = c("response", "link"), lambda=NULL, ...)

Arguments

object

Fitted "glinternet" model 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.

lambda

User input lambda sequence. Must be subset of the lambdas used in fitting. If NULL (the default), predict at all the lambdas used during fitting.

...

Not used. Other arguments to predict.

Details

If lambda is not specified, makes predictions at all the fitted lambda values. Users may provide their own lambda sequence, but this must be a subset of the values used to fit the models.

Value

A matrix of predicted values, with columns corresponding to each fitted model.

Author(s)

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

See Also

glinternet, glinternet.cv, predict.glinternet.cv, plot.glinternet.cv

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(X, Y, numLevels)
max(abs(fit$fitted - predict(fit, X)))

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