Learn R Programming

spareg (version 1.1.1)

rp_cw: Sparse Embedding 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 Clarkson2013LowRankApproxspareg.

Usage

rp_cw(..., 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 entries of the matrix are generated based on Clarkson2013LowRankApproxspareg. This matrix is constructed as \(\Phi=BD\in \mathbb{R}^{m\times p}\), where \(B\) is a \((p\times p)\) binary matrix, where for each column \(j\) an index is uniformly sampled from \(\{1,\ldots,m\}\) and the corresponding entry is set to one, and \(D\) is a \((p\times p)\) diagonal matrix, with entries \(d_j \sim \text{Unif}(\{-1, 1\})\). If specified as rp_cw(data = TRUE), the random elements on the diagonal are replaced by the ridge coefficients with a small penalty, as introduced in parzer2024glmsspareg.

References

Clarkson2013LowRankApproxsparegparzer2024glmsspareg.

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_cw(data = TRUE))

Run the code above in your browser using DataLab