Returns one or more of underlying attributes used in design generation/evaluation
Arguments
- output
The output of either
gen_design()
,eval_design()
, oreval_design_mc()
.- attr
Default
NULL
. Return just the specific value requested. Potential values aremodel_matrix
for model used,moments.matrix
,variance.matrix
,alias.matrix
,correlation.matrix
, andmodel
for the model used in the evaluation/generation of the design.- round
Default
TRUE
. Rounds off values smaller than the magnitude1e-15`` in the
correlation.matrixand
alias.matrix` matrix 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 -0.8164966 -1.414214
#> [2,] 1 -1 1.4142136 0.000000 -0.5773503 1.6329932 0.000000
#> [3,] 1 -1 1.4142136 0.000000 -0.5773503 -0.8164966 -1.414214
#> [4,] 1 -1 -0.7071068 1.224745 -0.5773503 1.6329932 0.000000
#> [5,] 1 -1 -0.7071068 -1.224745 -0.5773503 -0.8164966 1.414214
#> [6,] 1 -1 1.4142136 0.000000 -0.5773503 -0.8164966 1.414214
#> [7,] 1 -1 -0.7071068 -1.224745 -0.5773503 1.6329932 0.000000
#> [8,] 1 -1 -0.7071068 1.224745 -0.5773503 -0.8164966 -1.414214
#> [9,] 1 1 -0.7071068 -1.224745 -0.5773503 1.6329932 0.000000
#> [10,] 1 -1 -0.7071068 1.224745 -0.5773503 -0.8164966 1.414214
#> [11,] 1 1 -0.7071068 -1.224745 -0.5773503 -0.8164966 1.414214
#> [12,] 1 1 1.4142136 0.000000 -0.5773503 -0.8164966 1.414214
#> [13,] 1 1 -0.7071068 1.224745 -0.5773503 1.6329932 0.000000
#> [14,] 1 1 -0.7071068 1.224745 -0.5773503 1.6329932 0.000000
#> [15,] 1 -1 -0.7071068 -1.224745 1.7320508 0.0000000 0.000000
#> [16,] 1 1 -0.7071068 -1.224745 -0.5773503 -0.8164966 1.414214
#> [17,] 1 1 -0.7071068 1.224745 -0.5773503 -0.8164966 -1.414214
#> [18,] 1 -1 1.4142136 0.000000 1.7320508 0.0000000 0.000000
#> [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 -0.7071068 -1.224745 1.7320508 0.0000000 0.000000
#> [22,] 1 -1 -0.7071068 1.224745 1.7320508 0.0000000 0.000000
#> [23,] 1 1 -0.7071068 1.224745 -0.5773503 -0.8164966 -1.414214
#> [24,] 1 1 -0.7071068 -1.224745 -0.5773503 -0.8164966 -1.414214
#> [25,] 1 1 1.4142136 0.000000 -0.5773503 1.6329932 0.000000
#> [26,] 1 1 -0.7071068 1.224745 1.7320508 0.0000000 0.000000
#> [27,] 1 -1 -0.7071068 1.224745 -0.5773503 -0.8164966 1.414214
#> [28,] 1 1 1.4142136 0.000000 -0.5773503 -0.8164966 1.414214
#> [29,] 1 1 1.4142136 0.000000 1.7320508 0.0000000 0.000000
#>
#> $moments.matrix
#> [1] NA
#>
#> $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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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.00266230 0.004611238
#> cost 1 0 0 0 0 0 -0.03940203 0.068246326
#> size1 0 1 0 0 0 0 0.09538153 0.027244440
#> size2 0 0 1 0 0 0 0.02724444 0.063922356
#> type1 0 0 0 1 0 0 -0.05072362 0.087855888
#> type2 0 0 0 0 1 0 -0.07173403 0.124246988
#> type3 0 0 0 0 0 1 0.12424699 -0.215202096
#> cost:type1 cost:type2 cost:type3 size1:type1 size2:type1
#> (Intercept) 0.01159338 0.01639551 -0.02839786 -0.02028945 0.035142355
#> cost -0.02086808 -0.02951192 0.05111615 -0.05533486 0.095842787
#> size1 -0.05246564 -0.07419762 0.12851406 -0.04289550 -0.036813922
#> size2 0.09087316 0.12851406 -0.22259287 -0.03681392 -0.000386446
#> type1 0.12564544 -0.02434103 0.04215989 -0.08352014 0.144661130
#> type2 -0.02434103 0.10843373 0.05962309 0.02474182 -0.042854097
#> type3 0.04215989 0.05962309 0.03958692 -0.04285410 0.074225473
#> size1:type2 size2:type2 size1:type3 size2:type3
#> (Intercept) -0.02869361 0.0496987952 0.049698795 -0.0860808383
#> cost -0.07825531 0.1355421687 0.135542169 -0.2347659227
#> size1 -0.06066340 -0.0520627483 0.105072092 0.0901753252
#> size2 -0.05206275 -0.0005465171 0.090175325 0.0009465954
#> type1 0.02474182 -0.0428540970 -0.042854097 0.0742254733
#> type2 -0.06602503 0.1143587079 -0.060604845 0.1049706710
#> type3 -0.06060485 0.1049706710 0.003955417 -0.0068509825
#>
#> $correlation.matrix
#> cost size1 size2 type1 type2 type3
#> cost 1.00000000 0.00000000 0.00000000 0.02014149 0.02831827 0.04794633
#> size1 0.00000000 1.00000000 0.05976143 0.02898855 0.04075696 0.06900656
#> size2 0.00000000 0.05976143 1.00000000 0.04850713 0.06819943 0.11547005
#> type1 0.02014149 0.02898855 0.04850713 1.00000000 0.01654079 0.02800560
#> type2 0.02831827 0.04075696 0.06819943 0.01654079 1.00000000 0.03937496
#> type3 0.04794633 0.06900656 0.11547005 0.02800560 0.03937496 1.00000000
#>
#> $model
#> ~cost + size + type
#> <environment: 0x55f63bc4e208>
#>
#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 -0.8164966 -1.414214
#> [2,] 1 -1 1.4142136 0.000000 -0.5773503 1.6329932 0.000000
#> [3,] 1 -1 1.4142136 0.000000 -0.5773503 -0.8164966 -1.414214
#> [4,] 1 -1 -0.7071068 1.224745 -0.5773503 1.6329932 0.000000
#> [5,] 1 -1 -0.7071068 -1.224745 -0.5773503 -0.8164966 1.414214
#> [6,] 1 -1 1.4142136 0.000000 -0.5773503 -0.8164966 1.414214
#> [7,] 1 -1 -0.7071068 -1.224745 -0.5773503 1.6329932 0.000000
#> [8,] 1 -1 -0.7071068 1.224745 -0.5773503 -0.8164966 -1.414214
#> [9,] 1 1 -0.7071068 -1.224745 -0.5773503 1.6329932 0.000000
#> [10,] 1 -1 -0.7071068 1.224745 -0.5773503 -0.8164966 1.414214
#> [11,] 1 1 -0.7071068 -1.224745 -0.5773503 -0.8164966 1.414214
#> [12,] 1 1 1.4142136 0.000000 -0.5773503 -0.8164966 1.414214
#> [13,] 1 1 -0.7071068 1.224745 -0.5773503 1.6329932 0.000000
#> [14,] 1 1 -0.7071068 1.224745 -0.5773503 1.6329932 0.000000
#> [15,] 1 -1 -0.7071068 -1.224745 1.7320508 0.0000000 0.000000
#> [16,] 1 1 -0.7071068 -1.224745 -0.5773503 -0.8164966 1.414214
#> [17,] 1 1 -0.7071068 1.224745 -0.5773503 -0.8164966 -1.414214
#> [18,] 1 -1 1.4142136 0.000000 1.7320508 0.0000000 0.000000
#> [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 -0.7071068 -1.224745 1.7320508 0.0000000 0.000000
#> [22,] 1 -1 -0.7071068 1.224745 1.7320508 0.0000000 0.000000
#> [23,] 1 1 -0.7071068 1.224745 -0.5773503 -0.8164966 -1.414214
#> [24,] 1 1 -0.7071068 -1.224745 -0.5773503 -0.8164966 -1.414214
#> [25,] 1 1 1.4142136 0.000000 -0.5773503 1.6329932 0.000000
#> [26,] 1 1 -0.7071068 1.224745 1.7320508 0.0000000 0.000000
#> [27,] 1 -1 -0.7071068 1.224745 -0.5773503 -0.8164966 1.414214
#> [28,] 1 1 1.4142136 0.000000 -0.5773503 -0.8164966 1.414214
#> [29,] 1 1 1.4142136 0.000000 1.7320508 0.0000000 0.000000
# 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