genFactor: Generate a dataframe of unordered factors with known...

Description Usage Arguments Details Note Author(s) Examples

View source: R/generators.R

Description

Quickly generate random dataframes of unordered factor variables with known associations

Usage

1
genFactor(n, k, nlevel, rho, seed, keepSeed, ...)

Arguments

n

Number of rows in the resulting dataframe

k

Number of columns in the resulting dataframe

nlevel

Number of levels in the factor variables created

rho

Level of association among the variables created

seed

Allows an arbitrary seed of length n to be passed to generate starting values

keepSeed

logical; do you want to return the initializing seed

...

Additional arguments to be passed to genNumeric behind the scenes

Details

Rho is used to generate associations between preceding variables in the dataframe. Element 1 and 2 are associated at the level of rho. Element 2 and 3 are also associated at the level of rho. All variables have the same number of levels – nlevels – and currently factor level names are randomly generated from letters.

Note

For low n the value of rho will vary more greatly from the desired value.

Author(s)

Jared E. Knowles

Examples

1
2
3
4
5
6
7
8
9
dat1 <- genFactor(1000, 12, nlevel=6, rho=0.4)
gammaGK(dat1[, 1], dat1[, 2])
gammaGK(dat1[, 2], dat1[, 3])
# Not close to Rho
gammaGK(dat1[, 1], dat1[, 3])

# low n deviates further from rho
dat2 <- genFactor(50, 10, nlevel=6, rho=0.2)
gammaGK(dat2[, 1], dat2[, 2])

jknowles/datasynthR documentation built on May 19, 2019, 11:42 a.m.