Description Usage Arguments Value Examples
Solve the an elastic net problem via coordinate descent
1 2 | elnet_coord(X, y, lambda = NULL, nlambda = 100, alpha,
thresh = 1e-05, maxiter = 10000)
|
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 |
length(lambda)matrix of coefficients
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.