## Define the universe
yn <- c("yes", "no")
uni <- list(asia = yn, tub = yn, smoke = yn, lung = yn,
bronc = yn, either = yn, xray = yn, dysp = yn)
e1 <- list(dysp="no", xray="no")
eo1 <- new_evi(e1, levels=uni)
eo1 |> as.data.frame()
e2 <- list(dysp="no", xray=c(0, 1))
eo2 <- new_evi(e2, levels=uni)
eo2 |> as.data.frame()
# Above e1 and e2 specifies the same evidence but information about
# whether the state has been set definite or as a weight is
# maintained.
e3 <- list(dysp="yes", asia="yes")
eo3 <- new_evi(e3, uni)
eo3 |> as.data.frame()
# If evidence 'e1' is already set in the network and new evidence
# 'e3' emerges, then evidence in the network must be updated. But
# there is a conflict in that dysp="yes" in 'e1' and
# dysp="no" in 'e3'. The (arbitrary) convention is that
# existing evidence overrides new evidence so that the only new
# evidence in 'e3' is really asia="yes".
# To subtract existing evidence from new evidence we can do:
setdiff_evi(eo3, eo1) |> as.data.frame()
# Likewise the 'union' is
union_evi(eo3, eo1) |> as.data.frame()
Run the code above in your browser using DataLab