This function implements a quantile-based sparsification operation.

orthogonalizeAndQSparsify(
  v,
  sparsenessQuantile = 0.5,
  positivity = "either",
  orthogonalize = TRUE,
  softThresholding = FALSE,
  unitNorm = FALSE,
  sparsenessAlg = NA
)

Arguments

v

Input matrix

sparsenessQuantile

Quantile to control sparseness - higher is sparser

positivity

Restrict to positive or negative solution (beta) weights. Choices are "positive", "negative", or "either".

orthogonalize

Run Gram-Schmidt if TRUE.

softThresholding

Use soft thresholding if TRUE.

unitNorm

Normalize each vector to unit norm if TRUE.

sparsenessAlg

If specified, use a matrix partition algorithm ("orthorank", "spmp", "sum_preserving_matrix_partition" or "basic").

Value

A sparsified and optionally orthogonalized matrix.

Examples

mat <- replicate(100, rnorm(20))
mat <- orthogonalizeAndQSparsify(mat)