grain_evidence: Set, update and remove evidence.

Description Usage Arguments Value Note Author(s) References See Also Examples

Description

Set, update and remove evidence.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
setEvidence(
  object,
  nodes = NULL,
  states = NULL,
  evidence = NULL,
  nslist = NULL,
  propagate = TRUE,
  details = 0
)

retractEvidence(object, nodes = NULL, propagate = TRUE)

absorbEvidence(object, propagate = TRUE)

pEvidence(object)

getEvidence(object)

evidence(object)

## S3 method for class 'grain'
evidence(object)

evidence(object) <- value

## S3 replacement method for class 'grain'
evidence(object) <- value

Arguments

object

A "grain" object

nodes

A vector of nodes; those nodes for which the (conditional) distribution is requested.

states

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

evidence

An alternative way of specifying findings (evidence), see examples below.

nslist

deprecated

propagate

Should the network be propagated?

details

Debugging information

value

The evidence in the form of a named list or an evidence-object.

Value

A list of tables with potentials.

Note

setEvidence() is an improvement of setFinding() (and as such setFinding is obsolete). Users are recommended to use setEvidence() in the future.

setEvidence() allows to specification of "hard evidence" (specific values for variables) and likelihood evidence (also known as virtual evidence) for variables.

The syntax of setEvidence() may change in the future.

Author(s)

Søren Højsgaard, sorenh@math.aau.dk

References

Søren Hø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

setFinding, getFinding, retractFinding, pFinding

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
data(chest_cpt)
chest.bn <- grain(compileCPT(chest_cpt))
chest.bn <- compile(chest.bn)

## 1) These two forms are identical
setEvidence(chest.bn, c("asia", "xray"), c("yes", "yes"))
setFinding(chest.bn, c("asia", "xray"), c("yes", "yes"))

## 2) Suppose we do not know with certainty whether a patient has
## recently been to Asia. We can then introduce a new variable
## "guess.asia" with "asia" as its only parent. Suppose
## p(guess.asia=yes|asia=yes)=.8 and p(guess.asia=yes|asia=no)=.1
## If the patient is e.g. unusually tanned we may set
## guess.asia=yes and propagate.
##
## This corresponds to modifying the model by the likelihood (0.8,
## 0.1) as

setEvidence(chest.bn, c("asia", "xray"), list(c(0.8, 0.1), "yes"))

## 3) Hence, the same result as in 1) can be obtained with
setEvidence(chest.bn, c("asia", "xray"), list(c(1, 0), "yes"))

## 4) An alternative specification using evidence is
setEvidence(chest.bn, evidence=list(asia=c(1, 0), xray="yes"))

DataSciBurgoon/gRain documentation built on March 25, 2020, 12:02 a.m.