elnet_coord: Elastic Net

Description Usage Arguments Value Examples

View source: R/elnet_coord.R

Description

elnet_coord takes user-specified alpha and lambda values and fits an elastic net model using those parameters.

Usage

1
elnet_coord(x, y, alpha, lambda = 0.1, tol = 1e-04)

Arguments

x

Predictor matrix x, with n rows and p columns

y

Response vector y, with n elements

alpha

Elastic net alpha parameter. elastic net simplifies to Ridge regression under alpha = 0, and to Lasso regression under alpha = 1

lambda

Lasso tuning parameter

tol

Tolerance for convergence of betas. Algorithm will complete when the maximum change in beta values is smaller than the tol value

Value

Column vector of p Beta values from the elastic net algorithm.

Examples

1
2
3
4
5
beta = c(2,0,-2,0,1,0,-1,rep(0,13))
covar = diag(1,20)
covar[1,2] = covar[2,1] = covar[5,6] = covar[6,5] = .8
x = MASS::mvrnorm(20, rep(0, 20), covar)
y = x %*% beta + rnorm(20, 0, 1)

stevebroll/stsci6520hw2 documentation built on Dec. 23, 2021, 5:32 a.m.