# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.regression.linear.lasso

## Class ConstrainedLASSObyQP

• java.lang.Object
• com.numericalmethod.suanshu.stats.regression.linear.lasso.ConstrainedLASSObyQP
• All Implemented Interfaces:
LinearModel

public class ConstrainedLASSObyQP
extends Object
implements LinearModel
This class solves the constrained form of LASSO (i.e.$$\min_w \left \{ \left \| Xw - y \right \|_2^2 \right \}$$ subject to $$\left \| w \right \|_1 \leq t$$) by transforming it into a single quadratic programming problem with (2 * m + 1) constraints, where m is the number of columns of the design matrix. $\min_w ||Xw - y||_2^2, \mbox{ s.t. } \sum{|w|} \leq t\\ \equiv \min_w \frac{1}{2} ||Xw - y||_2^2, \mbox{ s.t. } \sum{|w|} \leq t\\ \equiv \min_{\beta} \frac{1}{2} ||X(\beta^{+} - \beta^{-}) - y||_2^2, \mbox{ s.t. } \sum{\beta} \leq t, \mbox{ where } \beta = \begin{bmatrix} {\beta^{+}}\\ {\beta^{-}} \end{bmatrix}, w = \beta^{+} - \beta^{-}\\ \equiv \min_{\beta} \left \{ \frac{1}{2} \beta^T \begin{bmatrix} X^T X & -X^T X \\ -X^T X & X^T X \end{bmatrix} \beta - \begin{bmatrix} X^T y \\ -X^T y \end{bmatrix} \beta \right \}, \mbox{ s.t. } \beta_i \geq 0 \mbox{ and } \sum{-\beta} \geq -t\\ \equiv \min_{\beta} \left \{ \frac{1}{2} \beta^T M \beta + c^T \beta \right \}, \mbox{ s.t. } \beta_i \geq 0 \mbox{ and } \sum{-\beta} \geq -t, \mbox{where } M = \begin{bmatrix}X \\-X \end{bmatrix} \begin{bmatrix}X & -X \end{bmatrix} \mbox{ and } c = - \begin{bmatrix}X^T y \\-X^T y \end{bmatrix}\\$
• Wikipedia: LASSO method
• Kukreja, S. L., Löfberg, J, Brenner, M. J., A LEAST ABSOLUTE SHRINKAGE AND SELECTION OPERATOR (LASSO) FOR NONLINEAR SYSTEM IDENTIFICATION, 2006.
• ### Constructor Summary

Constructors
Constructor and Description
ConstrainedLASSObyQP(ConstrainedLASSOProblem problem)
Solves a constrained LASSO problem by transforming it into a single quadratic programming problem.
• ### Method Summary

All Methods
Modifier and Type Method and Description
LMBeta beta()
Gets $$\hat{\beta}$$ and statistics.
double Ey(Vector x)
Computes the expectation $$E(y(x))$$ given an input.
LMResiduals residuals()
Gets the residual analysis of an OLS regression.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### ConstrainedLASSObyQP

public ConstrainedLASSObyQP(ConstrainedLASSOProblem problem)
Solves a constrained LASSO problem by transforming it into a single quadratic programming problem.
Parameters:
problem - a constrained LASSO problem
• ### Method Detail

• #### Ey

public double Ey(Vector x)
Description copied from interface: LinearModel
Computes the expectation $$E(y(x))$$ given an input.
Specified by:
Ey in interface LinearModel
Parameters:
x - an input
Returns:
$$E(y(x))$$
• #### beta

public LMBeta beta()
Description copied from interface: LinearModel
Gets $$\hat{\beta}$$ and statistics.
Specified by:
beta in interface LinearModel
Returns:
$$\hat{\beta}$$ and statistics
• #### residuals

public LMResiduals residuals()
Description copied from interface: LinearModel
Gets the residual analysis of an OLS regression.
Specified by:
residuals in interface LinearModel
Returns:
the residual analysis