Add a cardinality restriction over attribute-specific selected levels
Source:R/design_restrictions.R
cjtd_require_n_selected.RdEnforces that the number of attributes taking one of their selected levels is
in the range implied by n.
Examples
cfg <- cjtd_design_config(
attributes = list(
brand = c("A", "B", "C", "D"),
price = c("very_high", "high", "mid", "low", "very_low"),
f1 = c("off", "on"),
f2 = c("off", "on"),
f3 = c("off", "on")
),
n_tasks = 10,
n_alternatives = 3,
n_versions = 2
)
# Count how many of these binary attributes are "on" in each alternative.
cfg <- cjtd_require_n_selected(
cfg,
selected = list(
f1 = "on",
f2 = "on",
f3 = "on"
),
n = 1:2
)
# Selected levels can also contain more than one level per attribute.
# cfg <- cjtd_require_n_selected(cfg, selected = list(price = c("low", "very_low")), n = 0:1)
cfg
#>
#> ── Conjoint Design Config ──────────────────────────────────────────────────────
#> • n_tasks: 10
#> • n_alternatives: 3
#> • n_versions: 2
#> • restrictions: 1
#> attributes:
#> brand: A, B, C, D
#> price: very_high, high, mid, low, very_low
#> f1: off, on
#> f2: off, on
#> f3: off, on
#> restrictions:
#> [1] conjoint design restriction: require_n_selected
#> scope: alternative
#> attrs: f1, f2, f3
#> selected_levels: f1=[on]; f2=[on]; f3=[on]
#> min_count: 1
#> max_count: 2
#> n: 1, 2
#> ────────────────────────────────────────────────────────────────────────────────