free_lasso {free}R Documentation

Main solver of free

Description

Main solver of free

Usage

free_lasso(
  p,
  lambda,
  est_func,
  par_init,
  alpha,
  tau,
  maxit = 1000L,
  tol_ee = 1e-06,
  tol_par = 1e-06,
  verbose = FALSE
)

Arguments

p

The dimension of the dataset

lambda

Lasso regularization coefficient

est_func

R function, the estimating function specified by the user

par_init

Optional, initial value for parameter update

alpha

Tuning parameter

tau

Tuning parameter

maxit

Maximum iterations

tol_ee

Convergence criterion based on the update of the estimating function

tol_par

Convergence criterion based on the update of the parameter

verbose

logical, print updates

Value

A list containing the regularized estimating equation estimates and the number of iterations it takes to converge.

Examples

# Standardize data
dat <- scale(mtcars)
x <- as.matrix(dat[, -1])
y <- as.vector(dat[, 1])
n <- nrow(x)
p <- ncol(x)

# Specify estimating function
ufunc <- function(b) {
  1/n * crossprod(x, (x %*% b - y) )
}

# Set hyperparameters
tau <- 0.6
alpha <- 0.5

# Set regularization coefficient
lambda1 <- 0
free_R1 <- free_lasso(p = p,
                      lambda = lambda1,
                      est_func = ufunc,
                      par_init = rep(0, p),
                      alpha = alpha,
                      tau = tau,
                      maxit = 10000L,
                      tol_ee = 1e-20,
                      tol_par = 1e-10,
                      verbose = FALSE)
free_R1$coefficients

# Compare with lm() - very close
lm(y~x-1)$coefficients

# Set regularization coefficient
lambda2 <- 0.7
free_R2 <- free_lasso(p = p,
                      lambda = lambda2,
                      est_func = ufunc,
                      par_init = rep(0, p),
                      alpha = alpha,
                      tau = tau,
                      maxit = 10000L,
                      tol_ee = 1e-20,
                      tol_par = 1e-10,
                      verbose = FALSE)
free_R2$coefficients


[Package free version 1.0.2 Index]