Skip to contents

Formula: PRSS(beta, lambda) = sum_i (y_i - b0 - sum_j x_ij b_j)^2 + lambda sum_j |b_j|; S(b, lambda) = sign(b) max(|b| - lambda, 0)

Usage

Lassoobj(X, y, beta, lam, 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.

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, soft, lambda, 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 pp. 93-94: the lasso penalizes the RSS by the sum of the absolute regression coefficients, and the coordinate-wise descent step of Friedman et al. (2007) uses the soft-threshold operator S(b, lambda) = b - lambda if b > 0 and lambda < |b|, b + lambda if b < 0 and lambda < |b|, and 0 if lambda >= |b| – which is sign(b) max(|b| - lambda, 0). soft reports that operator applied to the supplied coefficients. Read from the chapter PDF, not recalled.

Examples

X <- cbind(c(1, 2, 3, 4), c(0, 1, 0, 1))
y <- c(1.1, 2.3, 2.9, 4.2)
Lassoobj(X, y, beta = c(0.1, 1, 0.2), lam = 0.5)[c("prss", "rss", "penalty")]
#> $prss
#> [1] 0.65
#> 
#> $rss
#> [1] 0.05
#> 
#> $penalty
#> [1] 0.6
#>