elnet_coord: Title

Description Usage Arguments Value Examples

Description

Solve the an elastic net problem via coordinate descent

Usage

1
2
elnet_coord(X, y, lambda = NULL, nlambda = 100, alpha,
  thresh = 1e-05, maxiter = 10000)

Arguments

X

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

y

response variable

lambda

default is null

nlambda

The number oflambda values - default is 100

alpha

The elasticnet mixing paramete

thresh

Convergence threshold for coordinate descent.

maxiter

the maximal number of iterations in each coordinate descent

Value

length(lambda)matrix of coefficients

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
n=50
p=20
beta<-c(2,0,-2,0,1,0,-1,0,rep(0,12))
X=matrix(rnorm(n*p),n,p)
Y<-X%*%beta+rnorm(n)
fit1<-elnet_coord(X,Y,alpha=0.3)
beta_cd<-t(as.matrix(fit1$beta))
pct <- rowSums(abs(beta_cd))
matplot(pct,beta_cd,type="l",lty=1,
       xlab="|beta|_1",ylab="Coefficients")
text(max(pct)+0.2,beta_cd[dim(beta_cd)[1],],1:p,col=1:p,cex=0.7)

sdeng24/statscomputing documentation built on June 5, 2019, 11:08 p.m.