simulate.bn: Draw data according to a Bayesian Network.

Description Usage Arguments See Also Examples

View source: R/sample.R

Description

Draw data according to a Bayesian Network.

Usage

1
2
  simulate.bn(object, nsim, seed, ptables, expectation = F,
  ...)

Arguments

object

A object of class bn

nsim

Number of simulations

seed

The starting seed (UNIMPLEMENTED)

ptables

A table of the form generated by cptBinary and ptablesDirichlet.

expectation

...

...

Further arguments, currently unused

See Also

cptBinary, ptablesDirichlet

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
cpt <- list(
as.table(array(c(0.7, 0.3), 2)),
as.table(array(c(0.5, 0.5, 0.2, 0.8), c(2, 2)))
)
net <- bn(NULL, 1)
sim <- simulate(object = net, nsim = 1000, ptables = cpt)

# a three node example
cpt <- list(
as.table(array(c(0.7, 0.3), 2)),
as.table(array(c(0.5, 0.5,
0.2, 0.8),
c(2, 2))),
as.table(array(c(
# prob of 1 then 2 given
0.8, 0.2, # p1 = 1, p2 = 1
0.2, 0.8, # p1 = 2, p2 = 1
0.2, 0.8, # p1 = 1, p2 = 2
0.2, 0.8  # p1 = 2, p2 = 2
), c(2, 2, 2)))
)
net <- bn(NULL, 1L, c(1L, 2L))
sim <- simulate(object = net, nsim = 1000, ptables = cpt)

rjbgoudie/parental documentation built on May 27, 2019, 9:11 a.m.