CompressedSensing_solver: Solve given compressed sensing problem in parametric simplex...

Description Usage Arguments Value See Also Examples

View source: R/CompressedSensing_solver.R

Description

Solve given compressed sensing problem in parametric simplex method

Usage

1
CompressedSensing_solver(X, y, max_it = 50, lambda_threshold = 0.01)

Arguments

X

x is an n by d data matrix

y

y is a length n response vector

max_it

This is the number of the maximum path length one would like to achieve. The default length is 50.

lambda_threshold

The parametric simplex method will stop when the calculated parameter is smaller than lambda. The default value is 0.01.

Value

An object with S3 class "primal" is returned:

data

The n by d data matrix from the input

response

The length n response vector from the input

beta

A matrix of regression estimates whose columns correspond to regularization parameters for parametric simplex method.

df

The degree of freedom (number of nonzero coefficients) along the solution path.

value

The sequence of optimal value of the object function corresponded to the sequence of lambda.

iterN

The number of iteration in the program.

lambda

The sequence of regularization parameters lambda obtained in the program.

type

The type of the problem, such as Dantzig and SparseSVM.

See Also

primal-package, Dantzig_solver

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Compressed Sensing
## We set X to be standard normal random matrix and generate Y using gaussian noise.
## Generate the design matrix and coefficient vector
n = 100 # sample number
d = 250 # sample dimension
c = 0.5 # correlation parameter
s = 20  # support size of coefficient
set.seed(1024)
X = scale(matrix(rnorm(n*d),n,d)+c*rnorm(n))/sqrt(n-1)*sqrt(n)
beta = c(rnorm(s), rep(0, d-s))
## Generate response using Gaussian noise, and solve the solution path
noise = rnorm(n)
Y = X%*%beta + noise
## Compressed Sensing solved with parametric simplex method
fit.compressed = CompressedSensing_solver(X, Y, max_it = 100, lambda_threshold = 0.01)
###lambdas used
print(fit.compressed$lambda)
## number of nonzero coefficients for each lambda
print(fit.compressed$df)
## Visualize the solution path
plot(fit.compressed)

Example output

  [1] 12.406378 11.141205 10.063477  8.814117  8.693490  8.679598  8.177075
  [8]  8.128629  8.086081  7.889135  7.621883  7.484945  7.480271  7.406947
 [15]  7.195734  6.961435  6.948209  6.927170  6.817339  6.732897  6.690299
 [22]  6.642020  6.545004  6.290476  5.942655  5.828034  5.803680  5.711641
 [29]  5.661453  5.637930  5.445942  5.413840  5.371675  5.279912  5.254621
 [36]  5.122681  4.901308  4.820121  4.671253  4.512878  4.426809  4.282791
 [43]  4.234149  4.203568  4.177336  4.152557  4.140607  4.133283  4.090686
 [50]  4.067215  3.958325  3.935855  3.919628  3.907932  3.904413  3.898132
 [57]  3.779656  3.765164  3.754536  3.630808  3.517061  3.457231  3.457228
 [64]  3.457208  3.431373  3.431247  3.424512  3.404246  3.385739  3.347856
 [71]  3.305876  3.230272  3.198963  3.193857  3.171493  3.166697  3.098317
 [78]  3.062190  3.009426  2.914106  2.889619  2.884761  2.871199  2.859409
 [85]  2.800739  2.763164  2.744492  2.734922  2.687798  2.683401  2.680913
 [92]  2.675275  2.661521  2.607589  2.597246  2.569194  2.522440  2.505755
 [99]  2.489123  2.479117
  [1]  0  1  2  3  4  5  4  5  6  5  5  6  7  6  7  8  8  9 10  9 10  9  9 10 10
 [26] 11 12 11 10 11 12 13 13 13 14 13 13 12 13 14 15 15 15 15 16 17 17 16 16 17
 [51] 17 18 17 18 17 18 19 19 20 20 21 22 23 23 23 23 23 23 23 24 24 25 25 25 25
 [76] 26 26 26 27 27 28 29 28 28 28 28 28 29 29 29 30 31 31 32 31 31 30 30 31 30

PRIMAL documentation built on Jan. 22, 2020, 5:06 p.m.