| fnnls_regs | R Documentation |
Solves the NNLS problem min ||Y - XB||_F^2 subject to B >= 0 using the Fast Non-Negative Least Squares algorithm of Bro & de Jong (1997).
fnnls_regs(
Y,
X,
tol = 1e-06,
max_iter = 1000,
sum_to_constant = FALSE,
constant = 1,
lower_bound = FALSE,
lb = 0,
parallel = FALSE,
ncores = -1
)
Y |
A numeric matrix of dimensions n x m. |
X |
A numeric matrix of dimensions n x p. |
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 in each column of B sum to 'constant'. Default is FALSE. |
constant |
If sum_to_constant is TRUE, all entries in each column 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. |
parallel |
If TRUE, the columns of B are computed in parallel. The default value is FALSE. |
ncores |
If parallel is TRUE, this many cores are used in the parallel computations. Must be positive integer. The default value is -1 (use all available cores). |
A list with two elements:
B: A non-negative numeric matrix of dimensions p x m with the estimated coefficients.
mse: A numeric vector of length m with the mean squared error for each output column.
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 <- 50
p <- 10
m <- 3
X <- matrix(rnorm(n * p), nrow = n, ncol = p)
Y <- matrix(runif(n * m, min = 0, max = 10), nrow = n, ncol = m)
result <- fnnls_regs(Y, X, tol = 1e-8, max_iter = 1000)
result$B
result$mse
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.