kisungyou / ADMM

Algorithms using Alternating Direction Method of Multipliers
6 stars 2 forks source link

Estimated lasso coefficients are not zero? #1

Open vtshen opened 5 years ago

vtshen commented 5 years ago

Following the example in the function admm.lasso, the estimated coefficients are small but not zero. Their values are seem to related to the argument reltol, so how many digits are valid?

Thanks

output$x
[1] -3.270854e-04 -2.460257e-03  8.444083e-04 -1.335290e-03  9.845349e-04  2.279027e-01
  [7]  7.398773e-04  2.245857e-03  7.515649e-04  2.404189e-03  9.981220e-04  6.412790e-04
 [13]  3.651442e-03 -5.036348e-04  1.308097e-03 -8.222905e-04  5.891553e-04 -2.098625e-03
 [19]  2.257304e-03 -4.582407e-04 -1.164597e-03 -2.423823e-01 -5.745030e-04 -3.135581e-03
 [25]  6.526661e-05 -1.461590e+00 -9.909032e-04 -6.328644e-04  1.206102e-03 -2.492967e-03
 [31]  1.179814e-03  1.495049e-03  1.316818e-03  1.679532e-03 -2.248019e-03 -6.329432e-04
 [37]  1.341321e-03 -2.575138e-03 -4.421040e-06  1.116922e-03  1.366425e-04  5.201158e-01
 [43]  2.550023e-03  3.194288e-04  8.194998e-04 -1.864943e-03 -1.070126e-04 -1.056679e+00
 [49] -4.187122e-04  5.545558e-04  8.169782e-04  1.215684e-04 -2.309607e-03  1.236960e-03
 [55] -2.321623e-04  1.429034e-03  2.839092e-04 -7.024475e-04 -5.072368e-04  1.674043e-02
 [61] -3.040985e-04 -2.398424e-03 -7.377515e-04  8.722082e-01  5.525391e-04  9.662510e-04
 [67]  4.041521e-04 -6.437467e-04 -7.882622e-04  1.098878e-03  1.000694e-03 -1.352730e-03
 [73] -1.765396e-03 -3.427888e-01 -9.247472e-04  3.599712e-05  1.946915e-02 -1.443810e-03
 [79]  1.294940e-03 -8.799976e-04  1.397357e-03  3.711076e-04 -5.439614e-04 -3.324134e-03
 [85] -1.596561e-03 -1.276059e-03  8.308569e-04 -3.080468e-04 -1.325126e-03  2.321922e-04
 [91]  3.931493e-01  1.891979e-03  1.383700e-03  2.985230e-04  4.987598e-05  2.787854e-03
 [97]  6.231259e-04 -6.365305e-01  2.290622e-03  1.065772e-03

Example in the R package

m = 50
n = 100
p = 0.1   # percentange of non-zero elements

x0 = matrix(Matrix::rsparsematrix(n,1,p))
A  = matrix(rnorm(m*n),nrow=m)
for (i in 1:ncol(A)){
  A[,i] = A[,i]/sqrt(sum(A[,i]*A[,i]))
}
b = A%*%x0 + sqrt(0.001)*matrix(rnorm(m))

## set regularization lambda value
lambda = 0.1*Matrix::norm(t(A)%*%b, 'I')

## run example
output = admm.lasso(A, b, lambda)
output$x
vtshen commented 5 years ago

I got advised that the solution will be sparse if the output variable is z. To verify that, is it possible to add the output of z from the output from admm_lasso.cpp