| fnnls | R Documentation |
Solves the NNLS problem min ||y - Xw||^2 subject to w >= 0 using the Fast Non-Negative Least Squares algorithm of Bro & de Jong (1997).
fnnls(
XtX,
Xty,
tol = 1e-06,
max_iter = 1000,
sum_to_constant = FALSE,
constant = 1,
lower_bound = FALSE,
lb = 0
)
XtX |
A symmetric positive definite matrix of dimensions k x k. |
Xty |
A numeric vector of length k. |
tol |
The convergence tolerance, default is 1e-6. |
max_iter |
The maximum number of iterations, default is 1000. |
sum_to_constant |
If TRUE all entries sum to 'constant', Default is FALSE. |
constant |
If sum_to_constant is TRUE, all entries sum to this number. The default value is 1. |
lower_bound |
If TRUE all entries bounded below by 'lb', otherwise they are nonnegative. The default value is FALSE. |
lb |
If lower_bound is TRUE all entries are bounded below by 'lb'. The default value is 0. |
A non-negative numeric vector of length k with the estimated coefficients.
Bro, Rasmus & Jong, Sijmen. (1997). A Fast Non-negativity-constrained Least Squares Algorithm. Journal of Chemometrics. 11. 393-401. 10.1002/(SICI)1099-128X(199709/10)11:53.0.CO;2-L.
k <- 10
D <- 100
H <- matrix(rnorm(k * D), nrow = k, ncol = D)
x <- rnorm(D)
XtX <- H %*% t(H) + diag(1e-8, k)
Xty <- as.vector(H %*% x)
w <- fnnls(XtX, Xty)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.