lasso.c {PACLasso}R Documentation

Complete Run of Constrained LASSO Path Function (Equality Constraints)

Description

This is a wrapper function for the lars.c PaC constrained Lasso function. lasso.c controls the overall path, providing checks for the path and allowing the user to control how the path is computed (and what to do in the case of a stopped path).

Usage

lasso.c(x, y, C.full, b, l.min = -2, l.max = 6, step = 0.2,
  beta0 = NULL, verbose = F, max.it = 12, intercept = T,
  normalize = T, backwards = F)

Arguments

x

independent variable matrix of data to be used in calculating PaC coefficient paths

y

response vector of data to be used in calculating PaC coefficient paths

C.full

complete constraint matrix C (with constraints of the form C.full*beta=b)

b

constraint vector b

l.min

lowest value of lambda to consider (used as 10^l.min). Default is -2

l.max

largest value of lambda to consider (used as 10^l.max). Default is 6

step

step size increase in lambda attempted at each iteration (by a factor of 10^step). Default is 0.2

beta0

initial guess for beta coefficient vector. Default is NULL (indicating initial vector should be calculated by algorithm)

verbose

should function print output at each iteration (TRUE) or not (FALSE). Default is FALSE

max.it

maximum number of times step size is halved before the algorithm terminates and gives a warning. Default is 12

intercept

should intercept be included in modeling (TRUE) or not (FALSE). Default is TRUE.

normalize

should X data be normalized. Default is TRUE

backwards

which direction should algorithm go, backwards from lambda = 10^l.max (TRUE) or forwards from 10^l.max and then backwards if algorithm gets stuck (FALSE). Default is FALSE.

Value

coefs A p by length(lambda) matrix with each column corresponding to the beta estimate for that lambda

lambda vector of values of lambda that were fit

intercept vector with each element corresponding to intercept for corresponding lambda

error Indicator of whether the algorithm terminated early because max.it was reached

References

Gareth M. James, Courtney Paulson, and Paat Rusmevichientong (JASA, 2019) "Penalized and Constrained Optimization." (Full text available at http://www-bcf.usc.edu/~gareth/research/PAC.pdf)

Examples

random_data = generate.data(n = 500, p = 20, m = 10)
lasso_fit = lasso.c(random_data$x, random_data$y, random_data$C.full, random_data$b)
lasso_fit$lambda
lasso_fit$error
### The coefficients for the first lambda value
lasso_fit$coefs[1,]
### Example of code where path is unable to be finished
### (only one iteration), so both directions will be tried
lasso_err = lasso.c(random_data$x, random_data$y, random_data$C.full,
random_data$b, max.it = 1)
lasso_err$error
lasso_err$lambda

[Package PACLasso version 1.0.0 Index]