ep {mvtBinaryEP} | R Documentation |
Generates correlated binary data based on the method of Emrich and Piedmonte (1991)
ep(mu, R, rho, n, isd = NULL, nRep = 1, seed = NULL, crit = 1e-06, maxiter = 20)
mu |
Vector of means. If rho is specified then mu must be of length 1. |
R |
Correlation matrix. If rho is specified then R is ignored. Only the
upper part of R is used. |
rho |
If common mean and exchangeable correlation is desired, then this correlation parameter must be specified. |
n |
Cluster size. If rho is specified, then this must be specified as well. |
isd |
Internal Simulation Descriptor. This is useful for generating more responses
based on the parameters used in the prior call to ep . This increases
efficiency since the intermediate quantities need not be recomputed. isd is
a list containing some of the input parameters as well as some intermediate
quantities. If this is provided then R and rho are ignored. |
nRep |
Number of clusters (replications). |
seed |
Sets the seed |
crit |
Level of precision used in solving for the tetra-choric correlations. |
maxiter |
Maximum number of iterations used in solving for the tetra-choric correlations. |
The method relies on simulating multivariate normal vectors and then dichotomizing each
coordinate. The cutpoints are determined by mu
. The correlation matrix S
(which are the tetra-choric correlations) of the multivariate normal vectors is computed
in such a way that the resulting binary vectors have correlation matrix R
. One possible
complication is that this process is not always possible. Further, when all tetra-choric
correlations are computed, the resulting matrix, S
, may not be positive definite. These
are two possible failure points in the algorithm; both are detected and reported back by the code.
Returns a list with the following two components:
y |
Multivariate response of dimension nRep by length(mu) |
isd |
Internal Simulation Descriptor |
The returned object isd is also a list with the following fields:
mu
rho
n
R
rootS
S
pd
sp
i
j
See Also ranMVN
, ranMVN2
, ranMvnXch
# Create mean vector mu=c(0.5, 0.3, 0.20, 0.1) # Create correlation matrix R = c( 1 , 0.2 , 0.15, -0.05, 0.2 , 1 , 0.25, 0.2 , 0.15 , 0.25, 1 , 0.25 , -0.05, 0.2 , 0.25, 1 ) R = matrix(R, ncol=4) ep0 = ep(mu=mu, R=R, nRep=1000, seed=NULL) apply(ep0$y, 2, mean); cor(ep0$y) #Generates more responses based on the parameters provided above. ep1 = ep(isd = ep0$isd, nRep=1000, seed=NULL) apply(ep1$y, 2, mean); cor(ep1$y) # 5-variate based on common mean and exchangeable correlation. ep2 = ep(mu=0.3, rho=0.2, n=5, nRep=10000) apply(ep2$y, 2, mean); cor(ep2$y)