old_grain_evidence: Set, update and remove evidence.

old_grain_evidenceR Documentation

Set, update and remove evidence.

Description

Set, update and remove evidence.

Usage

setEvidence(
  object,
  nodes = NULL,
  states = NULL,
  evidence = NULL,
  propagate = TRUE,
  details = 0
)

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

absorbEvidence(object, propagate = TRUE)

getEvidence(object, short = TRUE)

pEvidence(object, evidence = NULL)

Arguments

object

A "grain" object

nodes

A vector of nodes.

states

A vector of states (of the nodes given by 'nodes'). Now deprecated; use argument 'evidence' instead.

evidence

A list of name=value. See examples below.

propagate

Should the network be propagated?

details

Debugging information

short

If TRUE a dataframe with a summary is returned; otherwise a list with all details.

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. https://www.jstatsoft.org/v46/i10/.

See Also

setFinding, getFinding, retractFinding, pFinding

Examples


example("example_chest_cpt")
chest.bn <- grain(compileCPT(chest_cpt))

bn2 <- chest.bn |> evidence_add(list(asia="yes", xray="yes"))
bn3 <- chest.bn |> evidence_add(list(asia=c(0.8, 0.1), xray="yes"))

bn2 |> evidence_get()
bn3 |> evidence_get()

bn2 |> evidence_prob()
bn3 |> evidence_prob()

bn2 |> evidence_drop("xray")
bn3 |> evidence_drop("xray")

bn2 |> evidence_drop("xray") |> evidence_get()
bn3 |> evidence_drop("xray") |> evidence_get()

## For backward compatibility these functions are available now but
#may be deprecated later.
bb2 <- setEvidence(chest.bn, c("asia", "xray"), c("yes", "yes"))
bb3 <- setEvidence(chest.bn, c("asia", "xray"), list(c(0.8, 0.2), "yes"))
bb4 <- setFinding(chest.bn, c("asia", "xray"), c("yes", "yes"))

bb2 |> getEvidence()
bb3 |> getEvidence()

bb2 |> retractEvidence("xray")
bb3 |> retractEvidence("xray")

bb2 |> pEvidence()
bb3 |> pEvidence()

bb2 |> retractEvidence("xray") |> getEvidence()
bb3 |> retractEvidence("xray") |> getEvidence()


gRain documentation built on Sept. 22, 2024, 9:07 a.m.