Skip to contents

Forbids every edge between variables that are more than max_lag tiers apart, based on the tiers currently defined on kn.

Usage

set_max_lag(kn, max_lag)

Arguments

kn

A Knowledge object that already has tiers defined.

max_lag

A single positive integer: the maximum allowed tier distance between the endpoints of an edge.

Value

The updated Knowledge object, with the new forbidden edges added and max_lag stored on it.

Examples

data(tpc_example)

# verb form: forbid edges that skip more than one tier
kn1 <- knowledge(
  tpc_example,
  tier(
    child ~ starts_with("child"),
    youth ~ starts_with("youth"),
    old ~ starts_with("oldage")
  )
) |>
  set_max_lag(1)

print(kn1)
#> <Knowledge: 3 tiers | max_lag = 1 | 6 vars | 4 forbidden>
#>   tier(child): child_x1, child_x2
#>   tier(youth): youth_x3, youth_x4
#>   tier(old): oldage_x5, oldage_x6
#>   forbidden:
#>     child_x1!-->oldage_x5 + oldage_x6
#>     child_x2!-->oldage_x5 + oldage_x6

# DSL form: max_lag() inside tier() is equivalent
kn2 <- knowledge(
  tpc_example,
  tier(
    child ~ starts_with("child"),
    youth ~ starts_with("youth"),
    old ~ starts_with("oldage"),
    max_lag(1)
  )
)

print(identical(kn1, kn2))
#> [1] TRUE