Skip to contents

J = MSE + alpha * sum_{i>=1} |theta_i|, on the shared MSE core.

Usage

morie_geron_lasso_cost(X, y, theta, alpha, penalize_intercept = FALSE)

Arguments

X, y, theta

Design, targets and parameters.

alpha

Non-negative L1 weight.

penalize_intercept

Include theta[1] in the penalty.

Value

List with cost, mse, l1_penalty, l1_norm, n_zero.

Examples

morie_geron_lasso_cost(X = c(1, 2, 3, 4, 5, 6, 7, 8), y = 5L,
  theta = c(1, 2, 3, 4, 5, 6, 7, 8), alpha = 0.5)
#> $cost
#> [1] 39618.5
#> 
#> $mse
#> [1] 39601
#> 
#> $l1_penalty
#> [1] 17.5
#> 
#> $l1_norm
#> [1] 35
#> 
#> $n_zero
#> [1] 0
#> 
#> $alpha
#> [1] 0.5
#> 
#> $estimate
#> [1] 39618.5
#> 
#> $n
#> [1] 1
#>