Description Usage Arguments Details Value Author(s) Examples

View source: R/frontend-formula.R

Build a model string from a Bayesian network and vice versa.

1 2 3 4 5 6 7 8 9 | ```
modelstring(x)
modelstring(x, debug = FALSE) <- value
model2network(string, ordering = NULL, debug = FALSE)
## S3 method for class 'bn'
as.character(x, ...)
## S3 method for class 'character'
as.bn(x, ...)
``` |

`x` |
an object of class |

`string` |
a character string describing the Bayesian network. |

`ordering` |
the labels of all the nodes in the graph; their order is the
node ordering used in the construction of the |

`value` |
a character string, the same as the |

`debug` |
a boolean value. If |

`...` |
extra arguments from the generic method (currently ignored). |

The strings returned by `modelstringi()`

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

The format of the model strings is as follows. The local structure of each
node is enclosed in square brackets ("`[]`

"); the first string is the
label of that node. The parents of the node (if any) are listed after a
("`|`

") and separated by colons ("`:`

"). All nodes (including
isolated and root nodes) must be listed.

`model2network()`

and `as.bn()`

return an object of class `bn`

;
`modelstring()`

and `as.character.bn()`

return a character string.

Marco Scutari

1 2 3 4 5 6 7 | ```
data(learning.test)
res = set.arc(gs(learning.test), "A", "B")
res
modelstring(res)
res2 = model2network(modelstring(res))
res2
all.equal(res, res2)
``` |

```
Attaching package: 'bnlearn'
The following object is masked from 'package:stats':
sigma
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 (disc.)
alpha threshold: 0.05
tests used in the learning procedure: 60
optimized: TRUE
[1] "[A][C][F][B|A][D|A:C][E|B:F]"
Random/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
[1] TRUE
```

bnlearn documentation built on Jan. 15, 2018, 5:06 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.