Learn R Programming

biglasso (version 1.3-3)

cv.biglasso: Cross-validation for biglasso

Description

Perform k-fold cross validation for penalized regression models over a grid of values for the regularization parameter lambda.

Usage

cv.biglasso(X, y, row.idx = 1:nrow(X), eval.metric = c("default", "MAPE"), ncores = parallel::detectCores(), ..., nfolds = 5, seed, cv.ind, trace = FALSE)

Arguments

X
The design matrix, without an intercept, as in biglasso.
y
The response vector, as in biglasso.
row.idx
The integer vector of row indices of X that used for fitting the model. as in biglasso.
eval.metric
The evaluation metric for the cross-validated error and for choosing optimal lambda. "default" for linear regression is MSE (mean squared error), for logistic regression is misclassification error. "MAPE", for linear regression only, is the Mean Absolute Percentage Error.
ncores
The number of cores to use for parallel execution across a cluster created by the parallel package. (This is different from ncores in biglasso, which is the number of OpenMP threads.)
...
Additional arguments to biglasso.
nfolds
The number of cross-validation folds. Default is 5.
seed
The seed of the random number generator in order to obtain reproducible results.
cv.ind
Which fold each observation belongs to. By default the observations are randomly assigned by cv.biglasso.
trace
If set to TRUE, cv.biglasso will inform the user of its progress by announcing the beginning of each CV fold. Default is FALSE.

Value

An object with S3 class "cv.biglasso" which inherits from class "cv.ncvreg". The following variables are contained in the class (adopted from cv.ncvreg).

Details

The function calls biglasso nfolds times, each time leaving out 1/nfolds of the data. The cross-validation error is based on the residual sum of squares when family="gaussian" and the binomial deviance when family="binomial". The S3 class object cv.biglasso inherits class cv.ncvreg. So S3 functions such as "summary", "plot" can be directly applied to the cv.biglasso object.

See Also

biglasso, plot.cv.biglasso, summary.cv.biglasso, setupX

Examples

Run this code
## cv.biglasso
data(colon)
X <- colon$X
y <- colon$y
X.bm <- as.big.matrix(X)

## logistic regression
cvfit <- cv.biglasso(X.bm, y, family = 'binomial', seed = 1234, ncores = 2)
par(mfrow = c(2, 2))
plot(cvfit, type = 'all')
summary(cvfit)

Run the code above in your browser using DataLab