Learn R Programming

deal (version 1.1-15)

simulation: Simulation of data sets with a given dependency structure

Description

Given a network with nodes having the 'simprob'-attribute, simulates a data set.

Usage

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

Arguments

nw
A network where each node have the attribute simprob (see makesimprob).
n
The number of cases to simulate.
file
If a file name is given, 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 normal distribution is used, according to the simprob attribute 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,specifygraph=FALSE,doprob=FALSE) # doprob must be False
nw <- makesimprob(nw)                     # create simprob attributes

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

Run the code above in your browser using DataLab