R: Import and export networks from the gRain package

gRain integration {bnlearn} | R Documentation

## Import and export networks from the gRain package

### Description

Convert `bn.fit` objects to `grain` objects and vice versa.

### Usage

    ## S3 method for class 'grain'
    as.bn.fit(x, ...)
    ## S3 method for class 'bn.fit'
    as.grain(x)
    ## S3 method for class 'grain'
    as.bn(x, ..., check.cycles = TRUE)

### Arguments

`x` | an object of class `grain(code)` (for `as.bn.fit`) or `bn.fit()` (for `as.grain`).
`...` | extra arguments from the generic method (currently ignored).
`check.cycles` | a boolean value. If `FALSE` the returned network will not be checked for cycles.

### Value

An object of class `grain` (for `as.grain`) or `bn.fit` (for `as.bn.fit`).

### Note

Conditional probability tables in `grain` objects must be completely specified; on the other hand, `bn.fit` allows `NaN` values for unobserved parents' configurations. Such `bn.fit` objects will be converted to $m$ codegrain objects by replacing the missing conditional probability distributions with uniform distributions.

Another solution to this problem is to fit another `bn.fit` with `method = "bayes"` and a low `iss` value, using the same data and network structure.

Ordinal nodes will be treated as categorical by `as.grain`, disregarding the ordering of the levels.

### Author(s)

Marco Scutari

### Examples

    ## Not run:
    library(gRain)
    a = bn.fit(hc(learning.test), learning.test)
    b = as.grain(a)
    c = as.bn.fit(b)
    ## End(Not run)

[Package bnlearn version 4.4.1 Index]