querygrain | R Documentation |
Query an independence network, i.e. obtain the conditional distribution of a set of variables - possibly (and typically) given finding (evidence) on other variables.
querygrain(
object,
nodes = nodeNames(object),
type = "marginal",
evidence = NULL,
exclude = TRUE,
normalize = TRUE,
simplify = FALSE,
result = "array",
details = 0
)
object |
A |
nodes |
A vector of nodes; those nodes for which the (conditional) distribution is requested. |
type |
Valid choices are |
evidence |
An alternative way of specifying findings (evidence), see examples below. |
exclude |
If |
normalize |
Should the results be normalized to sum to one. |
simplify |
Should the result be simplified (to a dataframe) if possible. |
result |
If "data.frame" the result is returned as a data frame (or possibly as a list of dataframes). |
details |
Debugging information |
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/.
setEvidence
, getEvidence
,
retractEvidence
, pEvidence
testfile <- system.file("huginex", "chest_clinic.net", package = "gRain")
chest <- loadHuginNet(testfile, details=0)
qb <- querygrain(chest)
qb
lapply(qb, as.numeric) # Safe
sapply(qb, as.numeric) # Risky
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.