predict.gglasso: make predictions from a "gglasso" object.

View source: R/tools.R

predict.gglassoR Documentation

make predictions from a "gglasso" object.

Description

Similar to other predict methods, this functions predicts fitted values and class labels from a fitted gglasso object.

Usage

## S3 method for class 'gglasso'
predict(object, newx, s = NULL, type = c("class", "link"), ...)

Arguments

object

fitted gglasso model object.

newx

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

s

value(s) of the penalty parameter lambda at which predictions are required. Default is the entire sequence used to create the model.

type

type of prediction required:

  • Type "link", for regression it returns the fitted response; for classification it gives the linear predictors.

  • Type "class", only valid for classification, it produces the predicted class label corresponding to the maximum probability.

...

Not used. Other arguments to predict.

Details

s is the new vector at which predictions are requested. If s is not in the lambda sequence used for fitting the model, the predict function will use linear interpolation to make predictions. The new values are interpolated using a fraction of predicted values from both left and right lambda indices.

Value

The object returned depends on type.

Author(s)

Yi Yang and Hui Zou
Maintainer: Yi Yang <yi.yang6@mcgill.ca>

References

Yang, Y. and Zou, H. (2015), “A Fast Unified Algorithm for Computing Group-Lasso Penalized Learning Problems,” Statistics and Computing. 25(6), 1129-1141.
BugReport: https://github.com/emeryyi/gglasso

See Also

coef method

Examples


# load gglasso library
library(gglasso)

# load data set
data(colon)

# define group index
group <- rep(1:20,each=5)

# fit group lasso
m1 <- gglasso(x=colon$x,y=colon$y,group=group,loss="logit")

# predicted class label at x[10,]
print(predict(m1,type="class",newx=colon$x[10,]))

# predicted linear predictors at x[1:5,]
print(predict(m1,type="link",newx=colon$x[1:5,]))


gglasso documentation built on May 29, 2024, 2:38 a.m.