Skip to contents

Enforces that the number of attributes taking one of their selected levels is in the range implied by n.

Usage

cjtd_require_n_selected(config, selected, n, scope = "alternative")

Arguments

config

A cjtd_design_config object.

selected

Named list where each element is one attribute and one or more levels counted as selected.

n

Integer or integer sequence defining allowed counts.

scope

Restriction scope. Currently only "alternative" is supported.

Value

Updated cjtd_design_config.

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
#> ────────────────────────────────────────────────────────────────────────────────