genOrdNor: Generates a data set with ordinal and normal variables

Description Usage Arguments Value References See Also Examples

View source: R/genOrdNor.R

Description

The function simulates a data set with ordinal and normal components with a pre-specified correlation matrix and marginals.

Usage

1
genOrdNor(n, plist, cmat.star, mean.vec, sd.vec, no.ord, no.norm)

Arguments

n

Number of rows

plist

A list of probability vectors corresponding to each ordinal variable. The i-th element of plist is a vector of the cumulative probabilities defining the marginal distribution of the i-th ordinal component of the multivariate variables. If the i-th ordinal variable has k categories, the i-th vector of the plist will contain k-1 probability values. The k-th element is implicitly 1.

cmat.star

The intermediate correlation matrix obtained from cmat.star function.

mean.vec

A vector of means for the normal variables.

sd.vec

A vector of standard deviations for the normal variables.

no.ord

Number of ordinal variables.

no.norm

Number of normal variables.

Value

A matrix of size n \times (no.ord + no.norm), of which first no.ord are ordinal variables.

References

Demirtas, H., Yavuz, Y. (2015). Concurrent generation of ordinal and normal data. Journal of Biopharmaceutical Statistics; 25(4), 635-650.

See Also

cmat.star, validate.target.cormat, validate.plist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
	Sigma = diag(4)
	Sigma[lower.tri(Sigma)] = c(0.42, 0.78, 0.29, 0.37, 0.14, 0.26)
	Sigma = Sigma + t(Sigma)
	diag(Sigma)=1

	marginal = list( c(0.2, 0.5), c(0.4, 0.7, 0.9))
	cmat= cmat.star(marginal, Sigma, 2, 2)  
	mean.vec = c(2,4)
	sd.vec = c(0.5, 1.5)
	Y=genOrdNor(10000,marginal, cmat, mean.vec, sd.vec, 2, 2)
	cor(Y)

Example output

Loading required package: mvtnorm
Loading required package: corpcor
Loading required package: Matrix
Loading required package: GenOrd
Loading required package: MASS
          [,1]      [,2]      [,3]      [,4]
[1,] 1.0000000 0.4234109 0.7800659 0.2813916
[2,] 0.4234109 1.0000000 0.3796650 0.1365731
[3,] 0.7800659 0.3796650 1.0000000 0.2497522
[4,] 0.2813916 0.1365731 0.2497522 1.0000000

OrdNor documentation built on March 6, 2021, 1:08 a.m.