rnetwork {deal}R Documentation

Simulation of data sets with a given dependency structure

Description

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

Usage

rnetwork(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.

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.

Value

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

Author(s)

Susanne Gammelgaard Bottcher,
Claus Dethlefsen rpackage.deal@gmail.com.

Examples

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 <- rnetwork(nw,n=100)    # create simulated data frame

[Package deal version 1.2-42 Index]