| 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.
lambdathe sequence of
lambdavalues usedcvma matrix of error estimates (with squared error loss). The rows correspond to different
lambdavalues whilst the columns correspond to different iterationsBT_fita "
BT" object from a fit to the full data.cv_opta two component vector giving the cross-validation optimal
lambdaindex and iterationcv_opt_errthe 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)