Learn R Programming

gRain (version 1.3-0)

finding: Set, retrieve, and retract finding in Bayesian network.

Description

Set, retrieve, and retract finding in Bayesian network. NOTICE: The functions described here are kept only for backward compatibility; please use the corresponding evidence-functions in the future.

Usage

setFinding(object, nodes = NULL, states = NULL, flist = NULL,
  propagate = TRUE)

Arguments

object

A "grain" object

nodes

A vector of nodes

states

A vector of states (of the nodes given by 'nodes')

flist

An alternative way of specifying findings, see examples below.

propagate

Should the network be propagated?

References

S<U+00F8>ren H<U+00F8>jsgaard (2012). Graphical Independence Networks with the gRain Package for R. Journal of Statistical Software, 46(10), 1-26. http://www.jstatsoft.org/v46/i10/.

See Also

setEvidence getEvidence retractEvidence pEvidence querygrain

Examples

Run this code
# NOT RUN {

## setFindings
yn <- c("yes","no")
a    <- cptable(~asia, values=c(1,99),levels=yn)
t.a  <- cptable(~tub+asia, values=c(5,95,1,99),levels=yn)
s    <- cptable(~smoke, values=c(5,5), levels=yn)
l.s  <- cptable(~lung+smoke, values=c(1,9,1,99), levels=yn)
b.s  <- cptable(~bronc+smoke, values=c(6,4,3,7), levels=yn)
e.lt <- cptable(~either+lung+tub,values=c(1,0,1,0,1,0,0,1),levels=yn)
x.e  <- cptable(~xray+either, values=c(98,2,5,95), levels=yn)
d.be <- cptable(~dysp+bronc+either, values=c(9,1,7,3,8,2,1,9), levels=yn)
plist <- compileCPT(list(a, t.a, s, l.s, b.s, e.lt, x.e, d.be))
chest <- grain(plist)

## These two forms are equivalent
bn1 <- setFinding(chest, nodes=c("asia","xray"), states=c("yes", "yes"))
bn2 <- setFinding(chest, flist=list(c("asia","yes"), c("xray", "yes")))

getFinding(bn1)
getFinding(bn2)

pFinding(bn1)
pFinding(bn2)

bn1 <- retractFinding(bn1, nodes="asia")
bn2 <- retractFinding(bn2, nodes="asia")

getFinding(bn1)
getFinding(bn2)

pFinding(bn1)
pFinding(bn2)


# }

Run the code above in your browser using DataLab