Skip to contents

Lasso cost = MSE + alpha * L1 penalty (Geron Ch 4, morie.fn hmlaso)

Usage

morie_geron_lasso_cost_hmlaso(X, y, theta, alpha, skip_bias = FALSE)

Arguments

X, y

Data.

theta

Coefficients.

alpha

L1 strength.

skip_bias

Exclude theta[1].

Value

List with cost, mse, penalty, gradient, n_zero, estimate, n, method.

Examples

morie_geron_lasso_cost_hmlaso(X = c(1, 2, 3, 4, 5, 6, 7, 8), y = c(1, 2, 3, 4, 5, 6, 7, 8),
  theta = 0.5, alpha = 0.5)
#> $cost
#> [1] 6.625
#> 
#> $mse
#> [1] 6.375
#> 
#> $penalty
#> [1] 0.25
#> 
#> $gradient
#> [1] -25
#> 
#> $residuals
#> [1] -0.5 -1.0 -1.5 -2.0 -2.5 -3.0 -3.5 -4.0
#> 
#> $n_zero
#> [1] 0
#> 
#> $alpha
#> [1] 0.5
#> 
#> $estimate
#> [1] 6.625
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Lasso cost = MSE + alpha * L1 penalty"
#>