Learn R Programming

deal (version 1.2-4)

simulation: Simulation of data sets with a given dependency structure

Description

Given a network with nodes having the simprob property, simulation simulates a data set.

Usage

simulation(nw, n=24, file="")

Arguments

nw
an object of class network, where each node has the property simprob (see makesimprob).
n
an integer, which gives the number of cases to simulate.
file
a string. If non-empty, the data set is stored there.

Value

  • A data frame with one row per case. If a file name is given, a file is created with the data set.

Details

The variables are simulated one at a time in an order that ensures that the parents of the node have already been simulated. For discrete variables a multinomial distribution is used and for continuous variables, a Gaussian distribution is used, according to the simprob property in each node.

References

Further information about deal can be found at: http://www.math.auc.dk/novo/deal.

Examples

Run this code
A  <- factor(NA,levels=paste("A",1:2,sep=""))
B  <- factor(NA,levels=paste("B",1:3,sep=""))
c1 <- NA
c2 <- NA
df <- data.frame(A,B,c1,c2)

nw <- network(df,doprob=FALSE) # doprob must be FALSE
nw <- makesimprob(nw)          # create simprob properties

set.seed(944) 
sim <- simulation(nw,n=100)    # create simulated data frame

Run the code above in your browser using DataLab