Learn R Programming

BayesNetBP (version 1.0.1)

Marginals: Obtain marginal distributions

Description

Get the marginal distributions of multiple variables

Usage

Marginals(tree, vars)

Arguments

tree

a clustertree object

vars

a vector of variables for query of marginal distributions

Value

marginals

a list of marginal distributions

types

a named vector indicating the types of the variables whose marginals are queried: TRUE for discrete, FALSE for continuous.

Details

Get the marginal distributions of multiple variables. The function Marginals returns a list of marginal distributions. The marginal distribution of a discrete variable is a named vector of probabilities. Meanwhile, the marginal distributions of continous variables in a CG-BN model are mixtures of Gaussian distributions. To fully represent this information, the marginal of a continuous variable is represented by a data.frame with three columns to specify parameters for each Gaussian distribution in the mixture, which are

mean

the mean value of a Gaussian distribution.

sd

the standard deviation of a Gaussian distribution.

n

the number of Gaussian mixtures

References

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

See Also

PlotMarginals for visualization of the marginal distributions, SummaryMarginals for summarization of the marginal distributions of continuous variables.

Examples

Run this code

data(liver)
cst <- ClusterTreeCompile(dag=liver$dag, node.class=liver$node.class)
models <- LocalModelCompile(data=liver$data, dag=liver$dag, node.class=liver$node.class)
tree.init <- ElimTreeInitialize(tree=cst$tree.graph, 
                                dag=cst$dag, 
                                model=models, 
                                node.sets=cst$cluster.sets, 
                                node.class=cst$node.class)
tree.init.p <- PropagateDBN(tree.init)
tree.post <- AbsorbEvidence(tree.init.p, c("Nr1i3", "chr1_42.65"), list(1,"1"))
marg <- Marginals(tree.post, c("HDL", "Ppap2a"))
marg$marginals$HDL
head(marg$marginals$Ppap2a)

Run the code above in your browser using DataLab