| Index | Topics |
| model string utilities {bnlearn} | R Documentation |
Build a model string from a Bayesian network and vice versa
Description
Build a model string from a Bayesian network and vice versa.
Usage
modelstring(x) modelstring(x, debug = FALSE) <- value model2network(string, debug = FALSE) ## S3 method for class 'bn': as.character(x, ...) ## S3 method for class 'character': as.bn(string, ...)
Arguments
x |
an object of class bn. modelstring (but not its replacement form) accepts
also objects of class bn.fit. |
string |
a character string describing the Bayesian network. |
value |
a character string, the same as the string. |
debug |
a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is
completely silent. |
... |
extra arguments from the generic method (currently ignored). |
Details
The strings returned by modelstring have the same format as the ones returned by the
modelstring function in package deal; network structures may be easily
exported to and imported from that package (via the model2network function).
Value
model2network and as.bn return an object of class bn;
modelstring and as.character.bn return a character string.
Author(s)
Marco Scutari
Examples
data(learning.test) res = set.arc(gs(learning.test), "A", "B") res # # Bayesian network learned via Constraint-based methods # # model: # [A][C][F][B|A][D|A:C][E|B:F] # nodes: 6 # arcs: 5 # undirected arcs: 0 # directed arcs: 5 # average markov blanket size: 2.33 # average neighbourhood size: 1.67 # average branching factor: 0.83 # # learning algorithm: Grow-Shrink # conditional independence test: Mutual Information (discrete) # alpha threshold: 0.05 # tests used in the learning procedure: 43 # modelstring(res) # [1] "[A][C][F][B|A][D|A:C][E|B:F]" res2 = model2network(modelstring(res)) res2 # # Randomly generated Bayesian network # # model: # [A][C][F][B|A][D|A:C][E|B:F] # nodes: 6 # arcs: 5 # undirected arcs: 0 # directed arcs: 5 # average markov blanket size: 2.33 # average neighbourhood size: 1.67 # average branching factor: 0.83 # # generation algorithm: Empty # compare(res, res2) # [1] TRUE
| Index | Topics |
