gm.modelsim {gmvalid}R Documentation

Random data frames with given dependence model and fixed marginals

Description

Generates a random data frame of discrete variables given a dependence model and marginals.

Usage

    gm.modelsim(N, model, categories = 0)

Arguments

N Number of observations, sample size.
model A character string assigning a dependence model expressed as clique structure. Each variable has to be expressed as a letter, e.g. "ABC,CDE".
categories a list of weight vectors that assigns the weight of each catogory. Number of list elements must equal the number of variables in model. Default is "list(c(.5,.5),c(.5,.5),...)".

Value

A data frame with number of rows approximately equal to N and number of columns equal to the number of variables used in model.

Note

Observed marginal probabilities reflect the given marginal probabilites only approximatively. Works best with large sample sizes, like e.g. N=10,000.

Author(s)

Ronja Foraita, Fabian Sobotka
Bremen Institute for Prevention Research and Social Medicine
(BIPS) http://www.bips.uni-bremen.de

See Also

gm.generate, gm.sim.ixj, r2dtable

Examples

    gm.modelsim(100,"AB,AC")
    table( gm.modelsim(100,"a,b,c") )
    
    tmp.df <- gm.modelsim(10000,"abf,cd,cf,bdeg,bfg")
    
    # with given number of categories
    tmp.df <- gm.modelsim(1000,"AB,C",list(c(1,1,1),c(1,1),c(1,1,1)))

    # with given number of categories and marginals
    tmp.df <- gm.modelsim(1000,"ABC",list(c(0.3,0.3,0.4),c(0.6,.4),c(0.25,0.25,0.5)))
    table(tmp.df)

    ## Not run: 
tmp.df <- gm.modelsim(100,"ABC",list(3,2,3))# (number of categories will be 2 x 2 x 2 )
            gm.modelsim(100,"123")
            
## End(Not run)

[Package gmvalid version 1.2 Index]