Fastnnls sel

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search


Fast non-negative least squares with selective constraints.


[b,xi] = fastnnls_sel(x,y,tol,b0,eqconst,xi,nnconst)
[b,xi] = fastnnls_sel(x,y,tol,b0,eqconst,nnconst);


FASTNNLS finds (b) that minimizes X*b-y in a constrained least squares sense. It is similar to b = X/y except that selected elements of (b) cannot contain negative values.

NOTE: This version is nearly identical to the standard fastnnls function except that it allows row-wise, or element-wise, control over non-negative and equality constraints.


  • x = MxK matrix of predictor variables.
  • y = MxN vector or matrix of predicted variables. If (y) is a matrix, the result is the solution for each column of (y) calculated independently.

Optional Inputs

  • tol = tolerance on the size of a regression coefficient that is considered zero. Not supplied or empty [ ] implies the default value [based on (x) and )eps)].
  • b0 = KxN initial guess for the regression vector(s). Default or empty [ ] is interpreted as no known intial guess.
  • eqconst = KxN equality constraints matrix. A value of NaN indicates no equality constraint for that element. Elements with finite values indicates an equality-constraint. If (eqconst) is empty [ ] then no equality constraints are imposed.
  • xi = Cached inverses output by a previous run of FASTNNLS or FASTNNLS_SEL (see outputs). If (xi) is set to 0 (zero) caching is diabled. If (xi) is empty [ ] it serves as a placeholder in the input argument list.
  • nnconst = KxN matrix or Kx1 vector used to indicate which elements of (b) are to be non-negatively constrained. If (nnconst) is Kx1 the function expands it to ==> repmat(nncont,1,N). Elements in (nnconst) with a value of 1 are non-negatively constrained. A value of 0 indicates a non-constrained value (i.e., negative values are allowed). If not supplied or empty [ ], the default is that all values are non-negatively constrained. If KxN (equal in size to b0), (nnconst) provides an element-by-element control of the non-negativity of (b). If Kx1 then (nnconst) provides control of the non-negativity of rows of (b).


  • b = KxN non-negatively constrained least squares solution.
  • xi = cached inverses of x'x (unless caching was disabled).

See Also

fasternnls, fastnnls, lsq2top, mcr, parafac