Learn R Programming

gRain (version 1.3.11)

grain_propagate: Propagate a graphical independence network (a Bayesian network)

Description

Propagation refers to calibrating the cliques of the junction tree so that the clique potentials are consistent on their intersections; refer to the reference below for details.

Usage

# S3 method for grain
propagate(object, details = object$details, engine = "cpp", ...)

propagateLS(cqpotList, rip, initialize = TRUE, details = 0)

Value

A compiled and propagated grain object.

Arguments

object

A grain object

details

For debugging info

engine

Either "R" or "cpp"; "cpp" is the default and the fastest.

...

Currently not used

cqpotList

List of clique potentials

rip

A rip ordering

initialize

Always true.

Author

Søren Højsgaard, sorenh@math.aau.dk

Details

The propagate method invokes propagateLS which is a pure R implementation of the Lauritzen-Spiegelhalter algorithm. The c++ based version is several times faster than the purely R based version.

References

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/.

See Also

grain, compile

Examples

Run this code

yn   <- c("yes","no")
a    <- cptable(~asia,              values=c(1,99), levels=yn)
t.a  <- cptable(~tub+asia,          values=c(5,95,1,99), levels=yn)
s    <- cptable(~smoke,             values=c(5,5), levels=yn)
l.s  <- cptable(~lung+smoke,        values=c(1,9,1,99), levels=yn)
b.s  <- cptable(~bronc+smoke,       values=c(6,4,3,7), levels=yn)
e.lt <- cptable(~either+lung+tub,   values=c(1,0,1,0,1,0,0,1), levels=yn)
x.e  <- cptable(~xray+either,       values=c(98,2,5,95), levels=yn)
d.be <- cptable(~dysp+bronc+either, values=c(9,1,7,3,8,2,1,9), levels=yn)
chest.cpt <- compileCPT(list(a, t.a, s, l.s, b.s, e.lt, x.e, d.be))
chest.bn  <- grain(chest.cpt)
bn1  <- compile(chest.bn, propagate=FALSE)
bn2  <- propagate(bn1)
bn3  <- compile(chest.bn, propagate=TRUE)
 

Run the code above in your browser using DataLab