rbn {bnlearn}R Documentation

Generate random data from a given Bayesian network

Description

Generate random data from a given Bayesian network.

Usage

  rbn(x, n, data, debug = FALSE)

Arguments

x an object of class "bn".
n non-negative integer giving the number of observations to generate.
data a data frame, containing the data the Bayesian network was learned from.
debug a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is completely silent.

Value

A data frame with the same structure of the data parameter.

Note

Only discrete Bayesian networks are supported; the simulation uses an implementation of the Logic Sampling (LS) algorithm (Korb and Nicholson, 2004).

The execution time scales linearly with the number of generated data.

Node ordering uses a recursive approach; if there are lots of nodes in the network, you will need to increase R's recursion limit. See the expression argument to the options command for details on how to do this.

Author(s)

Marco Scutari

References

K. Korb and A. Nicholson. Bayesian artificial intelligence. Chapman and Hall, 2004.

Examples

## Not run: 
library(bnlearn)
data(learning.test)
res = gs(learning.test)
res = set.arc(res, "A", "B")
par(mfrow = c(1,2))
plot(res)
sim = rbn(res, 500, learning.test)
plot(gs(sim))
## End(Not run)

[Package bnlearn version 0.7 Index]