Learn R Programming

pchc (version 1.2)

Random values simulation from a Bayesian network: Random values simulation from a Bayesian network

Description

Random values simulation from a Bayesian network.

Usage

rbn(n, dagobj, x)

Value

A data frame with the same structure (column names and data types) of the argument "data".

Arguments

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.

Author

Michail Tsagris.

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.

Details

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.

References

Korb K. and Nicholson A.E. (2010).Bayesian Artificial Intelligence. Chapman & Hall/CRC, 2nd edition.

See Also

pchc

Examples

Run this code
# 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 )

Run the code above in your browser using DataLab