Skip to contents

Returns one or more of underlying attributes used in design generation/evaluation

Usage

get_attribute(output, attr = NULL, round = TRUE)

Arguments

output

The output of either `gen_design()` or `eval_design()`/`eval_design_mc()``

attr

Default `NULL`. Return just the specific value requested. Potential values are `model.matrix` for model used, `moments.matrix`, `variance.matrix`, `alias.matrix`, `correlation.matrix`, and `model` for the model used in the evaluation/generation of the design.

round

Default `TRUE`. Rounds off values smaller than the magnitude `1e-15`` in the `correlation.matrix` and `alias.matrix` matrix attributes.

Value

A list of attributes.

Examples

# We can extract the attributes of a design from either the output of `gen_design()`
# or the output of `eval_design()`

factorialcoffee = expand.grid(cost = c(1, 2),
                             type = as.factor(c("Kona", "Colombian", "Ethiopian", "Sumatra")),
                             size = as.factor(c("Short", "Grande", "Venti")))

designcoffee = gen_design(factorialcoffee, ~cost + size + type, trials = 29,
                         optimality = "D", repeats = 100)

#Extract a list of all attributes
get_attribute(designcoffee)
#> $model.matrix
#>       (Intercept) cost      size1     size2      type1      type2     type3
#>  [1,]           1   -1 -0.7071068  1.224745 -0.5773503  1.6329932  0.000000
#>  [2,]           1    1  1.4142136  0.000000 -0.5773503 -0.8164966 -1.414214
#>  [3,]           1    1 -0.7071068 -1.224745 -0.5773503 -0.8164966  1.414214
#>  [4,]           1   -1 -0.7071068 -1.224745 -0.5773503  1.6329932  0.000000
#>  [5,]           1   -1  1.4142136  0.000000  1.7320508  0.0000000  0.000000
#>  [6,]           1   -1  1.4142136  0.000000 -0.5773503 -0.8164966 -1.414214
#>  [7,]           1   -1 -0.7071068 -1.224745 -0.5773503 -0.8164966 -1.414214
#>  [8,]           1    1 -0.7071068  1.224745 -0.5773503 -0.8164966 -1.414214
#>  [9,]           1   -1 -0.7071068 -1.224745  1.7320508  0.0000000  0.000000
#> [10,]           1    1  1.4142136  0.000000 -0.5773503 -0.8164966 -1.414214
#> [11,]           1    1 -0.7071068 -1.224745  1.7320508  0.0000000  0.000000
#> [12,]           1   -1  1.4142136  0.000000 -0.5773503  1.6329932  0.000000
#> [13,]           1   -1 -0.7071068 -1.224745 -0.5773503 -0.8164966  1.414214
#> [14,]           1    1 -0.7071068 -1.224745  1.7320508  0.0000000  0.000000
#> [15,]           1    1  1.4142136  0.000000 -0.5773503  1.6329932  0.000000
#> [16,]           1    1  1.4142136  0.000000 -0.5773503 -0.8164966  1.414214
#> [17,]           1    1 -0.7071068  1.224745  1.7320508  0.0000000  0.000000
#> [18,]           1   -1 -0.7071068  1.224745 -0.5773503 -0.8164966 -1.414214
#> [19,]           1    1  1.4142136  0.000000 -0.5773503 -0.8164966  1.414214
#> [20,]           1   -1 -0.7071068  1.224745  1.7320508  0.0000000  0.000000
#> [21,]           1   -1  1.4142136  0.000000  1.7320508  0.0000000  0.000000
#> [22,]           1   -1 -0.7071068  1.224745 -0.5773503 -0.8164966  1.414214
#> [23,]           1    1  1.4142136  0.000000 -0.5773503  1.6329932  0.000000
#> [24,]           1    1 -0.7071068  1.224745 -0.5773503 -0.8164966  1.414214
#> [25,]           1    1 -0.7071068 -1.224745 -0.5773503  1.6329932  0.000000
#> [26,]           1   -1  1.4142136  0.000000 -0.5773503 -0.8164966  1.414214
#> [27,]           1    1 -0.7071068  1.224745  1.7320508  0.0000000  0.000000
#> [28,]           1    1 -0.7071068  1.224745 -0.5773503  1.6329932  0.000000
#> [29,]           1    1 -0.7071068 -1.224745 -0.5773503 -0.8164966 -1.414214
#> 
#> $moments.matrix
#>             (Intercept)      cost size1 size2 type1 type2 type3
#> (Intercept)           1 0.0000000     0     0     0     0     0
#> cost                  0 0.3333333     0     0     0     0     0
#> size1                 0 0.0000000     1     0     0     0     0
#> size2                 0 0.0000000     0     1     0     0     0
#> type1                 0 0.0000000     0     0     1     0     0
#> type2                 0 0.0000000     0     0     0     1     0
#> type3                 0 0.0000000     0     0     0     0     1
#> 
#> $variance.matrix
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
#>  [1,]    1    0    0    0    0    0    0    0    0     0     0     0     0
#>  [2,]    0    1    0    0    0    0    0    0    0     0     0     0     0
#>  [3,]    0    0    1    0    0    0    0    0    0     0     0     0     0
#>  [4,]    0    0    0    1    0    0    0    0    0     0     0     0     0
#>  [5,]    0    0    0    0    1    0    0    0    0     0     0     0     0
#>  [6,]    0    0    0    0    0    1    0    0    0     0     0     0     0
#>  [7,]    0    0    0    0    0    0    1    0    0     0     0     0     0
#>  [8,]    0    0    0    0    0    0    0    1    0     0     0     0     0
#>  [9,]    0    0    0    0    0    0    0    0    1     0     0     0     0
#> [10,]    0    0    0    0    0    0    0    0    0     1     0     0     0
#> [11,]    0    0    0    0    0    0    0    0    0     0     1     0     0
#> [12,]    0    0    0    0    0    0    0    0    0     0     0     1     0
#> [13,]    0    0    0    0    0    0    0    0    0     0     0     0     1
#> [14,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [15,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [16,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [17,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [18,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [19,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [20,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [21,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [22,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [23,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [24,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [25,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [26,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [27,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [28,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [29,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#>       [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
#>  [1,]     0     0     0     0     0     0     0     0     0     0     0     0
#>  [2,]     0     0     0     0     0     0     0     0     0     0     0     0
#>  [3,]     0     0     0     0     0     0     0     0     0     0     0     0
#>  [4,]     0     0     0     0     0     0     0     0     0     0     0     0
#>  [5,]     0     0     0     0     0     0     0     0     0     0     0     0
#>  [6,]     0     0     0     0     0     0     0     0     0     0     0     0
#>  [7,]     0     0     0     0     0     0     0     0     0     0     0     0
#>  [8,]     0     0     0     0     0     0     0     0     0     0     0     0
#>  [9,]     0     0     0     0     0     0     0     0     0     0     0     0
#> [10,]     0     0     0     0     0     0     0     0     0     0     0     0
#> [11,]     0     0     0     0     0     0     0     0     0     0     0     0
#> [12,]     0     0     0     0     0     0     0     0     0     0     0     0
#> [13,]     0     0     0     0     0     0     0     0     0     0     0     0
#> [14,]     1     0     0     0     0     0     0     0     0     0     0     0
#> [15,]     0     1     0     0     0     0     0     0     0     0     0     0
#> [16,]     0     0     1     0     0     0     0     0     0     0     0     0
#> [17,]     0     0     0     1     0     0     0     0     0     0     0     0
#> [18,]     0     0     0     0     1     0     0     0     0     0     0     0
#> [19,]     0     0     0     0     0     1     0     0     0     0     0     0
#> [20,]     0     0     0     0     0     0     1     0     0     0     0     0
#> [21,]     0     0     0     0     0     0     0     1     0     0     0     0
#> [22,]     0     0     0     0     0     0     0     0     1     0     0     0
#> [23,]     0     0     0     0     0     0     0     0     0     1     0     0
#> [24,]     0     0     0     0     0     0     0     0     0     0     1     0
#> [25,]     0     0     0     0     0     0     0     0     0     0     0     1
#> [26,]     0     0     0     0     0     0     0     0     0     0     0     0
#> [27,]     0     0     0     0     0     0     0     0     0     0     0     0
#> [28,]     0     0     0     0     0     0     0     0     0     0     0     0
#> [29,]     0     0     0     0     0     0     0     0     0     0     0     0
#>       [,26] [,27] [,28] [,29]
#>  [1,]     0     0     0     0
#>  [2,]     0     0     0     0
#>  [3,]     0     0     0     0
#>  [4,]     0     0     0     0
#>  [5,]     0     0     0     0
#>  [6,]     0     0     0     0
#>  [7,]     0     0     0     0
#>  [8,]     0     0     0     0
#>  [9,]     0     0     0     0
#> [10,]     0     0     0     0
#> [11,]     0     0     0     0
#> [12,]     0     0     0     0
#> [13,]     0     0     0     0
#> [14,]     0     0     0     0
#> [15,]     0     0     0     0
#> [16,]     0     0     0     0
#> [17,]     0     0     0     0
#> [18,]     0     0     0     0
#> [19,]     0     0     0     0
#> [20,]     0     0     0     0
#> [21,]     0     0     0     0
#> [22,]     0     0     0     0
#> [23,]     0     0     0     0
#> [24,]     0     0     0     0
#> [25,]     0     0     0     0
#> [26,]     1     0     0     0
#> [27,]     0     1     0     0
#> [28,]     0     0     1     0
#> [29,]     0     0     0     1
#> 
#> $alias.matrix
#>             cost size1 size2 type1 type2 type3   cost:size1 cost:size2
#> (Intercept)    0     0     0     0     0     0  0.005324599  0.0000000
#> cost           1     0     0     0     0     0  0.078804069  0.0000000
#> size1          0     1     0     0     0     0  0.048192771  0.0000000
#> size2          0     0     1     0     0     0  0.000000000  0.1111111
#> type1          0     0     0     1     0     0 -0.304341723  0.0000000
#> type2          0     0     0     0     1     0  0.000000000  0.0000000
#> type3          0     0     0     0     0     1  0.000000000  0.0000000
#>              cost:type1 cost:type2 cost:type3 size1:type1 size2:type1
#> (Intercept) -0.03478014  0.0000000  0.0000000 -0.12173669   0.0000000
#> cost         0.06260425  0.0000000  0.0000000 -0.33200915   0.0000000
#> size1       -0.31479386  0.0000000  0.0000000 -0.06260425   0.0000000
#> size2        0.00000000  0.0000000  0.0000000  0.00000000   0.1924501
#> type1       -0.01204819  0.0000000  0.0000000 -0.11288150   0.0000000
#> type2        0.00000000  0.1428571  0.0000000  0.00000000   0.0000000
#> type3        0.00000000  0.0000000  0.1428571  0.00000000   0.0000000
#>             size1:type2 size2:type2 size1:type3 size2:type3
#> (Intercept)   0.0000000           0   0.0000000           0
#> cost          0.0000000           0   0.0000000           0
#> size1         0.0000000           0   0.0000000           0
#> size2         0.0000000           0   0.0000000           0
#> type1         0.0000000           0   0.0000000           0
#> type2         0.2020305           0   0.0000000           0
#> type3         0.0000000           0   0.2020305           0
#> 
#> $correlation.matrix
#>             cost     size1 size2      type1 type2 type3
#> cost  1.00000000 0.0000000     0 0.05776713     0     0
#> size1 0.00000000 1.0000000     0 0.15803160     0     0
#> size2 0.00000000 0.0000000     1 0.00000000     0     0
#> type1 0.05776713 0.1580316     0 1.00000000     0     0
#> type2 0.00000000 0.0000000     0 0.00000000     1     0
#> type3 0.00000000 0.0000000     0 0.00000000     0     1
#> 
#> $model
#> ~cost + size + type
#> <environment: 0x562049b4c410>
#> 

#Get just one attribute
get_attribute(designcoffee,"model.matrix")
#>       (Intercept) cost      size1     size2      type1      type2     type3
#>  [1,]           1   -1 -0.7071068  1.224745 -0.5773503  1.6329932  0.000000
#>  [2,]           1    1  1.4142136  0.000000 -0.5773503 -0.8164966 -1.414214
#>  [3,]           1    1 -0.7071068 -1.224745 -0.5773503 -0.8164966  1.414214
#>  [4,]           1   -1 -0.7071068 -1.224745 -0.5773503  1.6329932  0.000000
#>  [5,]           1   -1  1.4142136  0.000000  1.7320508  0.0000000  0.000000
#>  [6,]           1   -1  1.4142136  0.000000 -0.5773503 -0.8164966 -1.414214
#>  [7,]           1   -1 -0.7071068 -1.224745 -0.5773503 -0.8164966 -1.414214
#>  [8,]           1    1 -0.7071068  1.224745 -0.5773503 -0.8164966 -1.414214
#>  [9,]           1   -1 -0.7071068 -1.224745  1.7320508  0.0000000  0.000000
#> [10,]           1    1  1.4142136  0.000000 -0.5773503 -0.8164966 -1.414214
#> [11,]           1    1 -0.7071068 -1.224745  1.7320508  0.0000000  0.000000
#> [12,]           1   -1  1.4142136  0.000000 -0.5773503  1.6329932  0.000000
#> [13,]           1   -1 -0.7071068 -1.224745 -0.5773503 -0.8164966  1.414214
#> [14,]           1    1 -0.7071068 -1.224745  1.7320508  0.0000000  0.000000
#> [15,]           1    1  1.4142136  0.000000 -0.5773503  1.6329932  0.000000
#> [16,]           1    1  1.4142136  0.000000 -0.5773503 -0.8164966  1.414214
#> [17,]           1    1 -0.7071068  1.224745  1.7320508  0.0000000  0.000000
#> [18,]           1   -1 -0.7071068  1.224745 -0.5773503 -0.8164966 -1.414214
#> [19,]           1    1  1.4142136  0.000000 -0.5773503 -0.8164966  1.414214
#> [20,]           1   -1 -0.7071068  1.224745  1.7320508  0.0000000  0.000000
#> [21,]           1   -1  1.4142136  0.000000  1.7320508  0.0000000  0.000000
#> [22,]           1   -1 -0.7071068  1.224745 -0.5773503 -0.8164966  1.414214
#> [23,]           1    1  1.4142136  0.000000 -0.5773503  1.6329932  0.000000
#> [24,]           1    1 -0.7071068  1.224745 -0.5773503 -0.8164966  1.414214
#> [25,]           1    1 -0.7071068 -1.224745 -0.5773503  1.6329932  0.000000
#> [26,]           1   -1  1.4142136  0.000000 -0.5773503 -0.8164966  1.414214
#> [27,]           1    1 -0.7071068  1.224745  1.7320508  0.0000000  0.000000
#> [28,]           1    1 -0.7071068  1.224745 -0.5773503  1.6329932  0.000000
#> [29,]           1    1 -0.7071068 -1.224745 -0.5773503 -0.8164966 -1.414214

# Extract from `eval_design()` output
power_output = eval_design(designcoffee, model = ~cost + size + type,
                          alpha = 0.05, detailedoutput = TRUE)

get_attribute(power_output,"correlation.matrix")
#>             cost      size1      size2      type1      type2      type3
#> cost  1.00000000 0.00997807 0.01772574 0.02159185 0.03064609 0.05386824
#> size1 0.00997807 1.00000000 0.04386345 0.02576107 0.03656362 0.06426979
#> size2 0.01772574 0.04386345 1.00000000 0.04576376 0.06495416 0.11417333
#> type1 0.02159185 0.02576107 0.04576376 1.00000000 0.01022654 0.01797572
#> type2 0.03064609 0.03656362 0.06495416 0.01022654 1.00000000 0.02551359
#> type3 0.05386824 0.06426979 0.11417333 0.01797572 0.02551359 1.00000000