Learn R Programming

deal (version 1.1-1)

simulation: Simulation of datasets with a given dependency structure

Description

Given a network with nodes having the 'simprob'-attribute, simulates a dataset

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 filename is given, the dataset is stored there.

Value

  • A dataframe with one row per case. If a filename is given, a file is created with the dataset.

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 probabilities or parameters given in simprob.

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 dataframe

Run the code above in your browser using DataLab