Learn R Programming

gRain (version 1.0-3)

querygrain: Query an independence network

Description

Query an independence network, i.e. obtain the conditional distribution of a set of variables given finding (evidence) on other variables.

Usage

querygrain(object, nodes = nodeNames(object), normalize = TRUE, type =
c("marginal", "joint", "conditional"), result="array", details = 0)

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

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 (evidence), see examples below.
propagate
Should the network be propagated?
normalize
Should the results be normalized to sum to one.
type
Should marginals (for each node), the joint for all nodes, or the conditional of the first node given the rest be returned.
result
If "data.frame" the result is returned as a data frame (or possibly as a list of dataframes).
details
Debugging information

Value

  • A list of tables with potentials

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

cptable

Examples

Run this code
testfile <- system.file("huginex", "chest_clinic.net", package = "gRain")
 chest <- loadHuginNet(testfile, details=0)


 qb <- querygrain(chest)
 qb

 lapply(qb, as.numeric) sapply(qb, as.numeric)

Run the code above in your browser using DataLab