grain_evidence | R Documentation |
Set, update and remove evidence.
evidence_add(object, evidence, propagate = TRUE, details = 0)
evidence_get(object, short = TRUE)
evidence_drop(object, nodes = NULL, propagate = TRUE)
evidence_prob(object, evidence = NULL)
object |
A "grain" object |
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. |
nodes |
A vector of nodes. |
A list of tables with potentials.
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.
Søren Højsgaard, sorenh@math.aau.dk
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/.
setFinding
, getFinding
,
retractFinding
, pFinding
example("grain")
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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.