Fit Ridge regression

ridge(x, y, lambda = 10^seq(-10, 10, length.out = 100))

Arguments

x

matrix of examples

y

a vector, the response

lambda

regularization parameters

Value

a list, an object of class 'ridge'

Examples


set.seed(123)
n <- 100 ; p <- 10
X <- matrix(rnorm(n * p), n, p)
y <- rnorm(n)

fit_obj <- ahead::ridge(X, y)

par(mfrow=c(1, 2))

matplot(log(fit_obj$lambda), t(fit_obj$coef), type = 'l',
main="coefficients \n f(lambda)")

plot(log(fit_obj$lambda), fit_obj$GCV, type='l',
main="GCV error")