Learn R Programming

MultiDiscreteRNG (version 0.1.0)

genMix: Generate multivariate mixed discrete data

Description

This function is the engine for simulating correlated mixed discrete outcomes once the intermediate binary parameters have been computed. It first generates correlated multivariate binary data using a latent normal approach implemented in generate.binaryVar and then maps the binary outcomes back to the original mixed discrete scales via a reverse-collapsing step implemented in BinToMix, using the component probability mass functions and dichotomization locations stored in binObj.

Usage

genMix(no.rows, binObj)

Value

A generated multivariate mixed discrete dataset (returned as a list containing the simulated data matrix and its empirical correlation matrix).

Arguments

no.rows

integer; number of observations to generate (sample size \(N\)).

binObj

list; intermediate object produced by the binary-correlation calibration step for mixed discrete margins (e.g., simBinaryCorr.Mix). It must contain:

pvec

numeric vector of binary success probabilities.

intermat

intermediate/tetrachoric correlation matrix for the latent normal model used to generate correlated binary data.

Mixprop

list of probability mass functions (probability masses over the support) for each discrete margin, used in the reverse-collapsing step.

Mlocation

numeric vector of dichotomization thresholds (median locations) used to split each marginal distribution into binary categories.

Examples

Run this code
GPD.theta = 4
GPD.lambda = 0.2
NB.r = 15
NB.prob = 0.42
M<- c(0.15, 0.2)
N <- diag(2)
N[lower.tri(N)] <- M
cmat<- N + t(N)
diag(cmat) <- 1
binObj = simBinaryCorr.Mix(GPD.theta.vec = GPD.theta, GPD.lambda.vec = GPD.lambda,
                           NB.r.vec = NB.r, NB.prob.vec = NB.prob,
                           CorrMat =cmat, no.rows = 20000, steps= 0.025)
Mix.data = genMix(no.rows = 100, binObj)$y

Run the code above in your browser using DataLab