# NOT RUN {
## Define the universe
uni <- list(asia = c("yes", "no"), tub = c("yes", "no"), smoke = c("yes", "no"),
lung = c("yes", "no"), bronc = c("yes", "no"), either = c("yes", "no"),
xray = c("yes", "no"), dysp = c("yes", "no"))
e1 <- list(dysp="no", xray="no")
eo1 <- new_ev( e1, levels=uni )
eo1
as.data.frame( eo1 )
eo1 %>% str
e1.2 <- list(dysp="no", xray=c(0, 1))
eo1.2 <- new_ev( e1.2, levels=uni )
eo1.2
# Notice that in \code{eo1.2}, \code{xray} is not regarded as hard
# evidence but as a weight on each level. Other than that \code{eo1.2}
# and \code{eo1} are equivalent here. This is used in connection
# with specifying likelihood evidence.
e2 <- list(dysp="yes", asia="yes")
eo2 <- new_ev(e2, uni)
# If evidence 'e1' is already set in the network and new evidence
# 'e2' emerges, the evidence in the network must be updated. But
# there is a conflict in that \code{dysp="yes"} in 'e1' and
# \code{dysp="no"} in 'e2'. The (arbitrary) convention is that
# existsting evidence overrides new evidence so that the only new
# evidence in 'e2' is really \code{asia="yes"}.
# To subtract existing evidence from new evidence we can do:
setdiff_ev( eo2, eo1 )
# Likewise the 'union' is
union_ev( eo2, eo1 )
# }
Run the code above in your browser using DataLab