FoygelDrton_Armadillo: Minimize l2-penalized quadratic function

View source: R/RcppExports.R

FoygelDrton_ArmadilloR Documentation

Minimize l2-penalized quadratic function

Description

Minimize l2-penalized quadratic function

Usage

FoygelDrton_Armadillo(h, L, lambda, evals, evecs)

Arguments

h

a vector

L

a matrix with number of rows equal to the length of h

lambda

a value greater than zero giving the strength of the penalty

evals

the eigenvalues of L^TL

evecs

the eigenvectors of L^TL

Value

Returns the unique minimizer of

(1/2) \|h - L β\|_2^2 + λ * \|β\|_2

See Theorem 2 of Foygel, Rina, and Mathias Drton. "Exact block-wise optimization in group lasso and sparse group lasso for linear regression." arXiv preprint arXiv:1010.3320 (2010).

Examples

# generate an h and L
h <- rnorm(100)
L <- matrix(rnorm(100*10),100,10)
lambda <- 1

# get eigendecomposition of t(L) %*% L
LtL <- t(L) %*% L
eigen.out <- eigen(LtL)
evals <- eigen.out$values
evecs <- t(eigen.out$vectors)

# find minimizer
FoygelDrton_Armadillo(h,L,lambda,evals,evecs)

# compare to using optim() to minimize the same function
obj <- function(beta,L,h,lambda){
 val <- (1/2) * sum(  (h - L %*% beta )^2 ) + lambda * sqrt( sum(beta^2))
 return(val)
}
optim(par=rep(0,d),obj,L = L, h = h, lambda = lambda)$par

gregorkb/semipadd2pop documentation built on Oct. 2, 2022, 1:37 p.m.