genOrdNor {OrdNor} | R Documentation |
Generates a data set with ordinal and normal variables
Description
The function simulates a data set with ordinal and normal components with a pre-specified correlation matrix and marginals.
Usage
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 |
cmat.star |
The intermediate correlation matrix obtained from |
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
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)