Learn R Programming

spareg (version 1.1.1)

rp_sparse: Sparse Random Projection Matrix

Description

Creates an object class 'randomprojection' using arguments passed by user which in turn can be employed to generate a sparse embedding matrix as in ACHLIOPTAS2003JLspareg.

Usage

rp_sparse(..., control = list())

Value

object of class 'randomprojection' which is a list with elements name, generate_fun, update_fun, control

Arguments

...

includes arguments which can be passed as attributes to the random projection matrix.

control

list of arguments to be used in functions generate_fun, update_fun, update_rpm_w_data

Details

The sparse matrix used in ACHLIOPTAS2003JLspareg with entries equal to \(\Psi_{ij} = \pm 1/\sqrt{\psi}\) with probability \(\psi/2\) and zero otherwise for \(\psi\in (0,1]\). Default is psi = 1.

Arguments related to the random projection procedure can be passed to the rp_gaussian() function through ..., and will be saved as attributes of the 'randomprojection' object. The following attributes are relevant for spar and spar.cv:

  • mslow: integer giving the minimum dimension to which the predictors should be projected; defaults to \(\log(p)\).

  • msup: integer giving the maximum dimension to which the predictors should be projected; defaults to \(n/2\).

References

ACHLIOPTAS2003JLspareg

Examples

Run this code
example_data <- simulate_spareg_data(n = 200, p = 2000, ntest = 100)
spar_res <- spar(example_data$x, example_data$y, xval = example_data$xtest,
  yval = example_data$ytest, nummods=c(5, 10, 15, 20, 25, 30),
  rp = rp_sparse(control = list(psi = 1/3)))

Run the code above in your browser using DataLab