genData: Calling function to simulate data

Description Usage Arguments Value Examples

View source: R/genData.R

Description

Calling function to simulate data

Usage

1
genData(n, dtDefs = NULL, id = "id")

Arguments

n

the number of observations required in the data set.

dtDefs

name of definitions data.table/data.frame. If no definitions are provided a data set with ids only is generated.

id

The string defining the id of the record

Value

A data.table that contains the simulated data.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
genData(5)
genData(5, id = "grpID")

def <- defData(varname = "xNr", dist = "nonrandom", formula=7, id = "idnum")
def <- defData(def, varname="xUni", dist="uniform", formula="10;20")
def <- defData(def, varname="xNorm", formula="xNr + xUni * 2", dist="normal", variance=8)
def <- defData(def, varname="xPois", dist="poisson", formula="xNr - 0.2 * xUni", link="log")
def <- defData(def, varname="xCat", formula = "0.3;0.2;0.5", dist="categorical")
def <- defData(def, varname="xGamma", dist="gamma", formula = "5+xCat", variance = 1, link = "log")
def <- defData(def, varname = "xBin", dist = "binary" , formula="-3 + xCat", link="logit")
def

genData(5, def)

kgoldfeld/simstudy documentation built on Nov. 8, 2018, 7:41 p.m.