Skip to contents

`fun_lines` applies function `fun` to regression vectors while reordering the coefficients, such that the `j`-th coefficient in `beta[j, ]` is permuted with the `i`-th coefficient.

Usage

fun_lines(i, j, beta, fun = `-`, ni = 1, nj = 1)

Arguments

i

integer scalar. Index of the first vector.

j

integer scalar. Index of the second vector.

beta

p by p numeric matrix. In rows, regression vectors coefficients after node-wise regression. `diag(beta) = 0`.

fun

function. Applied on lines.

ni

integer scalar. Weight for vector `i`.

nj

integer scalar. Weight for vector `j`.

Value

numeric vector

Examples

beta <- matrix(round(rnorm(9),2), ncol = 3)
diag(beta) <- 0
beta
#>       [,1] [,2] [,3]
#> [1,]  0.00 0.71 1.29
#> [2,] -0.64 0.00 0.59
#> [3,]  1.21 1.41 0.00
fun_lines(1, 2, beta)
#> [1] 0.00 1.35 0.70
fun_lines(2, 1, beta)
#> [1] -1.35  0.00 -0.70