Skip to contents

Formula: PRSS(beta, lambda, alpha) = RSS(beta) + lambda [ (1 - alpha)/2 * sum_j b_j^2

  • alpha * sum_j |b_j| ]

[ (1 - alpha)/2 * sum_j b_j^2

  • alpha * sum_j |b_j| ]: R:%20(1%20-%20alpha)/2%20*%20sum_j%20b_j%5E2%0A+%20alpha%20*%20sum_j%20%7Cb_j%7C%20

Usage

Enetobj(X, y, beta, lam, alpha, add_intercept = TRUE)

Arguments

X

Design matrix, one record per row.

y

Response vector of length n.

beta

Coefficient vector.

lam

Regularization parameter lambda; must be non-negative.

alpha

Mixing parameter in [0, 1]: 0 is the ridge penalty, 1 is the lasso penalty.

add_intercept

Treat the first entry of beta as an unpenalized intercept and prepend a column of ones to X.

Value

List with prss, rss, penalty, l1, l2, lambda, alpha, n, p.

References

Montesinos Lopez, Montesinos Lopez and Crossa (2022), Multivariate Statistical Machine Learning Methods for Genomic Prediction, Springer, doi:10.1007/978-3-030-89010-0. Chapter 3, Sect. 3.6.2 p. 94 describes the elastic net as the combination of the ridge and lasso penalties implemented by glmnet, and Chapter 7 p. 230 defines its mixing parameter alpha: alpha = 0 gives the ridge penalty, alpha = 1 the lasso, and values in between the elastic net. The book names those two endpoints but does not print the mixed objective itself; the (1 - alpha)/2 and alpha weights are the glmnet parameterization of Friedman, Hastie and Tibshirani (2010), Regularization Paths for Generalized Linear Models via Coordinate Descent, Journal of Statistical Software 33(1):1-22, doi:10.18637/jss.v033.i01, which is the package the book cites for this penalty. Both chapters read from the PDFs; the mixing weights come from the cited paper, and the endpoints agree with the book: alpha = 0 reproduces MVSML Sect. 3.6.1 up to the factor 1/2 on the ridge term, alpha = 1 reproduces Sect. 3.6.2 exactly.

Examples

set.seed(1)
X <- matrix(rnorm(20), 10, 2)
y <- rnorm(10)
Enetobj(X, y, beta = c(0, 0.5, -0.3), lam = 0.1, alpha = 0.5)
#> $prss
#> [1] 19.70967
#> 
#> $rss
#> [1] 19.66117
#> 
#> $penalty
#> [1] 0.0485
#> 
#> $l1
#> [1] 0.8
#> 
#> $l2
#> [1] 0.34
#> 
#> $lambda
#> [1] 0.1
#> 
#> $alpha
#> [1] 0.5
#> 
#> $n
#> [1] 10
#> 
#> $p
#> [1] 3
#> 
#> $method
#> [1] "Elastic net penalized RSS, MVSML Sect. 3.6.2 / Chap. 7"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"