simulate8bn: simulates a /dn/ from a /bn/

Description Usage Arguments Details Value Examples

Description

(dn) returns a matrix having simu rows and as many columns as variables in the bn, using the joint probability distribution implicitely defined by the bn.
Some of the columns can be already computed, in that case there are skipped from the general loop. This applies only for the root nodes to save the consistency with the /bn/ structure.

Usage

1
simulate8bn(bn, simu=100)

Arguments

bn

the bn to simulate

simu

either (1) a numeric indicating the desired number of simulations or (2) a data.frame whose the number of rows indicates the desired number of simulations, and where columns can comprises already computed nodes.
Already computed nodes are accepted when they are root node for the bn. If there are not root, they are not.
Notice that extra columns not being a node can be incorporated, they will be returned as they are.
To better tackle the 'categ' variables, all results coming back from the call of a generating function (associated to any node to simulate) are considered to be a data frame. If this is not the case, they are previously transformed in a data frame. Nevertheless the names of the variable are always imposed because some of the generating functions cannot do it.

Details

A compatible order with the definition of the conditional probabilities is first computed by porder, then nodes are sucessively generated according to this order using the generating functions stored into @rlks (except for some specific cases like 'empidata', 'numcat'...
BE AWARE that if a multivariate root node is included in the matrix simu, then ALL variables must be included and the fact is not checked.
Notice that the function relies on the column names of this matrix and also that the control of existing variables in case of multivariate nodes is not made a priori but at the moment of their use (then possibly generating an error message at an unexpected point for the user).

Value

the resulting data frame with values outside corresponding 'lpod's put to NA)

Examples

1
2
3
4
5
6
 rebastaba3k("RESET"); # For R convenience when checking
 simulate8bn(rebastaba.bn1, 10);
 simulate8bn(rebastaba.bn2, 10);
 simulate8bn(rebastaba.bn3, 10);
 simulate8bn(rebastaba.bn4, 10);
 simulate8bn(rebastaba.bn5, 10);

rebastaba documentation built on May 2, 2019, 5:24 p.m.