Skip to contents

Adds one restriction that forbids the Cartesian product of levels_a and levels_b for attributes attr_a and attr_b within a given scope.

Usage

cjtd_forbid_pairs(
  config,
  attr_a,
  levels_a,
  attr_b,
  levels_b,
  scope = "alternative"
)

Arguments

config

A cjtd_design_config object.

attr_a

Name of the first attribute.

levels_a

One or more levels of attr_a.

attr_b

Name of the second attribute.

levels_b

One or more levels of attr_b.

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
)

# Forbid one specific pair of levels from appearing together.
cfg <- cjtd_forbid_pairs(
  cfg,
  attr_a = "brand",
  levels_a = "A",
  attr_b = "price",
  levels_b = "very_low"
)

# Variations can forbid multiple levels on either side.
# cfg <- cjtd_forbid_pairs(cfg, "brand", c("A", "B"), "price", c("low", "very_low"))

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: forbid_pairs
#>     scope: alternative
#>     attr_a: brand
#>     levels_a: A
#>     attr_b: price
#>     levels_b: very_low
#> ────────────────────────────────────────────────────────────────────────────────