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

View source: R/tools.R

predict.cv.gglassoR Documentation

make predictions from a "cv.gglasso" object.

Description

This function makes predictions from a cross-validated gglasso model, using the stored "gglasso.fit" object, and the optimal value chosen for lambda.

Usage

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

Arguments

object

fitted cv.gglasso object.

newx

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

s

value(s) of the penalty parameter lambda at which predictions are required. 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 returned object depends on the ... argument which is passed on to the predict method for gglasso objects.

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

cv.gglasso, and coef.cv.gglasso methods.

Examples


# load gglasso library
library(gglasso)

# load data set
data(colon)

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

# 5-fold cross validation using group lasso 
# penalized logisitic regression
cv <- cv.gglasso(x=colon$x, y=colon$y, group=group, loss="logit",
pred.loss="misclass", lambda.factor=0.05, nfolds=5)

# the coefficients at lambda = lambda.min, newx = x[1,]
pre = predict(cv$gglasso.fit, newx = colon$x[1:10,], 
s = cv$lambda.min, type = "class")

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