
Ridge closed form (Geron Ch 4, morie.fn grridn)
Source:R/geron_train_native.R
morie_geron_ridge_normal_equation.Rdtheta = (X^T X + alpha diag(0, 1, ..., 1))^-1 X^T y; the bias column is never penalised.
Examples
morie_geron_ridge_normal_equation(X = c(1, 2, 3, 4, 5, 6, 7, 8), y = 5L, alpha = 0.5)
#> $theta
#> [1] 5 0 0 0 0 0 0 0
#>
#> $fitted
#> [1] 5
#>
#> $residuals
#> [1] 0
#>
#> $rss
#> [1] 0
#>
#> $penalty
#> [1] 0
#>
#> $estimate
#> [1] 5 0 0 0 0 0 0 0
#>
#> $n
#> [1] 1
#>