Skip to contents

Creates all the possible matrices given a number of blocks and a number of weights. Optionally it can create just a subset of those based on a numeric vector.

Usage

weight_design(weights = 4, size, diff0 = NULL)

Arguments

weights

A numeric value with the number of weights to be used

size

A numeric value with the number of datasets on the design.

diff0

A Numeric vector of position which should be different from 0 from the lower.tri(). See examples

Value

A list of matrices with the designs with different weights.

See also

Examples

out <- weight_design(4, 4)
head(out)
#> [[1]]
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    0    0    0
#> [2,]    0    0    0    0
#> [3,]    0    0    0    0
#> [4,]    0    0    0    0
#> 
#> [[2]]
#>           [,1]      [,2] [,3] [,4]
#> [1,] 0.0000000 0.3333333    0    0
#> [2,] 0.3333333 0.0000000    0    0
#> [3,] 0.0000000 0.0000000    0    0
#> [4,] 0.0000000 0.0000000    0    0
#> 
#> [[3]]
#>           [,1]      [,2] [,3] [,4]
#> [1,] 0.0000000 0.6666667    0    0
#> [2,] 0.6666667 0.0000000    0    0
#> [3,] 0.0000000 0.0000000    0    0
#> [4,] 0.0000000 0.0000000    0    0
#> 
#> [[4]]
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    1    0    0
#> [2,]    1    0    0    0
#> [3,]    0    0    0    0
#> [4,]    0    0    0    0
#> 
#> [[5]]
#>           [,1] [,2]      [,3] [,4]
#> [1,] 0.0000000    0 0.3333333    0
#> [2,] 0.0000000    0 0.0000000    0
#> [3,] 0.3333333    0 0.0000000    0
#> [4,] 0.0000000    0 0.0000000    0
#> 
#> [[6]]
#>           [,1]      [,2]      [,3] [,4]
#> [1,] 0.0000000 0.3333333 0.3333333    0
#> [2,] 0.3333333 0.0000000 0.0000000    0
#> [3,] 0.3333333 0.0000000 0.0000000    0
#> [4,] 0.0000000 0.0000000 0.0000000    0
#> 
# Using previously defined matrix
C <- diag(4)
diag(C) <- 0
C <- subSymm(C, 1, 2, 0.456)
C <- subSymm(C, 2, 3, runif(1))
C <- subSymm(C, 1, 3, runif(1))
C <- subSymm(C, 3, 4, runif(1))
# Explore matrices which are similar to C
d <- weight_design(weights = 11, size = 4, which(lower.tri(C) & C != 0))
head(d)
#> [[1]]
#>      [,1] [,2] [,3] [,4]
#> [1,]  0.0  0.1  0.1  0.0
#> [2,]  0.1  0.0  0.1  0.0
#> [3,]  0.1  0.1  0.0  0.1
#> [4,]  0.0  0.0  0.1  0.0
#> 
#> [[2]]
#>      [,1] [,2] [,3] [,4]
#> [1,]  0.0  0.2  0.1  0.0
#> [2,]  0.2  0.0  0.1  0.0
#> [3,]  0.1  0.1  0.0  0.1
#> [4,]  0.0  0.0  0.1  0.0
#> 
#> [[3]]
#>      [,1] [,2] [,3] [,4]
#> [1,]  0.0  0.3  0.1  0.0
#> [2,]  0.3  0.0  0.1  0.0
#> [3,]  0.1  0.1  0.0  0.1
#> [4,]  0.0  0.0  0.1  0.0
#> 
#> [[4]]
#>      [,1] [,2] [,3] [,4]
#> [1,]  0.0  0.4  0.1  0.0
#> [2,]  0.4  0.0  0.1  0.0
#> [3,]  0.1  0.1  0.0  0.1
#> [4,]  0.0  0.0  0.1  0.0
#> 
#> [[5]]
#>      [,1] [,2] [,3] [,4]
#> [1,]  0.0  0.5  0.1  0.0
#> [2,]  0.5  0.0  0.1  0.0
#> [3,]  0.1  0.1  0.0  0.1
#> [4,]  0.0  0.0  0.1  0.0
#> 
#> [[6]]
#>      [,1] [,2] [,3] [,4]
#> [1,]  0.0  0.6  0.1  0.0
#> [2,]  0.6  0.0  0.1  0.0
#> [3,]  0.1  0.1  0.0  0.1
#> [4,]  0.0  0.0  0.1  0.0
#>