Computes a number of Lasso solution paths with increasing numbers of interactions present in the design matrices corresponding to each path. Previous paths are used to speed up computation of subsequent paths so the process is very fast.
LassoBT(
x,
y,
nlambda = 100L,
iter_max = 1L,
lambda.min.ratio = ifelse(nobs < nvars, 0.01, 1e-04),
lambda = NULL,
thresh = 1e-07,
verbose = FALSE,
inter_orig
)An object with S3 class "BT".
callthe call that produced the object
a0list of intercept vectors
betalist of matrices of coefficients
stored in sparse column format (CsparseMatrix)
fittedlist of fitted values
lambdathe sequence of lambda values used
nobsthe number of observations
nvarsthe number of variables
var_indicesthe indices of the non-constant columns of the design matrix
interactionsa 2-row matrix with columns giving the interactions that were added to the design matrix
path_lookupa matrix with columns corresponding to iterations
and rows to lambda values. Entry \(ij\) gives the component of the
a0 and beta lists that gives the coefficients for the
\(i\)th lambda value and \(j\)th iteration
l_starta vector with component entries giving the minimimum
lambda index in the corresponding copmonents of beta and
a0
input matrix of dimension nobs by nvars; each row is an observation vector.
response variable; shoud be a numeric vector.
the number of lambda values. Must be at least 3.
the number of iterations of the Backtracking algorithm to
run. iter_max=1 corresponds to a single lasso or elasticnet fit.
Values greater than 1 will fit interactions.
smallest value in lambda as a fraction of the
largest value at which all main effects coefficients are 0.
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.
convergence threshold for coordinate descent. Each inner
coordinate descent loop continues until either the maximum change in the
objective after any coefficient update is less than thresh or
1E5 iterations have been performed.
if TRUE will print iteration numbers.
an optional 2-row matrix with each column giving interactions that are to be added to the design matrix before the algorithm begins.
The Lasso optimisations are performed using coordinate descent similarly to the glmnet package. An intercept term is always included. Variables are centred and scaled to have equal empirical variance. Interactions are constructed from these centred and scaled variables, and the interactions themselves are also centred and scaled. Note the coefficients are returned on the original scale of the variables. Coefficients returned for interactions are for simple pointwise products of the original variables with no scaling.
Shah, R. D. (2016) Shah, R. D. (2016) Modelling interactions in high-dimensional data with Backtracking. JMLR, 17, 1-31 https://www.jmlr.org/papers/volume17/13-515/13-515.pdf
predict.BT, coef.BT methods and the cvLassoBT
function.
x <- matrix(rnorm(100*250), 100, 250)
y <- x[, 1] + x[, 2] - x[, 1]*x[, 2] + x[, 3] + rnorm(100)
out <- LassoBT(x, y, iter_max=10)
Run the code above in your browser using DataLab