Learn R Programming

MultiOrd (version 2.4.4)

generate.binary: Generates multivariate binary data given marginal probabilities and correlation.

Description

Generates multivariate binary data given marginal probabilities and correlation based on the algorithm described in Emrich and Piedmonte (1991).

Usage

generate.binary(nObs, prop.vec.bin, corr.mat)

Value

data

Matrix of multivariate binary data

Arguments

nObs

Number of observations

prop.vec.bin

Vector of binary marginal probabilities

corr.mat

correlation matrix of the binary data

Details

It generates multivariate binary data from the marginal probabilities and correlation matrix. It uses the algorithm described in Emrich and Piedmonte (1991). In the process, if the tetrachoric correlation matrix is non-positive definite, a nearest positive definite matrix is used.

See Also

nearPD, compute.sigma.star

Examples

Run this code
if (FALSE) ordPmat1 = matrix( c(0.15,0.70,0.40,
					0.55,0.10,0.25,
					0.25,0.10,0.15,
					0.05,0.10,0.20),4,3,byrow=TRUE)
if (FALSE) cmat1= matrix( 	c(1,0.2,0.2,
				0.2,1,0.2,
				0.2,0.2,1),3,3,byrow=TRUE)
if (FALSE) p=find.binary.prob(ordPmat1) 
if (FALSE) finalCorr = simBinCorr(ordPmat1, cmat1, no.rows=100000)
if (FALSE) y=generate.binary( 1000, p$p, finalCorr$del.next)

Run the code above in your browser using DataLab