cvLassoBT: Cross-validation for 'LassoBT'

View source: R/cvBT.R

cvLassoBTR 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 lambda sequence of decreasing penalty parameters. Typical usage is to allow the function to compute its own lambda sequence. Inappropriate sequences may cause convergence problems.

nlambda

the number of lambda values. Must be at least 3.

lambda.min.ratio

smallest value in lambda as a fraction of the largest value at which all main effects coefficients are 0.

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 LassoBT.

Value

A list with components as below.

lambda

the sequence of lambda values used

cvm

a matrix of error estimates (with squared error loss). The rows correspond to different lambda values whilst the columns correspond to different iterations

BT_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 iteration

cv_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)

LassoBacktracking documentation built on Dec. 8, 2022, 5:12 p.m.