View source: R/frontend-simulation.R
rbn | R Documentation |
Simulate random samples from a given Bayesian network.
rbn(x, n = 1, ..., debug = FALSE)
x |
an object of class |
n |
a positive integer giving the number of observations to generate. |
... |
additional arguments for the parameter estimation prcoedure, see
again |
debug |
a boolean value. If |
rbn()
implements forward/logic sampling: values for the root nodes are
sampled from their (unconditional) distribution, then those of their children
conditional on the respective parent sets. This is done iteratively until
values have been sampled for all nodes.
If x
contains NA
parameter estimates (because of unobserved
discrete parents configurations in the data the parameters were learned from),
rbn
will produce samples that contain NA
s when those parents
configurations appear in the simulated samples. See bn.fit
for
details on how to make sure bn.fit
objects contain no NA
parameter estimates.
A data frame with the same structure as the data originally used to to fit the parameters of the Bayesian network.
Marco Scutari
Korb K, Nicholson AE (2010). Bayesian Artificial Intelligence. Chapman & Hall/CRC, 2nd edition.
cpdist
.
data(learning.test)
dag = hc(learning.test)
fitted = bn.fit(dag, learning.test)
rbn(fitted, 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.