nnls_mm: Nonnegative Least Squares via MM

Description Usage Arguments Examples

View source: R/nonnegativeleastsquares.R

Description

nnls_mm Iteratively computes the solution to the nonnegative least squares problem via a majorization-minimization algorithm.

Usage

1
nnls_mm(y, X, b, max_iter = 100, tol = 1e-04)

Arguments

y

Nonnegative response

X

Nonnegative design matrix

b

Nonnegative initial regression vector

max_iter

Maximum number of iterations

tol

Relative tolerance for convergence

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
set.seed(12345)
n <- 100
p <- 3
X <- matrix(rexp(n*p,rate=1),n,p)
b <- matrix(runif(p),p,1)
y <- X %*% b + matrix(abs(rnorm(n)),n,1)

## Setup mixture example
n <- 1e3
p <- 10
nnm <- generate_nnm(n,p)
set.seed(124)
X <- nnm$X
b <- double(p)
nComponents <- 3
k <- sample(1:p,nComponents,replace=FALSE)
b[k] <- matrix(runif(nComponents),ncol=1)
y <- X%*%b + 0.25*matrix(abs(rnorm(n)),n,1)

# Obtain solution to mixture problem
nnm_sol <- nnls_mm(y,X,runif(p))

gettingtothebottom documentation built on May 29, 2017, 8:28 p.m.