elnet_coord: fit linear model with elasticnet using coordinate descent...

Description Usage Arguments Details Value Examples

Description

Fit a linear model via penalized maximum likelihood. The regularization path is computed for the elasticnet penalty at a grid of values for the regularization parameter lambda, using coordinate descent algorithm.

Usage

1
2
elnet_coord(X, y, alpha = 1, lambda.length = 100, maxit = 10000,
  eps = 1e-05)

Arguments

X

input matrix, of dimension nobs x nvars; each row is an observation vector.

y

response variable.

alpha

The elasticnet mixing parameter, with 0≤ α ≤ 1. The penalty is defined as

(1-α)/2||β||_2^2+α ||β||_1

α=1 is the lasso penalty, and α=0 the ridge penalty.

lambda.length

The length of lambda sequence. Default is 100. The largest lambda is the smallest value which shrink all coefficients to zero. The smallest lambda is the largest lambda times 0.001. The lambda sequence is constructed from the largest lambda to the smallest lambda of length lambda.length.

maxit

Maximum number of passes over the data for all lambda values; default is 10^5.

eps

Convergence threshold for coordinate descent. Each inner coordinate-descent loop continues until the maximum change in the objective after any coefficient update is less than eps times the null deviance. Defaults value is 1E-7.

Details

The sequence of models implied by lambda is fit by coordinate descent. The objective function is

1/2 RSS/nobs + λ* penalty

.

Value

beta a list of fitted coefficients corresponding to the decreasing lambda sequence.

lambda the actural sequence of lambda values used. When alpha=0, the largest lambda reported does not quite give the zero coefficients reported (lambda=inf would in principle). Instead, the largest lambda for alpha=0.01 is used, and the sequence of lambda values is derived from this.

Examples

1
2
3
4
5
# Gaussian
x=matrix(rnorm(100*20),100,20)
y=rnorm(100)
fit1=elnet_coord(x,y)
plotpath(fit1,x)

yuxuanzhao2295/sci documentation built on May 23, 2019, 12:52 a.m.