cvLassoBT {LassoBacktracking} | R Documentation |
Cross-validation for LassoBT
Description
Perform k-fold cross-validation potentially multiple times on permuted version of the data.
Usage
cvLassoBT(
x,
y,
lambda = NULL,
nlambda = 100L,
lambda.min.ratio = ifelse(nobs < nvars, 0.01, 1e-04),
nfolds = 5L,
nperms = 1L,
mc.cores = 1L,
...
)
Arguments
x |
input matrix of dimension nobs by nvars; each row is an observation vector. |
y |
response variable; shoud be a numeric vector. |
lambda |
user supplied |
nlambda |
the number of lambda values. Must be at least 3. |
lambda.min.ratio |
smallest value in |
nfolds |
number of folds. Default is 5. |
nperms |
the number of permuted datasets to apply k-folds corss-validation to. Default is 1 so we carry out vanilla cross-validation. |
mc.cores |
the number of cores to use. Only applicable when not in Windows as it uses the parallel package to parallelise the computations. |
... |
other arguments that can be passed to |
Value
A list with components as below.
lambda
the sequence of
lambda
values usedcvm
a matrix of error estimates (with squared error loss). The rows correspond to different
lambda
values whilst the columns correspond to different iterationsBT_fit
a "
BT
" object from a fit to the full data.cv_opt
a two component vector giving the cross-validation optimal
lambda
index and iterationcv_opt_err
the minimal cross-validation error.
Examples
x <- matrix(rnorm(100*250), 100, 250)
y <- x[, 1] + x[, 2] - x[, 1]*x[, 2] + x[, 3] + rnorm(100)
out <- cvLassoBT(x, y, iter_max=10, nperms=2)