Random values simulation from a Bayesian network | R Documentation |
Random values simulation from a Bayesian network.
rbn(n, dagobj, x)
n |
The number of observations to generate. |
dagobj |
A "bn" object. See the examples for more information. |
x |
The data used to fit the Bayesian network in a data.frame format. |
This information is taken directly from the R package "bnlearn". This function implements forward/logic sampling: values for the root nodes are sampled from their (un-conditional) distribution, then those of their children conditional on the respective parent sets. Thisis done iteratively until values have been sampled for all nodes.If "dagobj" contains NA parameter estimates (because of unobserved discrete parents configurations in the data the parameters were learned from), rbn will produce observations that contain NAs when thoseparents configurations appear in the simulated samples.
A data frame with the same structure (column names and data types) of the argument "data".
Michail Tsagris.
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.
Korb K. and Nicholson A.E. (2010).Bayesian Artificial Intelligence. Chapman & Hall/CRC, 2nd edition.
pchc
# simulate a dataset with continuous data
x <- matrix( rnorm(200 * 20, 1, 10), nrow = 200 )
a <- pchc::pchc(x)
sim <- pchc::rbn( 100, dagobj = a$dag, x = x )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.