RSAVS_Generate_D_Matrix: Generate the pair-wise different matrix

View source: R/pre_define_functions.r

RSAVS_Generate_D_MatrixR Documentation

Generate the pair-wise different matrix

Description

This function generate the pairwise difference matrix(D matrix in the paper). By default it returns a sparse matrix(matrix.csr) from the package SparseM.

Usage

RSAVS_Generate_D_Matrix(n, dense = FALSE, w_vec = 1)

Arguments

n

number of observations.

dense

logical, whether the return type should be in dense matrix or not

w_vec

a scalar value of a length n * (n - 1) / 2 vector representing the weights for left part in each pair(e.g. \mu_i in \mu_i - \mu_j). If w_vec is a scalar, it will be recycled for every pair. Defaults to 1.

Details

In Original RSAVS via ADMM algorithm. This functions generates the pairwise difference matrix with w_vec = 1.

In RSI, the original objective function is converted to a sparse median regression via LLA. The pairwise difference matrix is coupled with weights extracted from the penalty functions. This is supplied into this function through w_vec.

Value

a difference matrix with size (n * (n - 1) / 2) \times n

Examples

RSAVS:::RSAVS_Generate_D_Matrix(5)
RSAVS:::RSAVS_Generate_D_Matrix(4, dense = TRUE)
RSAVS:::RSAVS_Generate_D_Matrix(3, w_vec = 2)
RSAVS:::RSAVS_Generate_D_Matrix(4, dense = TRUE, w_vec = c(1, -2, 3, -4, 5, -6))

fenguoerbian/RSAVS documentation built on Oct. 25, 2024, 3:16 p.m.