Description Usage Arguments Details Value Author(s) References See Also Examples
Extract list of conditional probability tables and list of clique potentials from data.
1 2 3 4 5 6 7 8 9 | extractCPT(data_, graph, smooth = 0)
extractPOT(data_, graph, smooth = 0)
extractMARG(data_, graph, smooth = 0)
marg2pot(mg)
pot2marg(pt)
|
data_ |
A named array or a dataframe. |
graph |
A |
smooth |
See 'details' below. |
mg |
An object of class |
pt |
An object of class |
If smooth
is non-zero then smooth
is added
to all cell counts before normalization takes place.
extractCPT
: A list of conditional probability tables.
extractPOT
: A list of clique potentials.
extractMARG
: A list of clique marginals.
Søren Højsgaard, sorenh@math.aau.dk
Søren Højsgaard (2012). Graphical Independence Networks with the gRain Package for R. Journal of Statistical Software, 46(10), 1-26. http://www.jstatsoft.org/v46/i10/.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ## Extract cpts / clique potentials from data and graph
# specification and create network. There are different ways:
data(lizard, package="gRbase")
# DAG: height <- species -> diam
daG <- dag(~species + height:species + diam:species)
# UG : [height:species][diam:species]
uG <- ug(~height:species + diam:species)
pt <- extractPOT(lizard, ~height:species + diam:species)
cp <- extractCPT(lizard, ~species + height:species + diam:species)
pt
cp
# Both specify the same probability distribution
tabListMult(pt) %>% as.data.frame.table
tabListMult(cp) %>% as.data.frame.table
## Not run:
# Bayesian networks can be created as
bn.uG <- grain(pt)
bn.daG <- grain(cp)
# The steps above are wrapped into a convenience method which
# builds a network from at graph and data.
bn.uG <- grain(uG, data=lizard)
bn.daG <- grain(daG, data=lizard)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.