Description Usage Arguments Value References Examples
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).
1 2 3 | lasso.ineq(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)
|
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 inequality constraints of the form |
b |
constraint vector b |
l.min |
lowest value of lambda to consider (used as 10^ |
l.max |
largest value of lambda to consider (used as 10^ |
step |
step size increase in lambda attempted at each iteration (by a factor of 10^ |
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^ |
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
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)
1 2 3 4 5 6 7 8 9 10 11 12 | random_data = generate.data(n = 500, p = 20, m = 10)
lasso_fit = lasso.ineq(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.ineq(random_data$x, random_data$y, random_data$C.full,
random_data$b, max.it = 1)
lasso_err$error
lasso_err$lambda
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.