querygrain {gRain}R Documentation

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"), return="array", trace = 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.
return If "data.frame" the result is returned as a data frame (or possibly as a list of dataframes).
trace Debugging information

Value

A list of tables with potentials

Author(s)

Søren Højsgaard, sorenh@agrsci.dk

See Also

cptable

Examples

 testfile <- system.file("huginex", "chest_clinic.net", package = "gRain")
 chest <- as.grain(loadHuginNet(testfile, trace=1))
 print(class(chest))

 qb <- querygrain(chest)
 qb

 lapply(qb, as.numeric) # Safe
 sapply(qb, as.numeric) # Risky


[Package gRain version 0.7.0 Index]