FactorQuery {BayesNetBP} | R Documentation |

## Queries of discrete variable distributions

### Description

Obtain the joint, marginal, and conditional distributions of discrete variables

### Usage

```
FactorQuery(tree, vars = c(), mode = c("joint", "conditional", "list"))
```

### Arguments

`tree` |
a |

`vars` |
the variables to be queried |

`mode` |
type of desired distribution |

### Details

Query the joint distribution of any combination of discrete variables when
mode is "joint", or conditional distribution of a discrete variable. The mode "list"
return a `list`

of variable combinations, such that joint distributions of any subset
of them are ready for extraction. Queries outside this list are also supported but may
take longer computing time. This function will also return marginal distribution if only
one variable is queried.

### Value

`data.frame`

object specifying a joint or conditional distribution.

### Author(s)

Han Yu

### References

Cowell, R. G. (2005). Local propagation in conditional Gaussian Bayesian networks.
Journal of Machine Learning Research, 6(Sep), 1517-1550.

Yu H, Moharil J, Blair RH (2020). BayesNetBP: An R Package for Probabilistic Reasoning in Bayesian
Networks. Journal of Statistical Software, 94(3), 1-31. <doi:10.18637/jss.v094.i03>.

### Examples

```
data(chest)
dag <- chest$dag
node.class <- rep(TRUE, length(dag@nodes))
names(node.class) <- dag@nodes
tree.init.p <- Initializer(dag=dag, data=chest$data,
node.class=node.class,
propagate=TRUE)
# joint distribution
FactorQuery(tree=tree.init.p, vars=c("tub", "xray", "dysp", "asia"), mode="joint")
# conditional distribution
FactorQuery(tree=tree.init.p, vars=c("xray"), mode="conditional")
```

*BayesNetBP*version 1.6.1 Index]