Skip to contents

Construct internal and external weights

Usage

construct_weights(coef, id)

Arguments

coef

matrix with \(p\) rows (features) and \(q\) columns (problems)

id

integer in \(1,\ldots,q\)

Value

Returns a list with slots lower.limits, upper.limits, weight.source (external weights) and weight.target (internal weights). Each slot is a vector of length \(2*p\), with the first \(p\) entries for positive effects and the last \(p\) entries for negative effects.

See also

Use construct_penfacs to obtain penalty factors (i.e., for scaling and inverting weights).

Examples

p <- 10
q <- 3
data <- stats::rbinom(p*q,size=1,prob=0.2)*stats::rnorm(p*q)
coef <- matrix(data=data,nrow=p,ncol=q)
construct_weights(coef=coef,id=1)
#> $lower.limits
#>  [1]    0    0    0    0    0    0    0    0    0    0 -Inf -Inf -Inf -Inf -Inf
#> [16] -Inf -Inf -Inf -Inf -Inf
#> 
#> $upper.limits
#>  [1] Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf   0   0   0   0   0   0   0   0   0
#> [20]   0
#> 
#> $weight.source
#>  [1] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
#>  [9] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
#> [17] 1.656015 0.000000 0.000000 0.000000
#> 
#> $weight.target
#>  [1] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#>  [8] 0.2551809 0.0000000 0.0000000 0.0000000 0.7088655 0.0000000 0.0000000
#> [15] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#>