setEvidence: Set evidence

Description Usage Arguments Examples

Description

Set and reset evidence in the network

Usage

1
setEvidence(network, evidence, propagate = FALSE)

Arguments

network

An existing network

evidence

Set state to a node

propagate

if set to TRUE, propagates the evidence through the network

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
node.a = createNodeInfo(~asia, prob=c(0.01, 0.99), states=c("yes","no"))
node.t = createNodeInfo(~tub|asia, prob=c(0.05, 0.95, 0.01, 0.99),states=c("yes","no"))
node.s = createNodeInfo(~smoke, prob=c(0.5,0.5), states=c("yes","no"))
node.l = createNodeInfo(~lung|smoke, prob=c(0.1, 0.9, 0.01, 0.99), states=c("yes","no"))
node.b = createNodeInfo(~bronc|smoke, prob=c(0.6, 0.4, 0.3, 0.7), states=c("yes","no"))
node.e = createNodeInfo(~either|lung:tub,prob=c(1,0,1,0,1,0,0,1),states=c("yes","no"))
node.x = createNodeInfo(~xray|either, prob=c(0.98, 0.02, 0.05, 0.95), states=c("yes","no"))
node.d = createNodeInfo(~dysp|bronc:either, prob=c(0.9, 0.1, 0.7, 0.3, 0.8, 0.2, 0.1, 0.9), states=c("yes", "no"))

nodes = list(node.a, node.t, node.s, node.l, node.b, node.e, node.x, node.d)
net = createNetwork(nodes, compile = TRUE)

## A priori probability for dysp = yes
aprioriProb = queryNetwork(net, c("dysp", "yes"))
aprioriProb

net = setEvidence(net, list(c("asia", "yes"), c("smoke", "no")))
net = propagateEvidence(net)
## A posteriori probability for dysp = yes given asia = yes and smoke = no
aposterioriProb = queryNetwork(net, c("dysp", "yes"))
aposterioriProb

rommelnc/runbbayes documentation built on May 27, 2019, 1:49 p.m.