| fnnls_reg | R Documentation |
Solves the NNLS problem min ||y - Xb||^2 subject to b >= 0 using the Fast Non-Negative Least Squares algorithm of Bro & de Jong (1997).
fnnls_reg(
y,
X,
tol = 1e-06,
max_iter = 1000,
sum_to_constant = FALSE,
constant = 1,
lower_bound = FALSE,
lb = 0
)
y |
A numeric vector of length n. |
X |
A numeric matrix of dimensions n x 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 list with two elements:
b: A non-negative numeric vector of length k with the estimated coefficients.
mse: The mean squared error of the fitted model.
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.
n <- 100
k <- 10
X <- matrix(rnorm(n * k), nrow = n, ncol = k)
true_b <- abs(rnorm(k))
y <- X %*% true_b + rnorm(n, sd = 0.1)
result <- fnnls_reg(y, X)
result$b
result$mse
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.