l2.reg: Cyclic Coordinate Descent for L2 regression

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Cyclic Coordinate Descent for L2 regression with p predictors and n cases

Usage

1
l2.reg(X, Y, lambda = 1)

Arguments

X

p x n design matrix - Note that the rows of X correspond to predictors and the columns to cases.

Y

Outcome of length n

lambda

Penalization Parameter. For optimal lambda, use cv.l2.reg.

Details

l2.reg performs an algorithm for estimating regression coefficients in a penalized L2 regression model. The algorithm is based on cyclic coordinate descent. For the new L1 algorithm that is faster, see (l1.reg).

Value

X

The design matrix.

cases

The number of cases

predictors

The number of predictors

lambda

The value of penalization parameter lambda used.

residual

A vector of length p listing the residuals

L2

The sum of the residuals

estimate

The estimate of the coefficients

nonzeros

The number "selected" variables included in the model.

selected

The name of the "selected" variables included in the model.

Author(s)

Edward Grant, Kenneth Lange, Tong Tong Wu

Maintainer: Edward Grant edward.m.grant@gmail.com

References

Wu, T.T. and Lange, K. (2008). Coordinate Descent Algorithms for Lasso Penalized Regression. Annals of Applied Statistics, Volume 2, No 1, 224-244.

See Also

print.l2.reg

summary.l2.reg

cv.l2.reg

plot.cv.l2.reg

l1.reg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
set.seed(100)
n=500
p=2000
nzfixed = c(1:5)
true.beta<-rep(0,p)
true.beta[nzfixed] = c(1,1,1,1,1)

x=matrix(rnorm(n*p),p,n)
y = t(x) %*% true.beta

rownames(x)<-1:nrow(x)
colnames(x)<-1:ncol(x)

#Lasso penalized L2 regression
out<-l2.reg(x,y,lambda=2)

#Re-estimate parameters without penalization
out2<-l2.reg(x[out$selected,],y,lambda=0)
out2

Example output

 Call: 
l2.reg.default(x[out$selected, ], y, lambda = 0)
# of cases= 500 
# of predictors= 5 

 Lambda used: 0 


 Intercept: 
[1] 4.665571e-08

 Selected Coefficient Estimates: 
     Predictor Estimate           
[1,] "1"       "0.999999991013709"
[2,] "2"       "1.00000001898795" 
[3,] "3"       "0.999999972687231"
[4,] "4"       "1.00000000402222" 
[5,] "5"       "0.999999997606403"

 Number of Active Variables: 
[1] 5

CDLasso documentation built on May 1, 2019, 8:02 p.m.