Compile conditional probability tables / cliques potentials as a preprocessing step for creating a graphical independence network

compile_cpt(x, ..., forceCheck = TRUE)

compile_pot(x, ..., forceCheck = TRUE)

parse_cpt(xi)

Arguments

x

To compileCPT x is a list of conditional probability tables; to compilePOT, x is a list of clique potentials.

...

Additional arguments; currently not used.

forceCheck

Controls if consistency checks of the probability tables should be made.

xi

cpt in some representation

Value

A list with a class attribute.

Details

* `compileCPT` is relevant for turning a collection of
cptable's into an object from which a network can be built. For
example, when specification of a cpt is made with cptable then
the levels of the node is given but not the levels of the
parents. `compileCPT` checks that the levels of variables in
the cpt's are consistent and also that the specifications
define a dag.

* `compilePOT` is not of direct relevance for the
user for the moment. However, the elements of the input should
be arrays which define a chordal undirected graph and the
arrays should, if multiplied, form a valid probability density.

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

Author

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

Examples


example("example_chest_cpt")
#> 
#> exmp__> yn   <- c("yes", "no")
#> 
#> exmp__> a    <- cpt(~asia, values=c(1,99),levels=yn)
#> 
#> exmp__> t.a  <- cpt(~tub|asia, values=c(5,95,1,99),levels=yn)
#> 
#> exmp__> s    <- cpt(~smoke, values=c(5,5), levels=yn)
#> 
#> exmp__> l.s  <- cpt(~lung|smoke, values=c(1,9,1,99), levels=yn)
#> 
#> exmp__> b.s  <- cpt(~bronc|smoke, values=c(6,4,3,7), levels=yn)
#> 
#> exmp__> e.lt <- cpt(~either|lung:tub,values=c(1,0,1,0,1,0,0,1),levels=yn)
#> 
#> exmp__> x.e  <- cpt(~xray|either, values=c(98,2,5,95), levels=yn)
#> 
#> exmp__> d.be <- cpt(~dysp|bronc:either, values=c(9,1,7,3,8,2,1,9), levels=yn)
#> 
#> exmp__> chest_cpt <- list(a, t.a, s, l.s, b.s, e.lt, x.e, d.be)
#> 
#> exmp__> ## bn <- grain(compile_cpt(chest_cpt))
#> exmp__> 
#> exmp__> 
#> exmp__> 
x <- compile_cpt(chest_cpt)
class(x)
#> [1] "cpt_spec"
grain(x)
#> Independence network: Compiled: TRUE Propagated: FALSE Evidence: FALSE