Skip to contents

Formula: beta(lambda) = (X'X + lambda D)^-1 X'y, D = diag(0, 1, ..., 1)

Usage

Ridgesol(X, y, lam, add_intercept = TRUE)

Arguments

X

Design matrix, one record per row.

y

Response vector of length n.

lam

Regularization parameter lambda; must be non-negative.

add_intercept

Prepend a column of ones to X and leave its coefficient unpenalized.

Value

List with beta, fitted, resid, rss, penalty, prss, 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.1 p. 82: solving grad PRSS_lambda(beta) = 0 gives beta-hat(lambda) = (X'X + lambda D)^-1 X'y with D the identity carrying a zero in its first entry. Delegates to the chapter-3 ridge routine verified against the book.

Examples

Ridgesol(X = c(1, 2, 3, 4, 5, 6, 7, 8), y = c(1, 2, 3, 4, 5, 6, 7, 8), lam = 5L)
#> $beta
#> [1] 0.4787234 0.8936170
#> 
#> $fitted
#> [1] 1.372340 2.265957 3.159574 4.053191 4.946809 5.840426 6.734043 7.627660
#> 
#> $resid
#> [1] -0.37234043 -0.26595745 -0.15957447 -0.05319149  0.05319149  0.15957447
#> [7]  0.26595745  0.37234043
#> 
#> $rss
#> [1] 0.4753282
#> 
#> $penalty
#> [1] 3.992757
#> 
#> $prss
#> [1] 4.468085
#> 
#> $lambda
#> [1] 5
#> 
#> $n
#> [1] 8
#> 
#> $p
#> [1] 2
#> 
#> $method
#> [1] "Ridge closed-form solution, MVSML Sect. 3.6.1"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"