set.seed(100)
n=500
p=2000
nz = c(1:5)
true.beta<-rep(0,p)
true.beta[nz] = 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 L1 regression
out<-l1.reg(x,y,lambda=50)
#Re-estimate parameters without penalization
out2<-l1.reg(x[out$selected,],y,lambda=0)
print(out2)
Run the code above in your browser using DataLab